mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
@@ -6,11 +6,12 @@ class MultiSelectDialog<T> extends StatefulWidget {
|
||||
final String title;
|
||||
final Map<T, String> values;
|
||||
|
||||
const MultiSelectDialog(
|
||||
{super.key,
|
||||
required this.initValues,
|
||||
required this.values,
|
||||
required this.title});
|
||||
const MultiSelectDialog({
|
||||
super.key,
|
||||
required this.initValues,
|
||||
required this.values,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MultiSelectDialog<T>> createState() => _MultiSelectDialogState<T>();
|
||||
@@ -32,31 +33,33 @@ class _MultiSelectDialogState<T> extends State<MultiSelectDialog<T>> {
|
||||
clipBehavior: Clip.hardEdge,
|
||||
title: Text(widget.title),
|
||||
contentPadding: const EdgeInsets.only(top: 12),
|
||||
content: StatefulBuilder(builder: (context, StateSetter setState) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: widget.values.entries.map((i) {
|
||||
bool isChecked = _tempValues.contains(i.key);
|
||||
return CheckboxListTile(
|
||||
dense: true,
|
||||
value: isChecked,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
title: Text(
|
||||
i.value,
|
||||
style: theme.textTheme.titleMedium!,
|
||||
),
|
||||
onChanged: (value) {
|
||||
isChecked
|
||||
? _tempValues.remove(i.key)
|
||||
: _tempValues.add(i.key);
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}),
|
||||
content: StatefulBuilder(
|
||||
builder: (context, StateSetter setState) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: widget.values.entries.map((i) {
|
||||
bool isChecked = _tempValues.contains(i.key);
|
||||
return CheckboxListTile(
|
||||
dense: true,
|
||||
value: isChecked,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
title: Text(
|
||||
i.value,
|
||||
style: theme.textTheme.titleMedium!,
|
||||
),
|
||||
onChanged: (value) {
|
||||
isChecked
|
||||
? _tempValues.remove(i.key)
|
||||
: _tempValues.add(i.key);
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
actionsPadding: const EdgeInsets.only(left: 16, right: 16, bottom: 12),
|
||||
actions: [
|
||||
TextButton(
|
||||
|
||||
@@ -44,14 +44,17 @@ class _NormalItemState extends State<NormalItem> {
|
||||
onTap: () => widget.onTap?.call(() {
|
||||
setState(() {});
|
||||
}),
|
||||
title: Text(widget.title ?? widget.getTitle?.call(),
|
||||
style: widget.titleStyle ?? Theme.of(context).textTheme.titleMedium!),
|
||||
title: Text(
|
||||
widget.title ?? widget.getTitle?.call(),
|
||||
style: widget.titleStyle ?? Theme.of(context).textTheme.titleMedium!,
|
||||
),
|
||||
subtitle: widget.subtitle != null || widget.getSubtitle != null
|
||||
? Text(widget.subtitle ?? widget.getSubtitle?.call(),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.copyWith(color: Theme.of(context).colorScheme.outline))
|
||||
? Text(
|
||||
widget.subtitle ?? widget.getSubtitle?.call(),
|
||||
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
leading: widget.leading,
|
||||
trailing: widget.getTrailing?.call(),
|
||||
|
||||
@@ -78,7 +78,9 @@ class _CdnSelectDialogState extends State<CdnSelectDialog> {
|
||||
_cdnSpeedTest = Pref.cdnSpeedTest;
|
||||
if (_cdnSpeedTest) {
|
||||
_cdnResList = List.generate(
|
||||
CDNService.values.length, (_) => ValueNotifier<String?>(null));
|
||||
CDNService.values.length,
|
||||
(_) => ValueNotifier<String?>(null),
|
||||
);
|
||||
_cancelToken = CancelToken();
|
||||
_startSpeedTest();
|
||||
}
|
||||
@@ -97,8 +99,10 @@ class _CdnSelectDialogState extends State<CdnSelectDialog> {
|
||||
}
|
||||
|
||||
Future<VideoItem> _getSampleUrl() async {
|
||||
final result =
|
||||
await VideoHttp.videoUrl(cid: 196018899, bvid: 'BV1fK4y1t7hj');
|
||||
final result = await VideoHttp.videoUrl(
|
||||
cid: 196018899,
|
||||
bvid: 'BV1fK4y1t7hj',
|
||||
);
|
||||
if (!result['status']) throw Exception('无法获取视频流');
|
||||
return result['data'].dash.video.first;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,12 @@ class _SlideDialogState extends State<SlideDialog> {
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(widget.title),
|
||||
contentPadding:
|
||||
const EdgeInsets.only(top: 20, left: 8, right: 8, bottom: 8),
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 20,
|
||||
left: 8,
|
||||
right: 8,
|
||||
bottom: 8,
|
||||
),
|
||||
content: SizedBox(
|
||||
height: 40,
|
||||
child: Slider(
|
||||
@@ -67,7 +71,7 @@ class _SlideDialogState extends State<SlideDialog> {
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, _tempValue),
|
||||
child: const Text('确定'),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,10 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
|
||||
if (widget.setKey == SettingBoxKey.appFontWeight) {
|
||||
val = Pref.appFontWeight != -1;
|
||||
} else {
|
||||
val = GStorage.setting
|
||||
.get(widget.setKey, defaultValue: widget.defaultVal ?? false);
|
||||
val = GStorage.setting.get(
|
||||
widget.setKey,
|
||||
defaultValue: widget.defaultVal ?? false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +84,10 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
await GStorage.setting
|
||||
.put(SettingBoxKey.badCertificateCallback, true);
|
||||
await GStorage.setting.put(
|
||||
SettingBoxKey.badCertificateCallback,
|
||||
true,
|
||||
);
|
||||
val = true;
|
||||
SmartDialog.showToast('重启生效');
|
||||
setState(() {});
|
||||
@@ -114,13 +118,16 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
TextStyle titleStyle = widget.titleStyle ??
|
||||
TextStyle titleStyle =
|
||||
widget.titleStyle ??
|
||||
theme.textTheme.titleMedium!.copyWith(
|
||||
color:
|
||||
widget.onTap != null && !val ? theme.colorScheme.outline : null,
|
||||
color: widget.onTap != null && !val
|
||||
? theme.colorScheme.outline
|
||||
: null,
|
||||
);
|
||||
TextStyle subTitleStyle =
|
||||
theme.textTheme.labelMedium!.copyWith(color: theme.colorScheme.outline);
|
||||
TextStyle subTitleStyle = theme.textTheme.labelMedium!.copyWith(
|
||||
color: theme.colorScheme.outline,
|
||||
);
|
||||
return ListTile(
|
||||
contentPadding: widget.contentPadding,
|
||||
enabled: widget.onTap != null ? val : true,
|
||||
@@ -136,8 +143,9 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
|
||||
alignment: Alignment.centerRight,
|
||||
scale: 0.8,
|
||||
child: Switch(
|
||||
thumbIcon:
|
||||
WidgetStateProperty.resolveWith<Icon?>((Set<WidgetState> states) {
|
||||
thumbIcon: WidgetStateProperty.resolveWith<Icon?>((
|
||||
Set<WidgetState> states,
|
||||
) {
|
||||
if (states.isNotEmpty && states.first == WidgetState.selected) {
|
||||
return const Icon(Icons.done);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user