191 lines
4.8 KiB
Dart
191 lines
4.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
part 'product_theme.g.dart';
|
|
|
|
/// 产品类型枚举
|
|
enum ProductType {
|
|
/// 公共页面(登录、配网等)
|
|
common,
|
|
|
|
/// 毛绒机芯
|
|
capybara,
|
|
|
|
/// 电子吧唧 AI
|
|
badgeAi,
|
|
|
|
/// 普通吧唧
|
|
badgeBasic,
|
|
}
|
|
|
|
/// 每个产品类型对应的主题配色
|
|
class ProductThemeData {
|
|
/// 按钮渐变
|
|
final LinearGradient buttonGradient;
|
|
|
|
/// 强调色(用于图标、文字高亮、进度条、选中态等)
|
|
final Color accentColor;
|
|
|
|
/// 次强调色(用于阴影、选中背景等)
|
|
final Color accentColorLight;
|
|
|
|
/// 按钮阴影
|
|
final List<BoxShadow> buttonShadows;
|
|
|
|
const ProductThemeData({
|
|
required this.buttonGradient,
|
|
required this.accentColor,
|
|
required this.accentColorLight,
|
|
required this.buttonShadows,
|
|
});
|
|
}
|
|
|
|
/// 各产品的主题定义
|
|
class ProductThemes {
|
|
ProductThemes._();
|
|
|
|
/// 公共/默认 — 蓝色色调 (cyan → blue → indigo → purple)
|
|
static final common = ProductThemeData(
|
|
buttonGradient: const LinearGradient(
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
colors: [
|
|
Color(0xFF22D3EE),
|
|
Color(0xFF3B82F6),
|
|
Color(0xFF6366F1),
|
|
Color(0xFF8B5CF6),
|
|
],
|
|
stops: [0.0, 0.35, 0.65, 1.0],
|
|
),
|
|
accentColor: const Color(0xFF6366F1),
|
|
accentColorLight: const Color(0xFF8B5CF6),
|
|
buttonShadows: [
|
|
BoxShadow(
|
|
color: const Color(0xFF6366F1).withOpacity(0.4),
|
|
offset: const Offset(0, 4),
|
|
blurRadius: 20,
|
|
),
|
|
BoxShadow(
|
|
color: const Color(0xFF8B5CF6).withOpacity(0.2),
|
|
offset: Offset.zero,
|
|
blurRadius: 40,
|
|
),
|
|
],
|
|
);
|
|
|
|
/// 毛绒机芯 — 金色/暖棕色
|
|
static final capybara = ProductThemeData(
|
|
buttonGradient: const LinearGradient(
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
colors: [Color(0xFFECCFA8), Color(0xFFC99672)],
|
|
),
|
|
accentColor: const Color(0xFFC99672),
|
|
accentColorLight: const Color(0xFFECCFA8),
|
|
buttonShadows: [
|
|
BoxShadow(
|
|
color: const Color(0xFFC99672).withOpacity(0.35),
|
|
offset: Offset.zero,
|
|
blurRadius: 15,
|
|
),
|
|
BoxShadow(
|
|
color: const Color(0xFFC99672).withOpacity(0.25),
|
|
offset: Offset.zero,
|
|
blurRadius: 30,
|
|
),
|
|
BoxShadow(
|
|
color: const Color(0xFFC99672).withOpacity(0.4),
|
|
offset: const Offset(0, 6),
|
|
blurRadius: 20,
|
|
),
|
|
],
|
|
);
|
|
|
|
/// 电子吧唧 AI — 蓝渐变紫(与产品卡片一致)
|
|
static final badgeAi = ProductThemeData(
|
|
buttonGradient: const LinearGradient(
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
colors: [
|
|
Color(0xFF22D3EE),
|
|
Color(0xFF60A5FA),
|
|
Color(0xFF818CF8),
|
|
Color(0xFFA78BFA),
|
|
],
|
|
stops: [0.0, 0.35, 0.70, 1.0],
|
|
),
|
|
accentColor: const Color(0xFF818CF8),
|
|
accentColorLight: const Color(0xFFA78BFA),
|
|
buttonShadows: [
|
|
BoxShadow(
|
|
color: const Color(0xFF818CF8).withOpacity(0.4),
|
|
offset: const Offset(0, 4),
|
|
blurRadius: 20,
|
|
),
|
|
BoxShadow(
|
|
color: const Color(0xFFA78BFA).withOpacity(0.2),
|
|
offset: Offset.zero,
|
|
blurRadius: 40,
|
|
),
|
|
],
|
|
);
|
|
|
|
/// 普通吧唧 — 粉渐变紫(与产品卡片一致)
|
|
static final badgeBasic = ProductThemeData(
|
|
buttonGradient: const LinearGradient(
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
colors: [
|
|
Color(0xFFC084FC),
|
|
Color(0xFFD8B4FE),
|
|
Color(0xFFC4B5FD),
|
|
Color(0xFFA78BFA),
|
|
],
|
|
stops: [0.0, 0.35, 0.70, 1.0],
|
|
),
|
|
accentColor: const Color(0xFFC084FC),
|
|
accentColorLight: const Color(0xFFD8B4FE),
|
|
buttonShadows: [
|
|
BoxShadow(
|
|
color: const Color(0xFFC084FC).withOpacity(0.4),
|
|
offset: const Offset(0, 4),
|
|
blurRadius: 20,
|
|
),
|
|
BoxShadow(
|
|
color: const Color(0xFFA78BFA).withOpacity(0.2),
|
|
offset: Offset.zero,
|
|
blurRadius: 40,
|
|
),
|
|
],
|
|
);
|
|
|
|
/// 根据产品类型获取主题
|
|
static ProductThemeData of(ProductType type) {
|
|
switch (type) {
|
|
case ProductType.common:
|
|
return common;
|
|
case ProductType.capybara:
|
|
return capybara;
|
|
case ProductType.badgeAi:
|
|
return badgeAi;
|
|
case ProductType.badgeBasic:
|
|
return badgeBasic;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// 全局当前产品类型 Notifier
|
|
@Riverpod(keepAlive: true)
|
|
class CurrentProductType extends _$CurrentProductType {
|
|
@override
|
|
ProductType build() => ProductType.common;
|
|
|
|
void set(ProductType type) => state = type;
|
|
}
|
|
|
|
/// 当前产品主题(派生自产品类型)
|
|
@riverpod
|
|
ProductThemeData currentProductTheme(Ref ref) {
|
|
return ProductThemes.of(ref.watch(currentProductTypeProvider));
|
|
}
|