opt: get theme color

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-28 21:32:30 +08:00
parent 451a84e696
commit ca993df0c6
149 changed files with 4415 additions and 4803 deletions

View File

@@ -27,6 +27,7 @@ class _MultiSelectDialogState<T> extends State<MultiSelectDialog<T>> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return AlertDialog(
clipBehavior: Clip.hardEdge,
title: Text(widget.title),
@@ -43,7 +44,7 @@ class _MultiSelectDialogState<T> extends State<MultiSelectDialog<T>> {
controlAffinity: ListTileControlAffinity.leading,
title: Text(
i.value,
style: Theme.of(context).textTheme.titleMedium!,
style: theme.textTheme.titleMedium!,
),
onChanged: (value) {
isChecked
@@ -63,7 +64,7 @@ class _MultiSelectDialogState<T> extends State<MultiSelectDialog<T>> {
child: Text(
'取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
color: theme.colorScheme.outline,
),
),
),

View File

@@ -91,10 +91,9 @@ class _SetSelectItemState extends State<SetSelectItem> {
@override
Widget build(BuildContext context) {
TextStyle subTitleStyle = Theme.of(context)
.textTheme
.labelMedium!
.copyWith(color: Theme.of(context).colorScheme.outline);
final theme = Theme.of(context);
TextStyle subTitleStyle =
theme.textTheme.labelMedium!.copyWith(color: theme.colorScheme.outline);
return ListTile(
onTap: () {},
title: Text(widget.title!),

View File

@@ -59,7 +59,7 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
setVal();
}
void switchChange(value) async {
void switchChange(ThemeData theme, value) async {
if (widget.setKey == SettingBoxKey.badCertificateCallback &&
(value ?? !val)) {
showDialog(
@@ -73,7 +73,7 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
child: Text(
'取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
color: theme.colorScheme.outline,
),
),
),
@@ -111,22 +111,21 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
TextStyle titleStyle = widget.titleStyle ??
Theme.of(context).textTheme.titleMedium!.copyWith(
color: widget.onTap != null && !val
? Theme.of(context).colorScheme.outline
: null,
);
TextStyle subTitleStyle = Theme.of(context)
.textTheme
.labelMedium!
.copyWith(color: Theme.of(context).colorScheme.outline);
theme.textTheme.titleMedium!.copyWith(
color:
widget.onTap != null && !val ? theme.colorScheme.outline : null,
);
TextStyle subTitleStyle =
theme.textTheme.labelMedium!.copyWith(color: theme.colorScheme.outline);
return ListTile(
contentPadding: widget.contentPadding,
enabled: widget.onTap != null ? val : true,
enableFeedback: true,
onTap: () =>
widget.onTap != null ? widget.onTap?.call() : switchChange(null),
onTap: () => widget.onTap != null
? widget.onTap?.call()
: switchChange(theme, null),
title: Text(widget.title!, style: titleStyle),
subtitle: widget.subtitle != null
? Text(widget.subtitle!, style: subTitleStyle)
@@ -144,7 +143,7 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
return null;
}),
value: val,
onChanged: switchChange,
onChanged: (value) => switchChange(theme, value),
),
),
);