Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

feat: color palette for theme picker

ErBW_s727b9091cdb9
diff --git a/lib/bean/card/palette_card.dart b/lib/bean/card/palette_card.dart
new file mode 100644
index 00000000..3c0c567b
--- /dev/null
+++ b/lib/bean/card/palette_card.dart
@@ -0,0 +1,86 @@
+import 'package:flutter/material.dart';
+import 'package:material_color_utilities/material_color_utilities.dart';
+
+class PaletteCard extends StatefulWidget {
+ final Color color;
+ final bool selected;
+
+ const PaletteCard({
+ super.key,
+ required this.color,
+ required this.selected,
+ });
+
+ @override
+ State<StatefulWidget> createState() => _PaletteCardState();
+}
+
+class _PaletteCardState extends State<PaletteCard> {
+ @override
+ Widget build(BuildContext context) {
+ final Hct hct = Hct.fromInt(widget.color.value);
+ final primary = Color(Hct.from(hct.hue, 20.0, 90.0).toInt());
+ final tertiary = Color(Hct.from(hct.hue + 50, 20.0, 85.0).toInt());
+ final primaryContainer = Color(Hct.from(hct.hue, 30.0, 50.0).toInt());
+ final checkbox = Color(Hct.from(hct.hue, 30.0, 40.0).toInt());
+ return SizedBox(
+ width: 70,
+ height: 70,
+ child: Stack(
+ children: [
+ Card(
+ elevation: 0,
+ child: Container(
+ padding: const EdgeInsets.all(10),
+ child: ClipOval(
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Expanded(
+ child: Container(
+ color: primary,
+ ),
+ ),
+ Expanded(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Expanded(
+ child: Container(
+ color: tertiary,
+ ),
+ ),
+ Expanded(
+ child: Container(
+ color: primaryContainer,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ if (widget.selected)
+ Center(
+ child: Container(
+ width: 25,
+ height: 25,
+ decoration: BoxDecoration(
+ color: checkbox,
+ shape: BoxShape.circle,
+ ),
+ child: Icon(
+ Icons.check_rounded,
+ color: Theme.of(context).colorScheme.surfaceContainerLow,
+ size: 12,
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/lib/pages/settings/theme_settings_page.dart b/lib/pages/settings/theme_settings_page.dart
index fd521fb9..aa1ab36a 100644
--- a/lib/pages/settings/theme_settings_page.dart
+++ b/lib/pages/settings/theme_settings_page.dart
@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
+import 'package:kazumi/bean/card/palette_card.dart';
import 'package:kazumi/utils/storage.dart';
import 'package:hive/hive.dart';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
@@ -204,8 +205,8 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {
colorThemeTypes;
return Wrap(
alignment: WrapAlignment.center,
- spacing: 22,
- runSpacing: 18,
+ spacing: 8,
+ runSpacing: Utils.isDesktop() ? 8 : 0,
children: [
...colorThemes.map(
(e) {
@@ -219,50 +220,17 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {
},
child: Column(
children: [
- Container(
- width: 46,
- height: 46,
- decoration: BoxDecoration(
- color:
- e['color'].withOpacity(0.8),
- borderRadius:
- BorderRadius.circular(50),
- border: Border.all(
- width: 2,
- color: e['color']
- .withOpacity(0.8),
- ),
- ),
- child: AnimatedOpacity(
- opacity: (e['color']
- .value
- .toRadixString(
- 16) ==
- defaultThemeColor ||
- (defaultThemeColor ==
- 'default' &&
- index == 0))
- ? 1
- : 0,
- duration: const Duration(
- milliseconds: 200),
- child: const Icon(
- Icons.done,
- color: Colors.black,
- size: 20,
- ),
- ),
- ),
- const SizedBox(height: 3),
- Text(
- e['label'],
- style: TextStyle(
- fontSize: 12,
- color: Theme.of(context)
- .colorScheme
- .outline,
- ),
+ PaletteCard(
+ color: e['color'],
+ selected: (e['color']
+ .value
+ .toRadixString(16) ==
+ defaultThemeColor ||
+ (defaultThemeColor ==
+ 'default' &&
+ index == 0)),
),
+ Text(e['label']),
],
),
);