Files
jizhi/frontend/lib/shared/widgets/app_icons.dart
T
2026-07-24 23:11:20 +08:00

184 lines
6.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
class CategoryIconMeta {
final String key;
final String label;
final String group;
const CategoryIconMeta(this.key, this.label, this.group);
}
/// 全套自绘 SVG 图标(来自 design/ui-mockup.html v0.5
/// 使用方式:AppIcons.cat → SvgPicture.asset(AppIcons.cat, colorFilter: ..., width: 24)
class AppIcons {
AppIcons._();
static const _p = 'assets/icons/';
// AI 形象
static const cat = '${_p}i-cat.svg';
static const dog = '${_p}i-dog.svg';
static const robot = '${_p}i-robot.svg';
// 底部导航
static const home = '${_p}i-home.svg';
static const chart = '${_p}i-chart.svg';
static const chat = '${_p}i-chat.svg';
static const user = '${_p}i-user.svg';
static const plus = '${_p}i-plus.svg';
// 分类图标
static const food = '${_p}i-food.svg';
static const cup = '${_p}i-cup.svg';
static const cart = '${_p}i-cart.svg';
static const metro = '${_p}i-metro.svg';
static const house = '${_p}i-house.svg';
static const game = '${_p}i-game.svg';
static const pill = '${_p}i-pill.svg';
static const book = '${_p}i-book.svg';
static const shirt = '${_p}i-shirt.svg';
static const gift = '${_p}i-gift.svg';
static const plane = '${_p}i-plane.svg';
static const money = '${_p}i-money.svg';
static const tag = '${_p}i-tag.svg';
// 扩展
static const wallet = '${_p}i-wallet.svg';
static const target = '${_p}i-target.svg';
static const sparkle = '${_p}i-sparkle.svg';
static const briefcase = '${_p}i-briefcase.svg';
static const cardIcon = '${_p}i-card.svg';
static const search = '${_p}i-search.svg';
static const bell = '${_p}i-bell.svg';
static const eye = '${_p}i-eye.svg';
static const gear = '${_p}i-gear.svg';
static const mic = '${_p}i-mic.svg';
static const smile = '${_p}i-smile.svg';
static const camera = '${_p}i-camera.svg';
static const fire = '${_p}i-fire.svg';
static const chevronDown = '${_p}i-chev-d.svg';
static const chevronRight = '${_p}i-chev-r.svg';
static const close = '${_p}i-close.svg';
static const check = '${_p}i-check.svg';
static const exportIcon = '${_p}i-export.svg';
static const cloud = '${_p}i-cloud.svg';
static const swap = '${_p}i-swap.svg';
static const receipt = '${_p}i-receipt.svg';
static const edit = '${_p}i-edit.svg';
static const trash = '${_p}i-trash.svg';
static const drag = '${_p}i-drag.svg';
static const offline = '${_p}i-offline.svg';
static const wave = '${_p}i-wave.svg';
static const scan = '${_p}i-scan.svg';
// 扩展分类图标
static const car = '${_p}i-car.svg';
static const baby = '${_p}i-baby.svg';
static const pet = '${_p}i-pet.svg';
static const phone = '${_p}i-phone.svg';
static const wifi = '${_p}i-wifi.svg';
static const sport = '${_p}i-sport.svg';
static const beauty = '${_p}i-beauty.svg';
static const insurance = '${_p}i-shield.svg';
static const tax = '${_p}i-tax.svg';
static const rent = '${_p}i-rent.svg';
static const refund = '${_p}i-refund.svg';
static const interest = '${_p}i-interest.svg';
// 映射 iconKey → asset path
static const keyMap = <String, String>{
'food': food,
'cup': cup,
'cart': cart,
'metro': metro,
'house': house,
'game': game,
'pill': pill,
'book': book,
'shirt': shirt,
'gift': gift,
'plane': plane,
'tag': tag,
'money': money,
'briefcase': briefcase,
'chart': chart,
'card': cardIcon,
'sparkle': sparkle,
'wallet': wallet,
'cat': cat,
'dog': dog,
'robot': robot,
'target': target,
'camera': camera,
'receipt': receipt,
'car': car,
'baby': baby,
'pet': pet,
'phone': phone,
'wifi': wifi,
'sport': sport,
'beauty': beauty,
'insurance': insurance,
'tax': tax,
'rent': rent,
'refund': refund,
'interest': interest,
};
static const categoryCatalog = <CategoryIconMeta>[
CategoryIconMeta('food', '餐饮', '日常生活'),
CategoryIconMeta('cup', '饮品', '日常生活'),
CategoryIconMeta('cart', '购物', '日常生活'),
CategoryIconMeta('house', '住房', '日常生活'),
CategoryIconMeta('rent', '房租', '日常生活'),
CategoryIconMeta('metro', '公交地铁', '交通出行'),
CategoryIconMeta('car', '汽车', '交通出行'),
CategoryIconMeta('plane', '旅行', '交通出行'),
CategoryIconMeta('phone', '手机数码', '日常生活'),
CategoryIconMeta('wifi', '网络通信', '日常生活'),
CategoryIconMeta('shirt', '服饰', '日常生活'),
CategoryIconMeta('beauty', '美容', '日常生活'),
CategoryIconMeta('pill', '医疗', '健康成长'),
CategoryIconMeta('sport', '运动', '健康成长'),
CategoryIconMeta('book', '学习', '健康成长'),
CategoryIconMeta('baby', '育儿', '健康成长'),
CategoryIconMeta('pet', '宠物', '健康成长'),
CategoryIconMeta('game', '娱乐', '休闲人情'),
CategoryIconMeta('gift', '礼物人情', '休闲人情'),
CategoryIconMeta('wallet', '钱包', '资金收入'),
CategoryIconMeta('money', '工资', '资金收入'),
CategoryIconMeta('briefcase', '工作兼职', '资金收入'),
CategoryIconMeta('chart', '投资理财', '资金收入'),
CategoryIconMeta('interest', '利息收益', '资金收入'),
CategoryIconMeta('refund', '退款', '资金收入'),
CategoryIconMeta('card', '银行卡', '资金收入'),
CategoryIconMeta('insurance', '保险', '资金收入'),
CategoryIconMeta('tax', '税费', '资金收入'),
CategoryIconMeta('receipt', '票据账单', '其他'),
CategoryIconMeta('camera', '摄影', '其他'),
CategoryIconMeta('target', '目标', '其他'),
CategoryIconMeta('sparkle', '奖励', '其他'),
CategoryIconMeta('tag', '其他', '其他'),
];
static String avatarAsset(String key) => keyMap[key] ?? cat;
/// 返回 SvgPicture widget
static Widget icon(String asset, {double size = 24, Color? color}) {
return SvgPicture.asset(
asset,
width: size,
height: size,
colorFilter: color != null
? ColorFilter.mode(color, BlendMode.srcIn)
: null,
);
}
/// 按 iconKey 返回 SvgPicture
static Widget byKey(String key, {double size = 24, Color? color}) {
return icon(keyMap[key] ?? tag, size: size, color: color);
}
}