diff --git a/flutter_monisuo/assets/icons/crypto/ada.svg b/flutter_monisuo/assets/icons/crypto/ada.svg
new file mode 100644
index 0000000..d558f0d
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/ada.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/atom.svg b/flutter_monisuo/assets/icons/crypto/atom.svg
new file mode 100644
index 0000000..f957f2c
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/atom.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/avax.svg b/flutter_monisuo/assets/icons/crypto/avax.svg
new file mode 100644
index 0000000..7bd97ad
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/avax.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/bnb.svg b/flutter_monisuo/assets/icons/crypto/bnb.svg
new file mode 100644
index 0000000..1a859f6
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/bnb.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/btc.svg b/flutter_monisuo/assets/icons/crypto/btc.svg
new file mode 100644
index 0000000..5dc8a39
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/btc.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/doge.svg b/flutter_monisuo/assets/icons/crypto/doge.svg
new file mode 100644
index 0000000..c22bf09
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/doge.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/dot.svg b/flutter_monisuo/assets/icons/crypto/dot.svg
new file mode 100644
index 0000000..7751a9c
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/dot.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/eth.svg b/flutter_monisuo/assets/icons/crypto/eth.svg
new file mode 100644
index 0000000..c761cef
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/eth.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/link.svg b/flutter_monisuo/assets/icons/crypto/link.svg
new file mode 100644
index 0000000..f7e000a
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/link.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/ltc.svg b/flutter_monisuo/assets/icons/crypto/ltc.svg
new file mode 100644
index 0000000..9afc706
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/ltc.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/matic.svg b/flutter_monisuo/assets/icons/crypto/matic.svg
new file mode 100644
index 0000000..31361b8
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/matic.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/shib.svg b/flutter_monisuo/assets/icons/crypto/shib.svg
new file mode 100644
index 0000000..729763d
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/shib.svg
@@ -0,0 +1 @@
+Couldn't find the requested file /svg/color/shib.svg in spothq/cryptocurrency-icons.
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/sol.svg b/flutter_monisuo/assets/icons/crypto/sol.svg
new file mode 100644
index 0000000..ce27130
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/sol.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/uni.svg b/flutter_monisuo/assets/icons/crypto/uni.svg
new file mode 100644
index 0000000..741735b
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/uni.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/usdt.svg b/flutter_monisuo/assets/icons/crypto/usdt.svg
new file mode 100644
index 0000000..38c491c
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/usdt.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/assets/icons/crypto/xrp.svg b/flutter_monisuo/assets/icons/crypto/xrp.svg
new file mode 100644
index 0000000..250cbfa
--- /dev/null
+++ b/flutter_monisuo/assets/icons/crypto/xrp.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/flutter_monisuo/lib/ui/components/coin_icon.dart b/flutter_monisuo/lib/ui/components/coin_icon.dart
index dab3dce..1939de1 100644
--- a/flutter_monisuo/lib/ui/components/coin_icon.dart
+++ b/flutter_monisuo/lib/ui/components/coin_icon.dart
@@ -1,105 +1,101 @@
import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
/// 数字货币图标组件
-///
-/// 支持离线图标和兜底显示
+///
+/// 支持离线 SVG 图标和兜底显示
class CoinIcon extends StatelessWidget {
- final String symbol; // 币种代码,如 'BTC', 'ETH'
- final double size; // 图标大小,默认 40
- final bool isCircle; // 是否圆形背景,默认 false
-
- const CoinIcon({
- super.key,
- required this.symbol,
- this.size = 40,
- this.isCircle = false,
- });
-
- // 币种代码到文件名的映射
- static const Map _coinFileMap = {
- 'BTC': 'btc',
- 'ETH': 'eth',
- 'USDT': 'usdt',
- 'BNB': 'bnb',
- 'SOL': 'sol',
- 'XRP': 'xrp',
- 'ADA': 'ada',
- 'DOGE': 'doge',
- 'DOT': 'dot',
- 'MATIC': 'matic',
- 'SHIB': 'shib',
- 'LTC': 'ltc',
- 'AVAX': 'avax',
- 'LINK': 'link',
- 'UNI': 'uni',
- 'ATOM': 'atom',
- };
-
- @override
- Widget build(BuildContext context) {
- final normalizedSymbol = symbol.toUpperCase();
- final fileName = _coinFileMap[normalizedSymbol];
-
- Widget icon;
-
- if (fileName != null) {
- // 尝试加载本地图标
- icon = Image.asset(
- 'assets/icons/crypto/$fileName.png',
- width: size,
- height: size,
- fit: BoxFit.contain,
- errorBuilder: (context, error, stackTrace) {
- // 加载失败,显示兜底UI
- return _buildFallback(context, normalizedSymbol);
- },
- );
- } else {
- // 没有对应的图标,显示兜底UI
- icon = _buildFallback(context, normalizedSymbol);
- }
-
- if (isCircle) {
- return Container(
- width: size,
- height: size,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: Theme.of(context).colorScheme.surfaceContainerHigh,
- ),
- child: Center(child: icon),
- );
- }
-
- return icon;
+ final String symbol; // 币种代码,如 'BTC', 'ETH'
+ final double size; // 图标大小,默认 40
+ final bool isCircle; // 是否圆形背景,默认 false
+
+ const CoinIcon({
+ super.key,
+ required this.symbol,
+ this.size = 40,
+ this.isCircle = false,
+ });
+
+ // 币种代码到文件名的映射
+ static const Map _coinFileMap = {
+ 'BTC': 'btc',
+ 'ETH': 'eth',
+ 'USDT': 'usdt',
+ 'BNB': 'bnb',
+ 'SOL': 'sol',
+ 'XRP': 'xrp',
+ 'ADA': 'ada',
+ 'DOGE': 'doge',
+ 'DOT': 'dot',
+ 'MATIC': 'matic',
+ 'SHIB': 'shib',
+ 'LTC': 'ltc',
+ 'AVAX': 'avax',
+ 'LINK': 'link',
+ 'UNI': 'uni',
+ 'ATOM': 'atom',
+ };
+
+ @override
+ Widget build(BuildContext context) {
+ final normalizedSymbol = symbol.toUpperCase();
+ final fileName = _coinFileMap[normalizedSymbol];
+
+ Widget icon;
+
+ if (fileName != null) {
+ icon = SvgPicture.asset(
+ 'assets/icons/crypto/$fileName.svg',
+ width: size,
+ height: size,
+ fit: BoxFit.contain,
+ placeholderBuilder: (context) => _buildFallback(context, normalizedSymbol),
+ );
+ } else {
+ icon = _buildFallback(context, normalizedSymbol);
}
-
- /// 构建兜底UI(显示币种代码)
- Widget _buildFallback(BuildContext context, String symbol) {
- return Container(
- width: size,
- height: size,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- gradient: LinearGradient(
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- colors: [
- Theme.of(context).colorScheme.primary,
- Theme.of(context).colorScheme.secondary,
- ],
- ),
- ),
- child: Center(
- child: Text(
- symbol.length > 3 ? symbol.substring(0, 3) : symbol,
- style: TextStyle(
- color: Colors.white,
- fontSize: size * 0.35,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- );
+
+ if (isCircle) {
+ return Container(
+ width: size,
+ height: size,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: Theme.of(context).colorScheme.surfaceContainerHigh,
+ ),
+ child: Center(child: icon),
+ );
}
+
+ return icon;
+ }
+
+ /// 构建兜底UI(显示币种代码)
+ Widget _buildFallback(BuildContext context, String symbol) {
+ return Container(
+ width: size,
+ height: size,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ gradient: LinearGradient(
+ begin: Alignment.topLeft,
+ end: Alignment.bottomRight,
+ colors: [
+ Theme.of(context).colorScheme.primary,
+ Theme.of(context).colorScheme.secondary,
+ ],
+ ),
+ ),
+ child: Center(
+ child: Text(
+ symbol.length > 3 ? symbol.substring(0, 3) : symbol,
+ style: TextStyle(
+ color: Colors.white,
+ fontSize: size * 0.35,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ ),
+ );
+ }
}
diff --git a/flutter_monisuo/pubspec.lock b/flutter_monisuo/pubspec.lock
index cec02a0..f4ccb95 100644
--- a/flutter_monisuo/pubspec.lock
+++ b/flutter_monisuo/pubspec.lock
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
+ args:
+ dependency: transitive
+ description:
+ name: args
+ sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.7.0"
async:
dependency: transitive
description:
@@ -203,6 +211,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.3"
+ flutter_svg:
+ dependency: "direct main"
+ description:
+ name: flutter_svg
+ sha256: "1ded017b39c8e15c8948ea855070a5ff8ff8b3d5e83f3446e02d6bb12add7ad9"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.2.4"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -437,6 +453,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
+ path_parsing:
+ dependency: transitive
+ description:
+ name: path_parsing
+ sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.0"
path_provider:
dependency: transitive
description:
@@ -485,6 +509,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.0"
+ petitparser:
+ dependency: transitive
+ description:
+ name: petitparser
+ sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675"
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.0.2"
platform:
dependency: transitive
description:
@@ -642,6 +674,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
+ vector_graphics:
+ dependency: transitive
+ description:
+ name: vector_graphics
+ sha256: "81da85e9ca8885ade47f9685b953cb098970d11be4821ac765580a6607ea4373"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.21"
+ vector_graphics_codec:
+ dependency: transitive
+ description:
+ name: vector_graphics_codec
+ sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.13"
+ vector_graphics_compiler:
+ dependency: transitive
+ description:
+ name: vector_graphics_compiler
+ sha256: "5a88dd14c0954a5398af544651c7fb51b457a2a556949bfb25369b210ef73a74"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.2.0"
vector_math:
dependency: transitive
description:
@@ -674,6 +730,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.0"
+ xml:
+ dependency: transitive
+ description:
+ name: xml
+ sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.6.1"
yaml:
dependency: transitive
description:
diff --git a/flutter_monisuo/pubspec.yaml b/flutter_monisuo/pubspec.yaml
index 53df0cb..77bc0e3 100644
--- a/flutter_monisuo/pubspec.yaml
+++ b/flutter_monisuo/pubspec.yaml
@@ -37,6 +37,9 @@ dependencies:
# Toast 提示
bot_toast: ^4.1.3
+ # SVG 支持
+ flutter_svg: ^2.0.10+1
+
# K 线图
flutter_chen_kchart: ^1.0.0