mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: get theme color
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -42,14 +42,13 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
final ColorSelectController ctr = Get.put(ColorSelectController());
|
||||
FlexSchemeVariant _dynamicSchemeVariant =
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
TextStyle titleStyle = theme.textTheme.titleMedium!;
|
||||
TextStyle subTitleStyle =
|
||||
theme.textTheme.labelMedium!.copyWith(color: theme.colorScheme.outline);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('选择应用主题')),
|
||||
body: SafeArea(
|
||||
@@ -119,11 +118,8 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
height: 1,
|
||||
fontSize: 13,
|
||||
color: ctr.type.value == 0
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.outline
|
||||
.withOpacity(0.8)
|
||||
: Theme.of(context).colorScheme.secondary,
|
||||
? theme.colorScheme.outline.withOpacity(0.8)
|
||||
: theme.colorScheme.secondary,
|
||||
),
|
||||
strutStyle: StrutStyle(leading: 0, height: 1),
|
||||
),
|
||||
@@ -131,11 +127,8 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
size: 20,
|
||||
Icons.keyboard_arrow_right,
|
||||
color: ctr.type.value == 0
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.outline
|
||||
.withOpacity(0.8)
|
||||
: Theme.of(context).colorScheme.secondary,
|
||||
? theme.colorScheme.outline.withOpacity(0.8)
|
||||
: theme.colorScheme.secondary,
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -236,9 +229,7 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: ctr.currentColor.value != index
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.outline
|
||||
? theme.colorScheme.outline
|
||||
: null,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -35,6 +35,7 @@ class _FontSizeSelectPageState extends State<FontSizeSelectPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
actions: [
|
||||
@@ -65,11 +66,8 @@ class _FontSizeSelectPageState extends State<FontSizeSelectPage> {
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary
|
||||
.withOpacity(0.3))),
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
color: theme.colorScheme.primary.withOpacity(0.3))),
|
||||
color: theme.colorScheme.surface,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
@@ -129,7 +129,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
}
|
||||
|
||||
// 设定倍速弹窗
|
||||
void showBottomSheet(index) {
|
||||
void showBottomSheet(ThemeData theme, int index) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useSafeArea: true,
|
||||
@@ -150,11 +150,11 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
menuAction(index, item['id']);
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
iconColor: Theme.of(context).colorScheme.onSurface,
|
||||
iconColor: theme.colorScheme.onSurface,
|
||||
leading: item['leading'],
|
||||
title: Text(
|
||||
item['title'],
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
style: theme.textTheme.titleSmall,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -194,6 +194,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('倍速设置'),
|
||||
@@ -218,7 +219,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
const EdgeInsets.only(left: 14, right: 14, top: 6, bottom: 0),
|
||||
child: Text(
|
||||
'点击下方按钮设置默认(长按)倍速',
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@@ -255,7 +256,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
children: [
|
||||
Text(
|
||||
'倍速列表',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
TextButton(
|
||||
@@ -278,7 +279,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
children: List.generate(
|
||||
speedList.length,
|
||||
(index) => FilledButton.tonal(
|
||||
onPressed: () => showBottomSheet(index),
|
||||
onPressed: () => showBottomSheet(theme, index),
|
||||
child: Text(speedList[index].toString()),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -8,6 +8,7 @@ class RecommendSetting extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: showAppBar == false ? null : AppBar(title: const Text('推荐流设置')),
|
||||
body: ListView(
|
||||
@@ -20,9 +21,8 @@ class RecommendSetting extends StatelessWidget {
|
||||
'* 其它(如热门视频、手动搜索、链接跳转等)均不受过滤器影响。\n'
|
||||
'* 设定较严苛的条件可导致推荐项数锐减或多次请求,请酌情选择。\n'
|
||||
'* 后续可能会增加更多过滤条件,敬请期待。',
|
||||
style: Theme.of(context).textTheme.labelSmall!.copyWith(
|
||||
color:
|
||||
Theme.of(context).colorScheme.outline.withOpacity(0.7)),
|
||||
style: theme.textTheme.labelSmall!
|
||||
.copyWith(color: theme.colorScheme.outline.withOpacity(0.7)),
|
||||
),
|
||||
),
|
||||
SizedBox(height: MediaQuery.paddingOf(context).bottom + 80),
|
||||
|
||||
@@ -56,12 +56,6 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
TextStyle get _titleStyle => TextStyle(fontSize: 15);
|
||||
TextStyle get _subTitleStyle => TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
);
|
||||
|
||||
_checkServerStatus() {
|
||||
Request()
|
||||
.get(
|
||||
@@ -78,7 +72,9 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget get _blockLimitItem => ListTile(
|
||||
Widget _blockLimitItem(
|
||||
ThemeData theme, TextStyle titleStyle, TextStyle subTitleStyle) =>
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () {
|
||||
_textController.text = _blockLimit.toString();
|
||||
@@ -86,7 +82,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('最短片段时长', style: _titleStyle),
|
||||
title: Text('最短片段时长', style: titleStyle),
|
||||
content: TextFormField(
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
controller: _textController,
|
||||
@@ -102,7 +98,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -121,10 +117,10 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
},
|
||||
);
|
||||
},
|
||||
title: Text('最短片段时长', style: _titleStyle),
|
||||
title: Text('最短片段时长', style: titleStyle),
|
||||
subtitle: Text(
|
||||
'忽略短于此时长的片段',
|
||||
style: _subTitleStyle,
|
||||
style: subTitleStyle,
|
||||
),
|
||||
trailing: Text(
|
||||
'${_blockLimit}s',
|
||||
@@ -132,17 +128,19 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
),
|
||||
);
|
||||
|
||||
Widget get _aboudItem => ListTile(
|
||||
Widget _aboudItem(TextStyle titleStyle, TextStyle subTitleStyle) => ListTile(
|
||||
dense: true,
|
||||
title: Text('关于空降助手', style: _titleStyle),
|
||||
subtitle: Text(_url, style: _subTitleStyle),
|
||||
title: Text('关于空降助手', style: titleStyle),
|
||||
subtitle: Text(_url, style: subTitleStyle),
|
||||
onTap: () => PageUtils.launchURL(_url),
|
||||
);
|
||||
|
||||
Widget get _userIdItem => ListTile(
|
||||
Widget _userIdItem(
|
||||
ThemeData theme, TextStyle titleStyle, TextStyle subTitleStyle) =>
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: Text('用户ID', style: _titleStyle),
|
||||
subtitle: Text(_userId, style: _subTitleStyle),
|
||||
title: Text('用户ID', style: titleStyle),
|
||||
subtitle: Text(_userId, style: subTitleStyle),
|
||||
onTap: () {
|
||||
final key = GlobalKey<FormState>();
|
||||
_textController.text = _userId;
|
||||
@@ -150,7 +148,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('用户ID', style: _titleStyle),
|
||||
title: Text('用户ID', style: titleStyle),
|
||||
content: Form(
|
||||
key: key,
|
||||
child: TextFormField(
|
||||
@@ -184,7 +182,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -218,12 +216,12 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
Widget get _blockToastItem => ListTile(
|
||||
Widget _blockToastItem(TextStyle titleStyle) => ListTile(
|
||||
dense: true,
|
||||
onTap: _updateBlockToast,
|
||||
title: Text(
|
||||
'显示跳过Toast',
|
||||
style: _titleStyle,
|
||||
style: titleStyle,
|
||||
),
|
||||
trailing: Transform.scale(
|
||||
alignment: Alignment.centerRight,
|
||||
@@ -242,36 +240,39 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
),
|
||||
));
|
||||
|
||||
Widget get _blockTrackItem => ListTile(
|
||||
dense: true,
|
||||
onTap: _updateBlockTrack,
|
||||
title: Text(
|
||||
'跳过次数统计跟踪',
|
||||
style: _titleStyle,
|
||||
),
|
||||
subtitle: Text(
|
||||
// from origin extension
|
||||
'此功能追踪您跳过了哪些片段,让用户知道他们提交的片段帮助了多少人。同时点赞会作为依据,确保垃圾信息不会污染数据库。在您每次跳过片段时,我们都会向服务器发送一条消息。希望大家开启此项设置,以便得到更准确的统计数据。:)',
|
||||
style: _subTitleStyle,
|
||||
),
|
||||
trailing: Transform.scale(
|
||||
alignment: Alignment.centerRight,
|
||||
scale: 0.8,
|
||||
child: Switch(
|
||||
thumbIcon: WidgetStateProperty.resolveWith<Icon?>((states) {
|
||||
if (states.isNotEmpty && states.first == WidgetState.selected) {
|
||||
return const Icon(Icons.done);
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
value: _blockTrack,
|
||||
onChanged: (val) {
|
||||
_updateBlockTrack();
|
||||
},
|
||||
),
|
||||
));
|
||||
Widget _blockTrackItem(TextStyle titleStyle, TextStyle subTitleStyle) =>
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: _updateBlockTrack,
|
||||
title: Text(
|
||||
'跳过次数统计跟踪',
|
||||
style: titleStyle,
|
||||
),
|
||||
subtitle: Text(
|
||||
// from origin extension
|
||||
'此功能追踪您跳过了哪些片段,让用户知道他们提交的片段帮助了多少人。同时点赞会作为依据,确保垃圾信息不会污染数据库。在您每次跳过片段时,我们都会向服务器发送一条消息。希望大家开启此项设置,以便得到更准确的统计数据。:)',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
trailing: Transform.scale(
|
||||
alignment: Alignment.centerRight,
|
||||
scale: 0.8,
|
||||
child: Switch(
|
||||
thumbIcon: WidgetStateProperty.resolveWith<Icon?>((states) {
|
||||
if (states.isNotEmpty && states.first == WidgetState.selected) {
|
||||
return const Icon(Icons.done);
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
value: _blockTrack,
|
||||
onChanged: (val) {
|
||||
_updateBlockTrack();
|
||||
},
|
||||
),
|
||||
));
|
||||
|
||||
Widget get _blockServerItem => ListTile(
|
||||
Widget _blockServerItem(
|
||||
ThemeData theme, TextStyle titleStyle, TextStyle subTitleStyle) =>
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () {
|
||||
_textController.text = _blockServer;
|
||||
@@ -279,7 +280,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('服务器地址', style: _titleStyle),
|
||||
title: Text('服务器地址', style: titleStyle),
|
||||
content: TextFormField(
|
||||
keyboardType: TextInputType.url,
|
||||
controller: _textController,
|
||||
@@ -302,7 +303,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -324,20 +325,20 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
},
|
||||
title: Text(
|
||||
'服务器地址',
|
||||
style: _titleStyle,
|
||||
style: titleStyle,
|
||||
),
|
||||
subtitle: Text(
|
||||
_blockServer,
|
||||
style: _subTitleStyle,
|
||||
style: subTitleStyle,
|
||||
),
|
||||
);
|
||||
|
||||
Widget get _serverStatusItem => ListTile(
|
||||
Widget _serverStatusItem(ThemeData theme, TextStyle titleStyle) => ListTile(
|
||||
dense: true,
|
||||
onTap: _checkServerStatus,
|
||||
title: Text(
|
||||
'服务器状态',
|
||||
style: _titleStyle,
|
||||
style: titleStyle,
|
||||
),
|
||||
trailing: Text(
|
||||
_serverStatus == null
|
||||
@@ -350,41 +351,51 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
color: _serverStatus == null
|
||||
? null
|
||||
: _serverStatus == true
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.error,
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget get _divider => SliverToBoxAdapter(
|
||||
child: Divider(
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.1),
|
||||
),
|
||||
);
|
||||
|
||||
Widget get _dividerL => SliverToBoxAdapter(
|
||||
child: Divider(
|
||||
thickness: 16,
|
||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.1),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
final titleStyle = TextStyle(fontSize: 15);
|
||||
|
||||
final subTitleStyle = TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.outline,
|
||||
);
|
||||
|
||||
final divider = SliverToBoxAdapter(
|
||||
child: Divider(
|
||||
height: 1,
|
||||
color: theme.colorScheme.outline.withOpacity(0.1),
|
||||
),
|
||||
);
|
||||
|
||||
final dividerL = SliverToBoxAdapter(
|
||||
child: Divider(
|
||||
thickness: 16,
|
||||
color: theme.colorScheme.outline.withOpacity(0.1),
|
||||
),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('空降助手')),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
_dividerL,
|
||||
SliverToBoxAdapter(child: _serverStatusItem),
|
||||
_dividerL,
|
||||
SliverToBoxAdapter(child: _blockLimitItem),
|
||||
_divider,
|
||||
SliverToBoxAdapter(child: _blockToastItem),
|
||||
_divider,
|
||||
SliverToBoxAdapter(child: _blockTrackItem),
|
||||
_dividerL,
|
||||
dividerL,
|
||||
SliverToBoxAdapter(child: _serverStatusItem(theme, titleStyle)),
|
||||
dividerL,
|
||||
SliverToBoxAdapter(
|
||||
child: _blockLimitItem(theme, titleStyle, subTitleStyle)),
|
||||
divider,
|
||||
SliverToBoxAdapter(child: _blockToastItem(titleStyle)),
|
||||
divider,
|
||||
SliverToBoxAdapter(child: _blockTrackItem(titleStyle, titleStyle)),
|
||||
dividerL,
|
||||
SliverList.separated(
|
||||
itemCount: _blockSettings.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
@@ -493,11 +504,8 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
fontSize: 14,
|
||||
color: _blockSettings[index].second ==
|
||||
SkipType.disable
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.outline
|
||||
.withOpacity(0.7)
|
||||
: Theme.of(context).colorScheme.secondary,
|
||||
? theme.colorScheme.outline.withOpacity(0.7)
|
||||
: theme.colorScheme.secondary,
|
||||
),
|
||||
strutStyle: StrutStyle(height: 1, leading: 0),
|
||||
),
|
||||
@@ -506,11 +514,8 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
size: MediaQuery.textScalerOf(context).scale(14),
|
||||
color:
|
||||
_blockSettings[index].second == SkipType.disable
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.outline
|
||||
.withOpacity(0.7)
|
||||
: Theme.of(context).colorScheme.secondary,
|
||||
? theme.colorScheme.outline.withOpacity(0.7)
|
||||
: theme.colorScheme.secondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -524,22 +529,24 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
fontSize: 12,
|
||||
color: _blockSettings[index].second == SkipType.disable
|
||||
? null
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.1),
|
||||
color: theme.colorScheme.outline.withOpacity(0.1),
|
||||
),
|
||||
),
|
||||
_dividerL,
|
||||
SliverToBoxAdapter(child: _userIdItem),
|
||||
_divider,
|
||||
SliverToBoxAdapter(child: _blockServerItem),
|
||||
_dividerL,
|
||||
SliverToBoxAdapter(child: _aboudItem),
|
||||
_dividerL,
|
||||
dividerL,
|
||||
SliverToBoxAdapter(
|
||||
child: _userIdItem(theme, titleStyle, subTitleStyle)),
|
||||
divider,
|
||||
SliverToBoxAdapter(
|
||||
child: _blockServerItem(theme, titleStyle, subTitleStyle)),
|
||||
dividerL,
|
||||
SliverToBoxAdapter(child: _aboudItem(titleStyle, subTitleStyle)),
|
||||
dividerL,
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 55 + MediaQuery.paddingOf(context).bottom,
|
||||
|
||||
@@ -42,11 +42,6 @@ class SettingPage extends StatefulWidget {
|
||||
class _SettingPageState extends State<SettingPage> {
|
||||
late String _type = 'privacySetting';
|
||||
final RxBool _noAccount = Accounts.accountMode.isEmpty.obs;
|
||||
TextStyle get _titleStyle => Theme.of(context).textTheme.titleMedium!;
|
||||
TextStyle get _subTitleStyle => Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.copyWith(color: Theme.of(context).colorScheme.outline);
|
||||
bool get _isPortrait => context.orientation == Orientation.portrait;
|
||||
|
||||
final List<_SettingsModel> _items = [
|
||||
@@ -100,6 +95,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: _isPortrait
|
||||
@@ -117,7 +113,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
}),
|
||||
),
|
||||
body: _isPortrait
|
||||
? _buildList
|
||||
? _buildList(theme)
|
||||
: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -127,12 +123,12 @@ class _SettingPageState extends State<SettingPage> {
|
||||
context: context,
|
||||
removeRight: true,
|
||||
removeTop: true,
|
||||
child: _buildList,
|
||||
child: _buildList(theme),
|
||||
),
|
||||
),
|
||||
VerticalDivider(
|
||||
width: 1,
|
||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.1),
|
||||
color: theme.colorScheme.outline.withOpacity(0.1),
|
||||
),
|
||||
Expanded(
|
||||
flex: 6,
|
||||
@@ -167,29 +163,30 @@ class _SettingPageState extends State<SettingPage> {
|
||||
}
|
||||
}
|
||||
|
||||
Color? _getTileColor(String name) {
|
||||
Color? _getTileColor(ThemeData theme, String name) {
|
||||
if (_isPortrait) {
|
||||
return null;
|
||||
} else {
|
||||
return name == _type
|
||||
? Theme.of(context).colorScheme.onInverseSurface
|
||||
: null;
|
||||
return name == _type ? theme.colorScheme.onInverseSurface : null;
|
||||
}
|
||||
}
|
||||
|
||||
Widget get _buildList {
|
||||
Widget _buildList(ThemeData theme) {
|
||||
TextStyle titleStyle = theme.textTheme.titleMedium!;
|
||||
TextStyle subTitleStyle =
|
||||
theme.textTheme.labelMedium!.copyWith(color: theme.colorScheme.outline);
|
||||
return ListView(
|
||||
children: [
|
||||
_buildSearchItem,
|
||||
_buildSearchItem(theme),
|
||||
..._items.sublist(0, _items.length - 1).map(
|
||||
(item) => ListTile(
|
||||
tileColor: _getTileColor(item.name),
|
||||
tileColor: _getTileColor(theme, item.name),
|
||||
onTap: () => _toPage(item.name),
|
||||
leading: Icon(item.icon),
|
||||
title: Text(item.title, style: _titleStyle),
|
||||
title: Text(item.title, style: titleStyle),
|
||||
subtitle: item.subtitle == null
|
||||
? null
|
||||
: Text(item.subtitle!, style: _subTitleStyle),
|
||||
: Text(item.subtitle!, style: subTitleStyle),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@@ -203,14 +200,14 @@ class _SettingPageState extends State<SettingPage> {
|
||||
: ListTile(
|
||||
leading: const Icon(Icons.logout_outlined),
|
||||
onTap: () => _logoutDialog(context),
|
||||
title: Text('退出登录', style: _titleStyle),
|
||||
title: Text('退出登录', style: titleStyle),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
tileColor: _getTileColor(_items.last.name),
|
||||
tileColor: _getTileColor(theme, _items.last.name),
|
||||
onTap: () => _toPage(_items.last.name),
|
||||
leading: Icon(_items.last.icon),
|
||||
title: Text(_items.last.title, style: _titleStyle),
|
||||
title: Text(_items.last.title, style: titleStyle),
|
||||
),
|
||||
SizedBox(height: MediaQuery.paddingOf(context).bottom + 80),
|
||||
],
|
||||
@@ -234,9 +231,10 @@ class _SettingPageState extends State<SettingPage> {
|
||||
return Accounts.deleteAll(result);
|
||||
}
|
||||
|
||||
await showDialog(
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
final theme = Theme.of(context);
|
||||
return AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content: Text(
|
||||
@@ -247,7 +245,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
child: Text(
|
||||
'点错了',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -258,7 +256,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
},
|
||||
child: Text(
|
||||
'仅登出',
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
style: TextStyle(color: theme.colorScheme.error),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
@@ -281,7 +279,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget get _buildSearchItem => Padding(
|
||||
Widget _buildSearchItem(ThemeData theme) => Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 5),
|
||||
child: InkWell(
|
||||
onTap: () => Get.toNamed('/settingsSearch'),
|
||||
@@ -290,7 +288,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
color: theme.colorScheme.onInverseSurface,
|
||||
),
|
||||
child: Center(
|
||||
child: Row(
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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!),
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user