From 692d596818d32c86d596f887ea5e72ac8105a660 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 4 Oct 2023 23:15:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E5=88=97?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/widgets/video_card_v.dart | 27 +++++++--------- lib/pages/live/controller.dart | 2 +- lib/pages/live/widgets/live_item.dart | 44 ++++++++++++++------------- lib/pages/rcmd/controller.dart | 2 +- lib/pages/setting/style_setting.dart | 39 ++++++++++++++++++++---- lib/utils/storage.dart | 1 + 6 files changed, 70 insertions(+), 45 deletions(-) diff --git a/lib/common/widgets/video_card_v.dart b/lib/common/widgets/video_card_v.dart index 9e34cbcb..04f6ee3f 100644 --- a/lib/common/widgets/video_card_v.dart +++ b/lib/common/widgets/video_card_v.dart @@ -287,23 +287,18 @@ class VideoStat extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( - children: [ - Text( - '${videoItem.stat.view}观看', - style: TextStyle( - fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, - color: Theme.of(context).colorScheme.outline, - ), + return RichText( + maxLines: 1, + text: TextSpan( + style: TextStyle( + fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, + color: Theme.of(context).colorScheme.outline, ), - Text( - ' • ${videoItem.stat.danmu}弹幕', - style: TextStyle( - fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, - color: Theme.of(context).colorScheme.outline, - ), - ), - ], + children: [ + TextSpan(text: '${videoItem.stat.view}观看'), + TextSpan(text: ' • ${videoItem.stat.danmu}弹幕'), + ], + ), ); } } diff --git a/lib/pages/live/controller.dart b/lib/pages/live/controller.dart index 28c34f3e..6a26f0d2 100644 --- a/lib/pages/live/controller.dart +++ b/lib/pages/live/controller.dart @@ -20,7 +20,7 @@ class LiveController extends GetxController { void onInit() { super.onInit(); crossAxisCount.value = - setting.get(SettingBoxKey.enableSingleRow, defaultValue: false) ? 1 : 2; + setting.get(SettingBoxKey.customRows, defaultValue: 2); } // 获取推荐 diff --git a/lib/pages/live/widgets/live_item.dart b/lib/pages/live/widgets/live_item.dart index 6160d721..8fa797fb 100644 --- a/lib/pages/live/widgets/live_item.dart +++ b/lib/pages/live/widgets/live_item.dart @@ -120,15 +120,18 @@ class LiveContent extends StatelessWidget { if (crossAxisCount == 1) const SizedBox(height: 4), Row( children: [ - Text( - liveItem.uname, - textAlign: TextAlign.start, - style: TextStyle( - fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, - color: Theme.of(context).colorScheme.outline, + Expanded( + child: Text( + liveItem.uname, + textAlign: TextAlign.start, + style: TextStyle( + fontSize: + Theme.of(context).textTheme.labelMedium!.fontSize, + color: Theme.of(context).colorScheme.outline, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, ), - maxLines: 1, - overflow: TextOverflow.ellipsis, ), if (crossAxisCount == 1) ...[ Text( @@ -169,7 +172,7 @@ class VideoStat extends StatelessWidget { Widget build(BuildContext context) { return Container( height: 50, - padding: const EdgeInsets.only(top: 22, left: 10, right: 10), + padding: const EdgeInsets.only(top: 26, left: 10, right: 10), decoration: const BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, @@ -181,18 +184,17 @@ class VideoStat extends StatelessWidget { tileMode: TileMode.mirror, ), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - liveItem!.areaName!, - style: const TextStyle(fontSize: 11, color: Colors.white), - ), - Text( - liveItem!.watchedShow!['text_small'], - style: const TextStyle(fontSize: 11, color: Colors.white), - ), - ], + child: RichText( + maxLines: 1, + textAlign: TextAlign.justify, + softWrap: false, + text: TextSpan( + style: const TextStyle(fontSize: 11, color: Colors.white), + children: [ + TextSpan(text: liveItem!.areaName!), + TextSpan(text: liveItem!.watchedShow!['text_small']), + ], + ), ), ); } diff --git a/lib/pages/rcmd/controller.dart b/lib/pages/rcmd/controller.dart index f3acb67d..52c112af 100644 --- a/lib/pages/rcmd/controller.dart +++ b/lib/pages/rcmd/controller.dart @@ -20,7 +20,7 @@ class RcmdController extends GetxController { void onInit() { super.onInit(); crossAxisCount.value = - setting.get(SettingBoxKey.enableSingleRow, defaultValue: false) ? 1 : 2; + setting.get(SettingBoxKey.customRows, defaultValue: 2); if (recVideo.get('cacheList') != null && recVideo.get('cacheList').isNotEmpty) { List list = []; diff --git a/lib/pages/setting/style_setting.dart b/lib/pages/setting/style_setting.dart index c502beeb..9151d79d 100644 --- a/lib/pages/setting/style_setting.dart +++ b/lib/pages/setting/style_setting.dart @@ -22,12 +22,14 @@ class _StyleSettingState extends State { Box setting = GStrorage.setting; late int picQuality; late ThemeType _tempThemeValue; + late dynamic defaultCustomRows; @override void initState() { super.initState(); picQuality = setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10); _tempThemeValue = settingController.themeType.value; + defaultCustomRows = setting.get(SettingBoxKey.customRows, defaultValue: 2); } @override @@ -76,12 +78,37 @@ class _StyleSettingState extends State { setKey: SettingBoxKey.iosTransition, defaultVal: false, ), - SetSwitchItem( - title: '首页单列', - subTitle: '每行展示一个内容卡片', - setKey: SettingBoxKey.enableSingleRow, - defaultVal: false, - callFn: (val) => {SmartDialog.showToast('下次启动时生效')}, + // SetSwitchItem( + // title: '首页单列', + // subTitle: '每行展示一个内容卡片', + // setKey: SettingBoxKey.enableSingleRow, + // defaultVal: false, + // callFn: (val) => {SmartDialog.showToast('下次启动时生效')}, + // ), + ListTile( + dense: false, + title: Text('自定义列数', style: titleStyle), + subtitle: Text( + '当前列数', + style: subTitleStyle, + ), + trailing: PopupMenuButton( + initialValue: defaultCustomRows, + icon: const Icon(Icons.more_vert_outlined, size: 22), + onSelected: (item) { + defaultCustomRows = item; + setting.put(SettingBoxKey.customRows, item); + setState(() {}); + }, + itemBuilder: (BuildContext context) => [ + for (var i in [1, 2, 3, 4, 5]) ...[ + PopupMenuItem( + value: i, + child: Text(i.toString()), + ), + ] + ], + ), ), ListTile( dense: false, diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 605530b7..b6c71a3e 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -132,6 +132,7 @@ class SettingBoxKey { static const String customColor = 'customColor'; // 自定义主题色 static const String iosTransition = 'iosTransition'; // ios路由 static const String enableSingleRow = 'enableSingleRow'; // 首页单列 + static const String customRows = 'customRows'; // 自定义列 } class LocalCacheKey {