mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-06-25 00:24: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/src/localization/**"
|
||||
- "rust_builder/"
|
||||
- "scripts/"
|
||||
- "build/"
|
||||
- "dependencies/**"
|
||||
- "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_svg/flutter_svg.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.
|
||||
///
|
||||
|
|
@ -338,8 +339,10 @@ class VerificationSuccessAnimationState
|
|||
child: SizedBox(
|
||||
width: widget.size * 0.5,
|
||||
height: widget.size * 0.5,
|
||||
child: SvgPicture.asset(
|
||||
'assets/icons/verified_badge_green.svg',
|
||||
child: const SvgPicture(
|
||||
AssetBytesLoader(
|
||||
'assets/icons/verified_badge_green.svg.vec',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:vector_graphics/vector_graphics.dart';
|
||||
|
||||
class SvgIcons {
|
||||
static const String verifiedGreen = 'assets/icons/verified_badge_green.svg';
|
||||
static const String verifiedRed = 'assets/icons/verified_badge_red.svg';
|
||||
static const String verifiedGreen =
|
||||
'assets/icons/verified_badge_green.svg.vec';
|
||||
static const String verifiedRed = 'assets/icons/verified_badge_red.svg.vec';
|
||||
|
||||
static String verifiedNumeric(int value) {
|
||||
if (value >= 4) {
|
||||
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
|
||||
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(
|
||||
assetPath,
|
||||
width: size,
|
||||
height: size,
|
||||
colorFilter: color != null
|
||||
? ColorFilter.mode(color!, BlendMode.srcIn)
|
||||
: null,
|
||||
colorFilter: filter,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2047,7 +2047,7 @@ packages:
|
|||
source: hosted
|
||||
version: "1.1.13"
|
||||
vector_graphics_compiler:
|
||||
dependency: transitive
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: vector_graphics_compiler
|
||||
sha256: "5a88dd14c0954a5398af544651c7fb51b457a2a556949bfb25369b210ef73a74"
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ dev_dependencies:
|
|||
drift_dev: ^2.25.2
|
||||
flutter_launcher_icons: ^0.14.1
|
||||
flutter_lints: ^6.0.0
|
||||
vector_graphics_compiler: ^1.2.0
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
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