@ -1,4 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
|
Box setting = GStrorage.setting;
|
||||||
|
|
||||||
class CustomToast extends StatelessWidget {
|
class CustomToast extends StatelessWidget {
|
||||||
final String msg;
|
final String msg;
|
||||||
@ -6,12 +10,17 @@ class CustomToast extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
double toastOpacity =
|
||||||
|
setting.get(SettingBoxKey.defaultToastOp, defaultValue: 1.0);
|
||||||
return Container(
|
return Container(
|
||||||
margin:
|
margin:
|
||||||
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom + 30),
|
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom + 30),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.primaryContainer,
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primaryContainer
|
||||||
|
.withOpacity(toastOpacity),
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@ -15,6 +15,7 @@ class SettingController extends GetxController {
|
|||||||
|
|
||||||
RxBool userLogin = false.obs;
|
RxBool userLogin = false.obs;
|
||||||
RxBool feedBackEnable = false.obs;
|
RxBool feedBackEnable = false.obs;
|
||||||
|
RxDouble toastOpacity = (1.0).obs;
|
||||||
RxInt picQuality = 10.obs;
|
RxInt picQuality = 10.obs;
|
||||||
Rx<ThemeType> themeType = ThemeType.system.obs;
|
Rx<ThemeType> themeType = ThemeType.system.obs;
|
||||||
var userInfo;
|
var userInfo;
|
||||||
@ -26,6 +27,8 @@ class SettingController extends GetxController {
|
|||||||
userLogin.value = userInfo != null;
|
userLogin.value = userInfo != null;
|
||||||
feedBackEnable.value =
|
feedBackEnable.value =
|
||||||
setting.get(SettingBoxKey.feedBackEnable, defaultValue: false);
|
setting.get(SettingBoxKey.feedBackEnable, defaultValue: false);
|
||||||
|
toastOpacity.value =
|
||||||
|
setting.get(SettingBoxKey.defaultToastOp, defaultValue: 1.0);
|
||||||
picQuality.value =
|
picQuality.value =
|
||||||
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
||||||
themeType.value = ThemeType.values[setting.get(SettingBoxKey.themeMode,
|
themeType.value = ThemeType.values[setting.get(SettingBoxKey.themeMode,
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/models/common/theme_type.dart';
|
import 'package:pilipala/models/common/theme_type.dart';
|
||||||
import 'package:pilipala/pages/setting/pages/color_select.dart';
|
import 'package:pilipala/pages/setting/pages/color_select.dart';
|
||||||
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
||||||
|
import 'package:pilipala/pages/setting/widgets/slide_dialog.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
@ -25,6 +27,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
|
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
late int picQuality;
|
late int picQuality;
|
||||||
|
late double toastOpacity;
|
||||||
late ThemeType _tempThemeValue;
|
late ThemeType _tempThemeValue;
|
||||||
late dynamic defaultCustomRows;
|
late dynamic defaultCustomRows;
|
||||||
|
|
||||||
@ -32,6 +35,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
picQuality = setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
picQuality = setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
||||||
|
toastOpacity = setting.get(SettingBoxKey.defaultToastOp, defaultValue: 1.0);
|
||||||
_tempThemeValue = settingController.themeType.value;
|
_tempThemeValue = settingController.themeType.value;
|
||||||
defaultCustomRows = setting.get(SettingBoxKey.customRows, defaultValue: 2);
|
defaultCustomRows = setting.get(SettingBoxKey.customRows, defaultValue: 2);
|
||||||
}
|
}
|
||||||
@ -187,6 +191,30 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
onTap: () async {
|
||||||
|
double? result = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return SlideDialog<double>(
|
||||||
|
title: 'Toast不透明度',
|
||||||
|
value: settingController.toastOpacity.value,
|
||||||
|
min: 0.0,
|
||||||
|
max: 1.0,
|
||||||
|
divisions: 10,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
settingController.toastOpacity.value = result;
|
||||||
|
SmartDialog.showToast('设置成功');
|
||||||
|
setting.put(SettingBoxKey.defaultToastOp, result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
title: Text('Toast不透明度', style: titleStyle),
|
||||||
|
subtitle: Text('自定义Toast不透明度', style: subTitleStyle),
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: false,
|
dense: false,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
|||||||
71
lib/pages/setting/widgets/slide_dialog.dart
Normal file
71
lib/pages/setting/widgets/slide_dialog.dart
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
// import 'package:pilipala/models/common/theme_type.dart';
|
||||||
|
|
||||||
|
class SlideDialog<T extends num> extends StatefulWidget {
|
||||||
|
final T value;
|
||||||
|
final String title;
|
||||||
|
final double min;
|
||||||
|
final double max;
|
||||||
|
final int? divisions;
|
||||||
|
final String? suffix;
|
||||||
|
|
||||||
|
const SlideDialog({
|
||||||
|
super.key,
|
||||||
|
required this.value,
|
||||||
|
required this.title,
|
||||||
|
required this.min,
|
||||||
|
required this.max,
|
||||||
|
this.divisions,
|
||||||
|
this.suffix,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_SlideDialogState<T> createState() => _SlideDialogState<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SlideDialogState<T extends num> extends State<SlideDialog<T>> {
|
||||||
|
late double _tempValue;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_tempValue = widget.value.toDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(widget.title),
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.only(top: 20, left: 8, right: 8, bottom: 8),
|
||||||
|
content: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: Slider(
|
||||||
|
value: _tempValue,
|
||||||
|
min: widget.min,
|
||||||
|
max: widget.max,
|
||||||
|
divisions: widget.divisions ?? 10,
|
||||||
|
label: '$_tempValue${widget.suffix ?? ''}',
|
||||||
|
onChanged: (double value) {
|
||||||
|
setState(() {
|
||||||
|
_tempValue = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context, _tempValue as T),
|
||||||
|
child: const Text('确定'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -98,6 +98,7 @@ class SettingBoxKey {
|
|||||||
fullScreenMode = 'fullScreenMode',
|
fullScreenMode = 'fullScreenMode',
|
||||||
defaultDecode = 'defaultDecode',
|
defaultDecode = 'defaultDecode',
|
||||||
danmakuEnable = 'danmakuEnable',
|
danmakuEnable = 'danmakuEnable',
|
||||||
|
defaultToastOp = 'defaultToastOp',
|
||||||
defaultPicQa = 'defaultPicQa',
|
defaultPicQa = 'defaultPicQa',
|
||||||
enableHA = 'enableHA',
|
enableHA = 'enableHA',
|
||||||
enableOnlineTotal = 'enableOnlineTotal',
|
enableOnlineTotal = 'enableOnlineTotal',
|
||||||
|
|||||||
Reference in New Issue
Block a user