From 9cf74c0db6ffb6f8a491d707e54ce235a85deced Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sat, 4 Jan 2025 10:44:21 +0800 Subject: [PATCH] opt: pages Signed-off-by: bggRGjQaUbCoE --- lib/pages/dynamics/view.dart | 234 ++++++++++--------- lib/pages/dynamics/widgets/action_panel.dart | 95 ++++---- lib/pages/setting/sponsor_block_page.dart | 147 ++++++------ lib/pages/setting/widgets/model.dart | 52 +++-- lib/pages/video/detail/controller.dart | 8 +- 5 files changed, 288 insertions(+), 248 deletions(-) diff --git a/lib/pages/dynamics/view.dart b/lib/pages/dynamics/view.dart index 93a0d29b..1b4dc3c9 100644 --- a/lib/pages/dynamics/view.dart +++ b/lib/pages/dynamics/view.dart @@ -332,52 +332,64 @@ class _CreatePanelState extends State { appBar: PreferredSize( preferredSize: Size.fromHeight(66), child: Padding( - padding: const EdgeInsets.only(top: 16, bottom: 16), - child: Row( + padding: const EdgeInsets.all(16), + child: Stack( children: [ - const SizedBox(width: 16), - SizedBox( - width: 34, - height: 34, - child: IconButton( - tooltip: '返回', - style: ButtonStyle( - padding: WidgetStateProperty.all(EdgeInsets.zero), - backgroundColor: WidgetStateProperty.resolveWith( - (states) { - return Theme.of(context).colorScheme.secondaryContainer; - }, + Positioned( + top: 0, + left: 0, + bottom: 0, + child: SizedBox( + width: 34, + height: 34, + child: IconButton( + tooltip: '返回', + style: ButtonStyle( + padding: WidgetStateProperty.all(EdgeInsets.zero), + backgroundColor: WidgetStateProperty.resolveWith( + (states) { + return Theme.of(context) + .colorScheme + .secondaryContainer; + }, + ), + ), + onPressed: Get.back, + icon: Icon( + Icons.arrow_back_outlined, + size: 18, + color: Theme.of(context).colorScheme.onSecondaryContainer, ), - ), - onPressed: Get.back, - icon: Icon( - Icons.arrow_back_outlined, - size: 18, - color: Theme.of(context).colorScheme.onSecondaryContainer, ), ), ), - const Spacer(), - const Text( - '发布动态', - style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), - ), - const Spacer(), - Obx( - () => FilledButton.tonal( - onPressed: _isEnablePub.value ? _onCreate : null, - style: FilledButton.styleFrom( - padding: const EdgeInsets.symmetric( - horizontal: 20, vertical: 10), - visualDensity: const VisualDensity( - horizontal: -2, - vertical: -2, - ), - ), - child: Text(_publishTime == null ? '发布' : '定时发布'), + Center( + child: const Text( + '发布动态', + style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), + ), + ), + Positioned( + top: 0, + right: 0, + child: Obx( + () => FilledButton.tonal( + onPressed: _isEnablePub.value ? _onCreate : null, + style: FilledButton.styleFrom( + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 10, + ), + visualDensity: const VisualDensity( + horizontal: -2, + vertical: -2, + ), + ), + child: Text(_publishTime == null ? '发布' : '定时发布'), + ), ), ), - const SizedBox(width: 16), ], ), ), @@ -520,78 +532,6 @@ class _CreatePanelState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - PopupMenuButton( - enabled: _publishTime == null, - initialValue: _isPrivate, - onSelected: (value) { - setState(() { - _isPrivate = value; - }); - }, - itemBuilder: (context) => List.generate( - 2, - (index) => PopupMenuItem( - value: index == 0 ? false : true, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - size: 19, - index == 0 - ? Icons.visibility - : Icons.visibility_off, - ), - const SizedBox(width: 4), - Text(index == 0 ? '所有人可见' : '仅自己可见'), - ], - ), - ), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 2), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - size: 19, - _isPrivate - ? Icons.visibility_off - : Icons.visibility, - color: _publishTime == null - ? _isPrivate - ? Theme.of(context).colorScheme.error - : Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.outline, - ), - const SizedBox(width: 4), - Text( - _isPrivate ? '仅自己可见' : '所有人可见', - style: TextStyle( - height: 1, - color: _publishTime == null - ? _isPrivate - ? Theme.of(context).colorScheme.error - : Theme.of(context) - .colorScheme - .primary - : Theme.of(context).colorScheme.outline, - ), - strutStyle: StrutStyle(leading: 0, height: 1), - ), - Icon( - size: 20, - Icons.keyboard_arrow_right, - color: _publishTime == null - ? _isPrivate - ? Theme.of(context).colorScheme.error - : Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.outline, - ), - ], - ), - ), - ), - const SizedBox(height: 5), PopupMenuButton( initialValue: _replyOption, onSelected: (item) { @@ -627,7 +567,7 @@ class _CreatePanelState extends State { _replyOption.iconData, color: _replyOption == ReplyOption.close ? Theme.of(context).colorScheme.error - : Theme.of(context).colorScheme.primary, + : Theme.of(context).colorScheme.secondary, ), const SizedBox(width: 4), Text( @@ -636,7 +576,7 @@ class _CreatePanelState extends State { height: 1, color: _replyOption == ReplyOption.close ? Theme.of(context).colorScheme.error - : Theme.of(context).colorScheme.primary, + : Theme.of(context).colorScheme.secondary, ), strutStyle: StrutStyle(leading: 0, height: 1), ), @@ -645,7 +585,73 @@ class _CreatePanelState extends State { Icons.keyboard_arrow_right, color: _replyOption == ReplyOption.close ? Theme.of(context).colorScheme.error - : Theme.of(context).colorScheme.primary, + : Theme.of(context).colorScheme.secondary, + ), + ], + ), + ), + ), + const SizedBox(height: 5), + PopupMenuButton( + initialValue: _isPrivate, + onSelected: (value) { + setState(() { + _isPrivate = value; + }); + }, + itemBuilder: (context) => List.generate( + 2, + (index) => PopupMenuItem( + enabled: _publishTime != null && index == 1 + ? false + : true, + value: index == 0 ? false : true, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + size: 19, + index == 0 + ? Icons.visibility + : Icons.visibility_off, + ), + const SizedBox(width: 4), + Text(index == 0 ? '所有人可见' : '仅自己可见'), + ], + ), + ), + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 2), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + size: 19, + _isPrivate + ? Icons.visibility_off + : Icons.visibility, + color: _isPrivate + ? Theme.of(context).colorScheme.error + : Theme.of(context).colorScheme.secondary, + ), + const SizedBox(width: 4), + Text( + _isPrivate ? '仅自己可见' : '所有人可见', + style: TextStyle( + height: 1, + color: _isPrivate + ? Theme.of(context).colorScheme.error + : Theme.of(context).colorScheme.secondary, + ), + strutStyle: StrutStyle(leading: 0, height: 1), + ), + Icon( + size: 20, + Icons.keyboard_arrow_right, + color: _isPrivate + ? Theme.of(context).colorScheme.error + : Theme.of(context).colorScheme.secondary, ), ], ), diff --git a/lib/pages/dynamics/widgets/action_panel.dart b/lib/pages/dynamics/widgets/action_panel.dart index 68940889..07e75e69 100644 --- a/lib/pages/dynamics/widgets/action_panel.dart +++ b/lib/pages/dynamics/widgets/action_panel.dart @@ -286,49 +286,66 @@ class _RepostPanelState extends State { ], ), if (_isMax) - Row( - children: [ - const SizedBox(width: 16), - SizedBox( - width: 34, - height: 34, - child: IconButton( - tooltip: '返回', - style: ButtonStyle( - padding: WidgetStateProperty.all(EdgeInsets.zero), - backgroundColor: - WidgetStateProperty.resolveWith((states) { - return Theme.of(context).colorScheme.secondaryContainer; - }), - ), - onPressed: Get.back, - icon: Icon( - Icons.arrow_back_outlined, - size: 18, - color: Theme.of(context).colorScheme.onSecondaryContainer, + SizedBox( + height: 34, + child: Stack( + children: [ + Positioned( + left: 16, + top: 0, + child: SizedBox( + width: 34, + height: 34, + child: IconButton( + tooltip: '返回', + style: ButtonStyle( + padding: WidgetStateProperty.all(EdgeInsets.zero), + backgroundColor: + WidgetStateProperty.resolveWith((states) { + return Theme.of(context) + .colorScheme + .secondaryContainer; + }), + ), + onPressed: Get.back, + icon: Icon( + Icons.arrow_back_outlined, + size: 18, + color: Theme.of(context) + .colorScheme + .onSecondaryContainer, + ), + ), ), ), - ), - const Spacer(), - const Text( - '转发动态', - style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), - ), - const Spacer(), - FilledButton.tonal( - onPressed: _onRepost, - style: FilledButton.styleFrom( - padding: const EdgeInsets.symmetric( - horizontal: 20, vertical: 10), - visualDensity: const VisualDensity( - horizontal: -2, - vertical: -2, + Center( + child: const Text( + '转发动态', + style: + TextStyle(fontSize: 15, fontWeight: FontWeight.bold), ), ), - child: const Text('转发'), - ), - const SizedBox(width: 16), - ], + Positioned( + right: 16, + top: 0, + child: FilledButton.tonal( + onPressed: _onRepost, + style: FilledButton.styleFrom( + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 10, + ), + visualDensity: const VisualDensity( + horizontal: -2, + vertical: -2, + ), + ), + child: const Text('转发'), + ), + ), + ], + ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), diff --git a/lib/pages/setting/sponsor_block_page.dart b/lib/pages/setting/sponsor_block_page.dart index f5381fca..95499400 100644 --- a/lib/pages/setting/sponsor_block_page.dart +++ b/lib/pages/setting/sponsor_block_page.dart @@ -451,32 +451,89 @@ class _SponsorBlockPageState extends State { ), ); }, - title: Text.rich( - TextSpan( - children: [ - WidgetSpan( - alignment: PlaceholderAlignment.middle, - child: Container( - height: MediaQuery.textScalerOf(context).scale(15), - width: 10, - alignment: Alignment.center, - child: Container( - height: 10, - width: 10, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: _blockColor[index], - ), - ), - ), - style: TextStyle(fontSize: 14), - ), + title: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text.rich( TextSpan( - text: ' ${_blockSettings[index].first.title}', - style: TextStyle(fontSize: 14), + children: [ + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: Container( + height: MediaQuery.textScalerOf(context).scale(15), + width: 10, + alignment: Alignment.center, + child: Container( + height: 10, + width: 10, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: _blockColor[index], + ), + ), + ), + style: TextStyle(fontSize: 14), + ), + TextSpan( + text: ' ${_blockSettings[index].first.title}', + style: TextStyle(fontSize: 14), + ), + ], ), - ], - ), + ), + PopupMenuButton( + initialValue: _blockSettings[index].second, + onSelected: (item) async { + _blockSettings[index].second = item; + await setting.put( + SettingBoxKey.blockSettings, + _blockSettings + .map((item) => item.second.index) + .toList()); + setState(() {}); + }, + itemBuilder: (context) => SkipType.values + .map((item) => PopupMenuItem( + value: item, + child: Text(item.title), + )) + .toList(), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + _blockSettings[index].second.title, + style: TextStyle( + height: 1, + fontSize: 14, + color: _blockSettings[index].second == + SkipType.disable + ? Theme.of(context) + .colorScheme + .outline + .withOpacity(0.7) + : Theme.of(context).colorScheme.secondary, + ), + strutStyle: StrutStyle(height: 1, leading: 0), + ), + Icon( + MdiIcons.unfoldMoreHorizontal, + 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, + ), + ], + ), + ), + ), + ], ), subtitle: Text( _blockSettings[index].first.description, @@ -487,48 +544,6 @@ class _SponsorBlockPageState extends State { : Theme.of(context).colorScheme.outline, ), ), - trailing: PopupMenuButton( - initialValue: _blockSettings[index].second, - onSelected: (item) async { - _blockSettings[index].second = item; - await setting.put(SettingBoxKey.blockSettings, - _blockSettings.map((item) => item.second.index).toList()); - setState(() {}); - }, - itemBuilder: (context) => SkipType.values - .map((item) => PopupMenuItem( - value: item, - child: Text(item.title), - )) - .toList(), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - _blockSettings[index].second.title, - style: TextStyle( - height: 1, - fontSize: 14, - color: - _blockSettings[index].second == SkipType.disable - ? Theme.of(context).colorScheme.error - : Theme.of(context).colorScheme.primary, - ), - strutStyle: StrutStyle(height: 1, leading: 0), - ), - Icon( - MdiIcons.unfoldMoreHorizontal, - size: MediaQuery.textScalerOf(context).scale(14), - color: _blockSettings[index].second == SkipType.disable - ? Theme.of(context).colorScheme.error - : Theme.of(context).colorScheme.primary, - ), - ], - ), - ), - ), ), separatorBuilder: (context, index) => Divider( height: 1, diff --git a/lib/pages/setting/widgets/model.dart b/lib/pages/setting/widgets/model.dart index 5b16f2fd..fe1f5756 100644 --- a/lib/pages/setting/widgets/model.dart +++ b/lib/pages/setting/widgets/model.dart @@ -7,6 +7,7 @@ import 'package:PiliPalaX/models/common/dynamics_type.dart'; import 'package:PiliPalaX/models/common/nav_bar_config.dart'; import 'package:PiliPalaX/models/common/rcmd_type.dart'; import 'package:PiliPalaX/models/common/reply_sort_type.dart'; +import 'package:PiliPalaX/models/common/theme_type.dart'; import 'package:PiliPalaX/models/common/up_panel_position.dart'; import 'package:PiliPalaX/models/video/play/CDN.dart'; import 'package:PiliPalaX/models/video/play/quality.dart'; @@ -348,31 +349,32 @@ List get styleSettings => [ ), ), ), - // SettingsModel( - // settingsType: SettingsType.normal, - // onTap: (setState) async { - // ThemeType? result = await showDialog( - // context: Get.context!, - // builder: (context) { - // return SelectDialog( - // title: '主题模式', - // value: GStorage.themeType, - // values: ThemeType.values.map( - // (e) { - // return {'title': e.description, 'value': e}; - // }, - // ).toList()); - // }, - // ); - // if (result != null) { - // GStorage.setting.put(SettingBoxKey.themeMode, result.index); - // Get.forceAppUpdate(); - // } - // }, - // leading: const Icon(Icons.flashlight_on_outlined), - // title: '主题模式', - // getSubtitle: () => '当前模式:${GStorage.themeType.description}', - // ), + SettingsModel( + settingsType: SettingsType.normal, + onTap: (setState) async { + ThemeType? result = await showDialog( + context: Get.context!, + builder: (context) { + return SelectDialog( + title: '主题模式', + value: GStorage.themeType, + values: ThemeType.values.map( + (e) { + return {'title': e.description, 'value': e}; + }, + ).toList()); + }, + ); + if (result != null) { + GStorage.setting.put(SettingBoxKey.themeMode, result.index); + Get.put(ColorSelectController()).themeType.value = result; + Get.forceAppUpdate(); + } + }, + leading: const Icon(Icons.flashlight_on_outlined), + title: '主题模式', + getSubtitle: () => '当前模式:${GStorage.themeType.description}', + ), SettingsModel( settingsType: SettingsType.normal, onTap: (setState) => Get.toNamed('/colorSetting'), diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 7b81b28d..170be27d 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -1538,7 +1538,7 @@ class VideoDetailController extends GetxController fontSize: 14, color: Theme.of(context) .colorScheme - .primary, + .secondary, ), strutStyle: StrutStyle( height: 1, @@ -1554,7 +1554,7 @@ class VideoDetailController extends GetxController .scale(14), color: Theme.of(context) .colorScheme - .primary, + .secondary, ), ], ), @@ -1605,7 +1605,7 @@ class VideoDetailController extends GetxController fontSize: 14, color: Theme.of(context) .colorScheme - .primary, + .secondary, ), strutStyle: StrutStyle( height: 1, @@ -1621,7 +1621,7 @@ class VideoDetailController extends GetxController .scale(14), color: Theme.of(context) .colorScheme - .primary, + .secondary, ), ], ),