mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-21 16:48:43 +00:00
add split settings model
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -30,6 +30,43 @@ sealed class SettingsModel {
|
||||
});
|
||||
}
|
||||
|
||||
class SplitModel extends SettingsModel {
|
||||
const SplitModel({
|
||||
super.contentPadding,
|
||||
super.titleStyle,
|
||||
required this.normalModel,
|
||||
required this.switchModel,
|
||||
});
|
||||
|
||||
@override
|
||||
String? get effectiveSubtitle => normalModel.effectiveSubtitle;
|
||||
|
||||
@override
|
||||
String get effectiveTitle => normalModel.effectiveTitle;
|
||||
|
||||
@override
|
||||
String? get title => normalModel.title;
|
||||
|
||||
final NormalModel normalModel;
|
||||
|
||||
final SwitchModel switchModel;
|
||||
|
||||
@override
|
||||
Widget get widget => SetSwitchItem(
|
||||
title: effectiveTitle,
|
||||
subtitle: effectiveSubtitle,
|
||||
setKey: switchModel.setKey,
|
||||
defaultVal: switchModel.defaultVal,
|
||||
onChanged: switchModel.onChanged,
|
||||
needReboot: switchModel.needReboot,
|
||||
leading: normalModel.leading,
|
||||
onTap: switchModel.onTap,
|
||||
contentPadding: contentPadding,
|
||||
titleStyle: titleStyle,
|
||||
isSplit: true,
|
||||
);
|
||||
}
|
||||
|
||||
class PopupModel<T extends EnumWithLabel> extends SettingsModel {
|
||||
const PopupModel({
|
||||
required this.title,
|
||||
@@ -88,6 +125,18 @@ class NormalModel extends SettingsModel {
|
||||
this.onTap,
|
||||
}) : assert(title != null || getTitle != null);
|
||||
|
||||
const NormalModel.split({
|
||||
super.subtitle,
|
||||
super.leading,
|
||||
super.contentPadding,
|
||||
super.titleStyle,
|
||||
this.title,
|
||||
this.getTitle,
|
||||
this.getSubtitle,
|
||||
this.getTrailing,
|
||||
}) : onTap = null,
|
||||
assert(title != null || getTitle != null);
|
||||
|
||||
@override
|
||||
String get effectiveTitle => title ?? getTitle!();
|
||||
@override
|
||||
@@ -109,7 +158,7 @@ class NormalModel extends SettingsModel {
|
||||
|
||||
class SwitchModel extends SettingsModel {
|
||||
@override
|
||||
final String title;
|
||||
final String? title;
|
||||
final String setKey;
|
||||
final bool defaultVal;
|
||||
final ValueChanged<bool>? onChanged;
|
||||
@@ -121,7 +170,7 @@ class SwitchModel extends SettingsModel {
|
||||
super.leading,
|
||||
super.contentPadding,
|
||||
super.titleStyle,
|
||||
required this.title,
|
||||
required String this.title,
|
||||
required this.setKey,
|
||||
this.defaultVal = false,
|
||||
this.onChanged,
|
||||
@@ -129,14 +178,22 @@ class SwitchModel extends SettingsModel {
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
const SwitchModel.split({
|
||||
required this.setKey,
|
||||
this.defaultVal = false,
|
||||
this.needReboot = false,
|
||||
this.onChanged,
|
||||
this.onTap,
|
||||
}) : title = null;
|
||||
|
||||
@override
|
||||
String get effectiveTitle => title;
|
||||
String get effectiveTitle => title!;
|
||||
@override
|
||||
String? get effectiveSubtitle => subtitle;
|
||||
|
||||
@override
|
||||
Widget get widget => SetSwitchItem(
|
||||
title: title,
|
||||
title: title!,
|
||||
subtitle: subtitle,
|
||||
setKey: setKey,
|
||||
defaultVal: defaultVal,
|
||||
|
||||
Reference in New Issue
Block a user