mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: style settings
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -41,7 +41,7 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
dynamicsController = Get.find<DynamicsController>();
|
dynamicsController = Get.put(DynamicsController());
|
||||||
_dynamicsTabController = Get.put(
|
_dynamicsTabController = Get.put(
|
||||||
DynamicsTabController(dynamicsType: widget.dynamicsType)
|
DynamicsTabController(dynamicsType: widget.dynamicsType)
|
||||||
..mid = dynamicsController.mid.value,
|
..mid = dynamicsController.mid.value,
|
||||||
|
|||||||
@@ -109,9 +109,9 @@ class MainController extends GetxController {
|
|||||||
selectedIndex = defaultIndex != -1 ? defaultIndex : 0;
|
selectedIndex = defaultIndex != -1 ? defaultIndex : 0;
|
||||||
pages = navigationBars
|
pages = navigationBars
|
||||||
.map<Widget>((e) => switch (e['id']) {
|
.map<Widget>((e) => switch (e['id']) {
|
||||||
0 => HomePage(),
|
0 => const HomePage(),
|
||||||
1 => DynamicsPage(),
|
1 => const DynamicsPage(),
|
||||||
2 => MediaPage(),
|
2 => const MediaPage(),
|
||||||
_ => throw UnimplementedError(),
|
_ => throw UnimplementedError(),
|
||||||
})
|
})
|
||||||
.toList();
|
.toList();
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
import 'package:PiliPalaX/models/common/nav_bar_config.dart';
|
||||||
|
import 'package:PiliPalaX/models/common/theme_type.dart';
|
||||||
|
import 'package:PiliPalaX/pages/home/index.dart';
|
||||||
|
import 'package:PiliPalaX/pages/setting/controller.dart';
|
||||||
|
import 'package:PiliPalaX/pages/setting/widgets/select_dialog.dart';
|
||||||
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
|
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -60,9 +65,15 @@ List<Item> generateItems(int count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ColorSelectPageState extends State<ColorSelectPage> {
|
class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||||
|
final SettingController settingController = Get.put(SettingController());
|
||||||
final ColorSelectController ctr = Get.put(ColorSelectController());
|
final ColorSelectController ctr = Get.put(ColorSelectController());
|
||||||
FlexSchemeVariant _dynamicSchemeVariant =
|
FlexSchemeVariant _dynamicSchemeVariant =
|
||||||
FlexSchemeVariant.values[GStorage.schemeVariant];
|
FlexSchemeVariant.values[GStorage.schemeVariant];
|
||||||
|
TextStyle get titleStyle => Theme.of(context).textTheme.titleMedium!;
|
||||||
|
TextStyle get subTitleStyle => Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelMedium!
|
||||||
|
.copyWith(color: Theme.of(context).colorScheme.outline);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -70,53 +81,84 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
|||||||
appBar: AppBar(title: const Text('选择应用主题')),
|
appBar: AppBar(title: const Text('选择应用主题')),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: [
|
children: [
|
||||||
Builder(
|
ListTile(
|
||||||
builder: (context) => ListTile(
|
onTap: () async {
|
||||||
title: const Text('调色板风格'),
|
ThemeType? result = await showDialog(
|
||||||
leading: Container(
|
context: context,
|
||||||
width: 40,
|
builder: (context) {
|
||||||
alignment: Alignment.center,
|
return SelectDialog<ThemeType>(
|
||||||
child: Icon(Icons.palette_outlined),
|
title: '主题模式',
|
||||||
),
|
value: settingController.themeType.value,
|
||||||
subtitle: Text(
|
values: ThemeType.values.map((e) {
|
||||||
_dynamicSchemeVariant.description,
|
return {'title': e.description, 'value': e};
|
||||||
style: TextStyle(fontSize: 12),
|
}).toList());
|
||||||
),
|
|
||||||
trailing: PopupMenuButton(
|
|
||||||
initialValue: _dynamicSchemeVariant,
|
|
||||||
onSelected: (item) async {
|
|
||||||
_dynamicSchemeVariant = item;
|
|
||||||
await GStorage.setting
|
|
||||||
.put(SettingBoxKey.schemeVariant, item.index);
|
|
||||||
(context as Element).markNeedsBuild();
|
|
||||||
Get.forceAppUpdate();
|
|
||||||
},
|
},
|
||||||
itemBuilder: (context) => FlexSchemeVariant.values
|
);
|
||||||
.map((item) => PopupMenuItem<FlexSchemeVariant>(
|
if (result != null) {
|
||||||
value: item,
|
settingController.themeType.value = result;
|
||||||
child: Text(item.variantName),
|
GStorage.setting.put(SettingBoxKey.themeMode, result.index);
|
||||||
))
|
Get.forceAppUpdate();
|
||||||
.toList(),
|
}
|
||||||
child: Row(
|
},
|
||||||
mainAxisSize: MainAxisSize.min,
|
leading: Container(
|
||||||
children: [
|
width: 40,
|
||||||
Text(
|
alignment: Alignment.center,
|
||||||
_dynamicSchemeVariant.variantName,
|
child: const Icon(Icons.flashlight_on_outlined),
|
||||||
style: TextStyle(
|
),
|
||||||
height: 1,
|
title: Text('主题模式', style: titleStyle),
|
||||||
fontSize: 13,
|
subtitle: Obx(() => Text(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
'当前模式:${settingController.themeType.value.description}',
|
||||||
|
style: subTitleStyle)),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text('调色板风格'),
|
||||||
|
PopupMenuButton(
|
||||||
|
initialValue: _dynamicSchemeVariant,
|
||||||
|
onSelected: (item) async {
|
||||||
|
_dynamicSchemeVariant = item;
|
||||||
|
await GStorage.setting
|
||||||
|
.put(SettingBoxKey.schemeVariant, item.index);
|
||||||
|
Get.forceAppUpdate();
|
||||||
|
},
|
||||||
|
itemBuilder: (context) => FlexSchemeVariant.values
|
||||||
|
.map((item) => PopupMenuItem<FlexSchemeVariant>(
|
||||||
|
value: item,
|
||||||
|
child: Text(item.variantName),
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
_dynamicSchemeVariant.variantName,
|
||||||
|
style: TextStyle(
|
||||||
|
height: 1,
|
||||||
|
fontSize: 13,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
strutStyle: StrutStyle(leading: 0, height: 1),
|
||||||
),
|
),
|
||||||
strutStyle: StrutStyle(leading: 0, height: 1),
|
Icon(
|
||||||
),
|
size: 20,
|
||||||
Icon(
|
Icons.keyboard_arrow_right,
|
||||||
size: 20,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
Icons.keyboard_arrow_right,
|
)
|
||||||
color: Theme.of(context).colorScheme.primary,
|
],
|
||||||
)
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
|
),
|
||||||
|
leading: Container(
|
||||||
|
width: 40,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Icon(Icons.palette_outlined),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
_dynamicSchemeVariant.description,
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
@@ -143,12 +185,13 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Obx(
|
AnimatedSize(
|
||||||
() {
|
curve: Curves.easeInOut,
|
||||||
int type = ctr.type.value;
|
alignment: Alignment.topCenter,
|
||||||
return AnimatedOpacity(
|
duration: const Duration(milliseconds: 200),
|
||||||
opacity: type == 1 ? 1 : 0,
|
child: Obx(
|
||||||
duration: const Duration(milliseconds: 200),
|
() => SizedBox(
|
||||||
|
height: ctr.type.value == 0 ? 0 : null,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 12, left: 12, right: 12),
|
padding: const EdgeInsets.only(top: 12, left: 12, right: 12),
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
@@ -209,9 +252,30 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
|
...[
|
||||||
|
IgnorePointer(
|
||||||
|
child: SizedBox(
|
||||||
|
height: Get.height / 2,
|
||||||
|
width: Get.width,
|
||||||
|
child: const HomePage(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IgnorePointer(
|
||||||
|
child: NavigationBar(
|
||||||
|
destinations: defaultNavigationBars
|
||||||
|
.map(
|
||||||
|
(item) => NavigationDestination(
|
||||||
|
icon: item['icon'],
|
||||||
|
label: item['label'],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
final ColorSelectController colorSelectController =
|
final ColorSelectController colorSelectController =
|
||||||
Get.put(ColorSelectController());
|
Get.put(ColorSelectController());
|
||||||
|
|
||||||
late ThemeType _tempThemeValue;
|
|
||||||
late double maxRowWidth;
|
late double maxRowWidth;
|
||||||
late UpPanelPosition upPanelPosition;
|
late UpPanelPosition upPanelPosition;
|
||||||
|
|
||||||
@@ -40,7 +39,6 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_tempThemeValue = settingController.themeType.value;
|
|
||||||
maxRowWidth =
|
maxRowWidth =
|
||||||
setting.get(SettingBoxKey.maxRowWidth, defaultValue: 240.0) as double;
|
setting.get(SettingBoxKey.maxRowWidth, defaultValue: 240.0) as double;
|
||||||
upPanelPosition = UpPanelPosition.values[setting.get(
|
upPanelPosition = UpPanelPosition.values[setting.get(
|
||||||
@@ -299,14 +297,13 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SelectDialog<ThemeType>(
|
return SelectDialog<ThemeType>(
|
||||||
title: '主题模式',
|
title: '主题模式',
|
||||||
value: _tempThemeValue,
|
value: settingController.themeType.value,
|
||||||
values: ThemeType.values.map((e) {
|
values: ThemeType.values.map((e) {
|
||||||
return {'title': e.description, 'value': e};
|
return {'title': e.description, 'value': e};
|
||||||
}).toList());
|
}).toList());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
_tempThemeValue = result;
|
|
||||||
settingController.themeType.value = result;
|
settingController.themeType.value = result;
|
||||||
setting.put(SettingBoxKey.themeMode, result.index);
|
setting.put(SettingBoxKey.themeMode, result.index);
|
||||||
Get.forceAppUpdate();
|
Get.forceAppUpdate();
|
||||||
|
|||||||
Reference in New Issue
Block a user