mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt color select
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -129,7 +129,7 @@ class MyApp extends StatelessWidget {
|
||||
// 主题色
|
||||
Color defaultColor =
|
||||
colorThemeTypes[setting.get(SettingBoxKey.customColor, defaultValue: 0)]
|
||||
['color'];
|
||||
.color;
|
||||
Color brandColor = defaultColor;
|
||||
// 是否动态取色
|
||||
bool isDynamicColor =
|
||||
|
||||
@@ -1,23 +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': '灰色'},
|
||||
const List<({Color color, String label})> 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: '灰色'),
|
||||
];
|
||||
|
||||
@@ -104,9 +104,7 @@ class _HomePageState extends State<HomePage>
|
||||
_homeController.showUserInfoDialog(context),
|
||||
splashColor: theme.colorScheme.primaryContainer
|
||||
.withValues(alpha: 0.3),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(50),
|
||||
),
|
||||
customBorder: const CircleBorder(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -415,9 +415,7 @@ class _MainAppState extends State<MainApp>
|
||||
_homeController.showUserInfoDialog(context),
|
||||
splashColor: theme.colorScheme.primaryContainer
|
||||
.withValues(alpha: 0.3),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(50),
|
||||
),
|
||||
customBorder: const CircleBorder(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -186,62 +186,59 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 22,
|
||||
runSpacing: 18,
|
||||
children: [
|
||||
...ctr.colorThemes.map(
|
||||
(e) {
|
||||
final index = ctr.colorThemes.indexOf(e);
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
ctr.currentColor.value = index;
|
||||
ctr.setting
|
||||
.put(SettingBoxKey.customColor, index);
|
||||
Get.forceAppUpdate();
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 46,
|
||||
height: 46,
|
||||
decoration: BoxDecoration(
|
||||
color: e['color'].withValues(alpha: 0.8),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(50)),
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: ctr.currentColor.value == index
|
||||
? Colors.black
|
||||
: e['color'].withValues(alpha: 0.8),
|
||||
),
|
||||
),
|
||||
child: AnimatedOpacity(
|
||||
opacity: ctr.currentColor.value == index
|
||||
? 1
|
||||
: 0,
|
||||
duration:
|
||||
const Duration(milliseconds: 200),
|
||||
child: const Icon(
|
||||
Icons.done,
|
||||
color: Colors.black,
|
||||
size: 20,
|
||||
),
|
||||
children: colorThemeTypes.indexed.map(
|
||||
(e) {
|
||||
final index = e.$1;
|
||||
final item = e.$2;
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
ctr
|
||||
..currentColor.value = index
|
||||
..setting.put(SettingBoxKey.customColor, index);
|
||||
Get.forceAppUpdate();
|
||||
},
|
||||
child: Column(
|
||||
spacing: 3,
|
||||
children: [
|
||||
Container(
|
||||
width: 46,
|
||||
height: 46,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: item.color.withValues(alpha: 0.8),
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: ctr.currentColor.value == index
|
||||
? Colors.black
|
||||
: item.color.withValues(alpha: 0.8),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
e['label'],
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: ctr.currentColor.value != index
|
||||
? theme.colorScheme.outline
|
||||
: null,
|
||||
child: AnimatedOpacity(
|
||||
opacity:
|
||||
ctr.currentColor.value == index ? 1 : 0,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: const Icon(
|
||||
Icons.done,
|
||||
color: Colors.black,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
Text(
|
||||
item.label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: ctr.currentColor.value != index
|
||||
? theme.colorScheme.outline
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -249,9 +246,10 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
),
|
||||
...[
|
||||
IgnorePointer(
|
||||
child: SizedBox(
|
||||
child: Container(
|
||||
height: Get.height / 2,
|
||||
width: Get.width,
|
||||
color: theme.colorScheme.surface,
|
||||
child: const HomePage(),
|
||||
),
|
||||
),
|
||||
@@ -278,7 +276,6 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
class ColorSelectController extends GetxController {
|
||||
RxBool dynamicColor = true.obs;
|
||||
RxInt type = 0.obs;
|
||||
late final List<Map<String, dynamic>> colorThemes = colorThemeTypes;
|
||||
RxInt currentColor = 0.obs;
|
||||
RxDouble currentTextScale = 1.0.obs;
|
||||
Rx<ThemeType> themeType = GStorage.themeType.obs;
|
||||
|
||||
Reference in New Issue
Block a user