opt: enum

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-05 15:06:19 +08:00
parent 4e68c765c5
commit 2f4c739f0b
116 changed files with 577 additions and 554 deletions

View File

@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
const List<Map<String, dynamic>> colorThemeTypes = [
{'color': Color(0xFF5CB67B), 'label': '默认绿'},
{'color': Color(0xFFFF7299), 'label': '粉红色'},
{'color': Colors.red, 'label': '红色'},
{'color': Colors.orange, 'label': '橙色'},
{'color': Colors.amber, 'label': '琥珀色'},
{'color': Colors.yellow, 'label': '黄色'},
{'color': Colors.lime, 'label': '酸橙色'},
{'color': Colors.lightGreen, 'label': '浅绿色'},
{'color': Colors.green, 'label': '绿色'},
{'color': Colors.teal, 'label': '青色'},
{'color': Colors.cyan, 'label': '蓝绿色'},
{'color': Colors.lightBlue, 'label': '浅蓝色'},
{'color': Colors.blue, 'label': '蓝色'},
{'color': Colors.indigo, 'label': '靛蓝色'},
{'color': Colors.purple, 'label': '紫色'},
{'color': Colors.deepPurple, 'label': '深紫色'},
{'color': Colors.blueGrey, 'label': '蓝灰色'},
{'color': Colors.brown, 'label': '棕色'},
{'color': Colors.grey, 'label': '灰色'},
];

View File

@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
enum ThemeType {
light,
dark,
system,
}
extension ThemeTypeExt on ThemeType {
String get description => const ['浅色', '深色', '跟随系统'][index];
int get code => index;
ThemeMode get toThemeMode => switch (this) {
ThemeType.light => ThemeMode.light,
ThemeType.dark => ThemeMode.dark,
ThemeType.system => ThemeMode.system,
};
IconData get iconData => switch (this) {
ThemeType.light => MdiIcons.weatherSunny,
ThemeType.dark => MdiIcons.weatherNight,
ThemeType.system => MdiIcons.themeLightDark,
};
}