mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-06-25 05:04:07 +00:00
use svg vector format
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
This commit is contained in:
parent
8070f66142
commit
2687545e33
11 changed files with 106 additions and 9 deletions
|
|
@ -19,6 +19,7 @@ analyzer:
|
||||||
- "lib/core/**"
|
- "lib/core/**"
|
||||||
- "lib/src/localization/**"
|
- "lib/src/localization/**"
|
||||||
- "rust_builder/"
|
- "rust_builder/"
|
||||||
|
- "scripts/"
|
||||||
- "build/"
|
- "build/"
|
||||||
- "dependencies/**"
|
- "dependencies/**"
|
||||||
- "pubspec.yaml"
|
- "pubspec.yaml"
|
||||||
|
|
|
||||||
BIN
assets/icons/verification_badge_numeric/verified_badge_1.svg.vec
Normal file
BIN
assets/icons/verification_badge_numeric/verified_badge_1.svg.vec
Normal file
Binary file not shown.
BIN
assets/icons/verification_badge_numeric/verified_badge_2.svg.vec
Normal file
BIN
assets/icons/verification_badge_numeric/verified_badge_2.svg.vec
Normal file
Binary file not shown.
BIN
assets/icons/verification_badge_numeric/verified_badge_3.svg.vec
Normal file
BIN
assets/icons/verification_badge_numeric/verified_badge_3.svg.vec
Normal file
Binary file not shown.
BIN
assets/icons/verified_badge_green.svg.vec
Normal file
BIN
assets/icons/verified_badge_green.svg.vec
Normal file
Binary file not shown.
BIN
assets/icons/verified_badge_red.svg.vec
Normal file
BIN
assets/icons/verified_badge_red.svg.vec
Normal file
Binary file not shown.
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:twonly/src/visual/themes/light.dart';
|
import 'package:twonly/src/visual/themes/light.dart';
|
||||||
|
import 'package:vector_graphics/vector_graphics.dart';
|
||||||
|
|
||||||
/// Animated chain-link logo for the "verification success" moment.
|
/// Animated chain-link logo for the "verification success" moment.
|
||||||
///
|
///
|
||||||
|
|
@ -338,8 +339,10 @@ class VerificationSuccessAnimationState
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: widget.size * 0.5,
|
width: widget.size * 0.5,
|
||||||
height: widget.size * 0.5,
|
height: widget.size * 0.5,
|
||||||
child: SvgPicture.asset(
|
child: const SvgPicture(
|
||||||
'assets/icons/verified_badge_green.svg',
|
AssetBytesLoader(
|
||||||
|
'assets/icons/verified_badge_green.svg.vec',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:vector_graphics/vector_graphics.dart';
|
||||||
|
|
||||||
class SvgIcons {
|
class SvgIcons {
|
||||||
static const String verifiedGreen = 'assets/icons/verified_badge_green.svg';
|
static const String verifiedGreen =
|
||||||
static const String verifiedRed = 'assets/icons/verified_badge_red.svg';
|
'assets/icons/verified_badge_green.svg.vec';
|
||||||
|
static const String verifiedRed = 'assets/icons/verified_badge_red.svg.vec';
|
||||||
|
|
||||||
static String verifiedNumeric(int value) {
|
static String verifiedNumeric(int value) {
|
||||||
if (value >= 4) {
|
if (value >= 4) {
|
||||||
return verifiedGreen;
|
return verifiedGreen;
|
||||||
}
|
}
|
||||||
return 'assets/icons/verification_badge_numeric/verified_badge_$value.svg';
|
return 'assets/icons/verification_badge_numeric/verified_badge_$value.svg.vec';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,13 +28,24 @@ class SvgIcon extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final filter = color != null
|
||||||
|
? ColorFilter.mode(color!, BlendMode.srcIn)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (assetPath.endsWith('.vec')) {
|
||||||
|
return SvgPicture(
|
||||||
|
AssetBytesLoader(assetPath),
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
colorFilter: filter,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return SvgPicture.asset(
|
return SvgPicture.asset(
|
||||||
assetPath,
|
assetPath,
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
colorFilter: color != null
|
colorFilter: filter,
|
||||||
? ColorFilter.mode(color!, BlendMode.srcIn)
|
|
||||||
: null,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2047,7 +2047,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.13"
|
version: "1.1.13"
|
||||||
vector_graphics_compiler:
|
vector_graphics_compiler:
|
||||||
dependency: transitive
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: vector_graphics_compiler
|
name: vector_graphics_compiler
|
||||||
sha256: "5a88dd14c0954a5398af544651c7fb51b457a2a556949bfb25369b210ef73a74"
|
sha256: "5a88dd14c0954a5398af544651c7fb51b457a2a556949bfb25369b210ef73a74"
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,7 @@ dev_dependencies:
|
||||||
drift_dev: ^2.25.2
|
drift_dev: ^2.25.2
|
||||||
flutter_launcher_icons: ^0.14.1
|
flutter_launcher_icons: ^0.14.1
|
||||||
flutter_lints: ^6.0.0
|
flutter_lints: ^6.0.0
|
||||||
|
vector_graphics_compiler: ^1.2.0
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
json_serializable: ^6.8.0
|
json_serializable: ^6.8.0
|
||||||
|
|
|
||||||
79
scripts/compile_svgs.dart
Normal file
79
scripts/compile_svgs.dart
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
// ignore_for_file: avoid_print
|
||||||
|
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
Future<void> main() async {
|
||||||
|
final iconsDir = Directory('assets/icons');
|
||||||
|
if (!iconsDir.existsSync()) {
|
||||||
|
print(
|
||||||
|
'Error: assets/icons directory does not exist at ${iconsDir.absolute.path}',
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
print('Locating SVG files recursively under assets/icons...');
|
||||||
|
final svgFiles = <File>[];
|
||||||
|
try {
|
||||||
|
await for (final entity in iconsDir.list(recursive: true)) {
|
||||||
|
if (entity is File && entity.path.endsWith('.svg')) {
|
||||||
|
svgFiles.add(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Error while scanning directory: $e');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (svgFiles.isEmpty) {
|
||||||
|
print('No SVG files found in assets/icons.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
print('Found ${svgFiles.length} SVG file(s) to convert.');
|
||||||
|
|
||||||
|
var compiledCount = 0;
|
||||||
|
var failedCount = 0;
|
||||||
|
|
||||||
|
for (final svgFile in svgFiles) {
|
||||||
|
final inputPath = svgFile.path;
|
||||||
|
final outputPath = '$inputPath.vec';
|
||||||
|
|
||||||
|
print('Compiling: $inputPath -> $outputPath');
|
||||||
|
|
||||||
|
// Run the vector_graphics_compiler tool
|
||||||
|
final result = await Process.run('dart', [
|
||||||
|
'run',
|
||||||
|
'vector_graphics_compiler',
|
||||||
|
'-i',
|
||||||
|
inputPath,
|
||||||
|
'-o',
|
||||||
|
outputPath,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (result.exitCode == 0) {
|
||||||
|
print(' [Success] Compiled $outputPath');
|
||||||
|
compiledCount++;
|
||||||
|
} else {
|
||||||
|
print(
|
||||||
|
' [Error] Failed to compile $inputPath (Exit Code: ${result.exitCode})',
|
||||||
|
);
|
||||||
|
if (result.stdout.toString().isNotEmpty) {
|
||||||
|
print(' stdout: ${result.stdout}');
|
||||||
|
}
|
||||||
|
if (result.stderr.toString().isNotEmpty) {
|
||||||
|
print(' stderr: ${result.stderr}');
|
||||||
|
}
|
||||||
|
failedCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print('\n----------------------------------------');
|
||||||
|
print('Summary:');
|
||||||
|
print(' Successfully compiled: $compiledCount');
|
||||||
|
print(' Failed compilation: $failedCount');
|
||||||
|
print('----------------------------------------');
|
||||||
|
|
||||||
|
if (failedCount > 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue