145 lines
4.2 KiB
Dart
145 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:jydj/assets_tool/images.dart';
|
|
|
|
final holidayTheme = HolidayTheme._();
|
|
|
|
class HolidayTheme {
|
|
HolidayTheme._();
|
|
|
|
/// 节假日 → (主题编号, 桌面图标 index);春节不换图标,icon 为 0
|
|
static const Map<String, ({int theme, int icon})> _festivalMap = {
|
|
'默认': (theme: 1, icon: 0),
|
|
'清明节': (theme: 2, icon: 16),
|
|
'端午节': (theme: 3, icon: 17),
|
|
'劳动节': (theme: 4, icon: 18),
|
|
'春节': (theme: 5, icon: 0),
|
|
};
|
|
|
|
int themeValue = 1;
|
|
int iconIndex = 0;
|
|
final HolidayThemeModel _model = HolidayThemeModel();
|
|
|
|
static HolidayThemeModel get theme => holidayTheme._model;
|
|
|
|
/// 是否打开节假日
|
|
bool get openHoliday => themeValue > 1;
|
|
|
|
void setThemeValue(String festival) {
|
|
final cfg = _festivalMap[festival] ?? const (theme: 1, icon: 0);
|
|
themeValue = cfg.theme;
|
|
iconIndex = cfg.icon;
|
|
final m = _model;
|
|
m.current = themeValue;
|
|
|
|
m.appIcon = _p('ic_launcher.webp');
|
|
m.searchBgImg = _p('search_bg.webp');
|
|
m.addPublish = _p('publish.png');
|
|
m.vipBg = _p('mine_vip_bg.webp');
|
|
m.coin = _p('mine_gold_enter.webp');
|
|
m.agent = _p('mine_agent_enter.webp');
|
|
m.vipEnter = _p('mine_vip_enter.webp');
|
|
m.aiEnter = _p('mine_ai_enter.webp');
|
|
|
|
m.homeNor = _p('home_0_0.png');
|
|
m.homeSel = _p('home_0_1.png');
|
|
m.shortNor = _p('home_1_0.png');
|
|
m.shortSel = _p('home_1_1.png');
|
|
m.darkNor = _p('home_2_0.png');
|
|
m.darkSel = _p('home_2_1.png');
|
|
m.aiNor = _p('home_3_0.png');
|
|
m.aiSel = _p('home_3_1.png');
|
|
m.communityNor = _p('home_4_0.png');
|
|
m.communitySel = _p('home_4_1.png');
|
|
m.mineNor = _p('home_5_0.png');
|
|
m.mineSel = _p('home_5_1.png');
|
|
|
|
// 默认三块背景都用 main_bg,仅 case 3/5 单独覆盖
|
|
final mainBg = _p('main_bg.webp');
|
|
m.mainBg = mainBg;
|
|
m.findBg = mainBg;
|
|
m.mineBg = mainBg;
|
|
|
|
// 节日特有图标默认清空,避免切换主题后残留
|
|
m.signIcon = '';
|
|
m.broadcastIcon = '';
|
|
|
|
switch (themeValue) {
|
|
case 1:
|
|
m.tabSelColor = const Color(0xffFFC000);
|
|
m.tabNorColor = const Color(0x59FFFFFF);
|
|
m.searchBgColor = Colors.black.withValues(alpha: 0.08);
|
|
m.searchTxColor = const Color(0xff999999);
|
|
break;
|
|
case 2:
|
|
m.tabSelColor = const Color(0xff00BBB8);
|
|
m.tabNorColor = const Color(0xff5D6573);
|
|
m.searchBgColor = const Color(0xff41D0AB);
|
|
m.searchTxColor = Colors.white;
|
|
break;
|
|
case 3:
|
|
m.tabSelColor = const Color(0xff07738D);
|
|
m.tabNorColor = const Color(0xff5D6573);
|
|
m.searchBgColor = const Color(0xff8EC58E);
|
|
m.searchTxColor = Colors.white;
|
|
m.findBg = _p('find_bg.webp');
|
|
m.mineBg = _p('mine_bg.webp');
|
|
break;
|
|
case 4:
|
|
m.tabSelColor = const Color(0xffBE0209);
|
|
m.tabNorColor = const Color(0xff6C6C6C);
|
|
m.searchBgColor = const Color(0xffD7221D);
|
|
m.searchTxColor = Colors.white;
|
|
break;
|
|
case 5:
|
|
m.tabSelColor = const Color(0xffFFC000);
|
|
m.tabNorColor = const Color(0xff989898);
|
|
m.searchBgColor = Colors.black.withValues(alpha: 0.08);
|
|
m.searchTxColor = Colors.white;
|
|
m.mineBg = _p('mine_bg.webp');
|
|
m.signIcon = _p('sign_icon.png');
|
|
m.broadcastIcon = _p('icon_broadcast.png');
|
|
break;
|
|
}
|
|
}
|
|
|
|
String _p(String name) => '$themeValue/$name'.holidayPath;
|
|
}
|
|
|
|
class HolidayThemeModel {
|
|
int current = 1;
|
|
|
|
String appIcon = '';
|
|
String searchBgImg = '';
|
|
String addPublish = '';
|
|
String vipBg = '';
|
|
String coin = '';
|
|
String agent = '';
|
|
String vipEnter = '';
|
|
String aiEnter = '';
|
|
|
|
String homeNor = '';
|
|
String homeSel = '';
|
|
String shortNor = '';
|
|
String shortSel = '';
|
|
String darkNor = '';
|
|
String darkSel = '';
|
|
String aiNor = '';
|
|
String aiSel = '';
|
|
String communityNor = '';
|
|
String communitySel = '';
|
|
String mineNor = '';
|
|
String mineSel = '';
|
|
|
|
String mainBg = '';
|
|
String findBg = '';
|
|
String mineBg = '';
|
|
|
|
String signIcon = '';
|
|
String broadcastIcon = '';
|
|
|
|
Color tabNorColor = const Color(0x59FFFFFF);
|
|
Color tabSelColor = const Color(0xffFFC000);
|
|
Color searchBgColor = Colors.black;
|
|
Color searchTxColor = const Color(0xff999999);
|
|
}
|