feat: 自定义列数

This commit is contained in:
guozhigq
2023-10-04 23:15:46 +08:00
parent d83b4bc59e
commit 692d596818
6 changed files with 70 additions and 45 deletions

View File

@ -287,23 +287,18 @@ class VideoStat extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return RichText(
children: [ maxLines: 1,
Text( text: TextSpan(
'${videoItem.stat.view}观看', style: TextStyle(
style: TextStyle( fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, color: Theme.of(context).colorScheme.outline,
color: Theme.of(context).colorScheme.outline,
),
), ),
Text( children: [
'${videoItem.stat.danmu}弹幕', TextSpan(text: '${videoItem.stat.view}观看'),
style: TextStyle( TextSpan(text: '${videoItem.stat.danmu}弹幕'),
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, ],
color: Theme.of(context).colorScheme.outline, ),
),
),
],
); );
} }
} }

View File

@ -20,7 +20,7 @@ class LiveController extends GetxController {
void onInit() { void onInit() {
super.onInit(); super.onInit();
crossAxisCount.value = crossAxisCount.value =
setting.get(SettingBoxKey.enableSingleRow, defaultValue: false) ? 1 : 2; setting.get(SettingBoxKey.customRows, defaultValue: 2);
} }
// 获取推荐 // 获取推荐

View File

@ -120,15 +120,18 @@ class LiveContent extends StatelessWidget {
if (crossAxisCount == 1) const SizedBox(height: 4), if (crossAxisCount == 1) const SizedBox(height: 4),
Row( Row(
children: [ children: [
Text( Expanded(
liveItem.uname, child: Text(
textAlign: TextAlign.start, liveItem.uname,
style: TextStyle( textAlign: TextAlign.start,
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, style: TextStyle(
color: Theme.of(context).colorScheme.outline, 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) ...[ if (crossAxisCount == 1) ...[
Text( Text(
@ -169,7 +172,7 @@ class VideoStat extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
height: 50, 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( decoration: const BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.topCenter, begin: Alignment.topCenter,
@ -181,18 +184,17 @@ class VideoStat extends StatelessWidget {
tileMode: TileMode.mirror, tileMode: TileMode.mirror,
), ),
), ),
child: Row( child: RichText(
mainAxisAlignment: MainAxisAlignment.spaceBetween, maxLines: 1,
children: [ textAlign: TextAlign.justify,
Text( softWrap: false,
liveItem!.areaName!, text: TextSpan(
style: const TextStyle(fontSize: 11, color: Colors.white), style: const TextStyle(fontSize: 11, color: Colors.white),
), children: [
Text( TextSpan(text: liveItem!.areaName!),
liveItem!.watchedShow!['text_small'], TextSpan(text: liveItem!.watchedShow!['text_small']),
style: const TextStyle(fontSize: 11, color: Colors.white), ],
), ),
],
), ),
); );
} }

View File

@ -20,7 +20,7 @@ class RcmdController extends GetxController {
void onInit() { void onInit() {
super.onInit(); super.onInit();
crossAxisCount.value = crossAxisCount.value =
setting.get(SettingBoxKey.enableSingleRow, defaultValue: false) ? 1 : 2; setting.get(SettingBoxKey.customRows, defaultValue: 2);
if (recVideo.get('cacheList') != null && if (recVideo.get('cacheList') != null &&
recVideo.get('cacheList').isNotEmpty) { recVideo.get('cacheList').isNotEmpty) {
List<RecVideoItemAppModel> list = []; List<RecVideoItemAppModel> list = [];

View File

@ -22,12 +22,14 @@ class _StyleSettingState extends State<StyleSetting> {
Box setting = GStrorage.setting; Box setting = GStrorage.setting;
late int picQuality; late int picQuality;
late ThemeType _tempThemeValue; late ThemeType _tempThemeValue;
late dynamic defaultCustomRows;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
picQuality = setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10); picQuality = setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
_tempThemeValue = settingController.themeType.value; _tempThemeValue = settingController.themeType.value;
defaultCustomRows = setting.get(SettingBoxKey.customRows, defaultValue: 2);
} }
@override @override
@ -76,12 +78,37 @@ class _StyleSettingState extends State<StyleSetting> {
setKey: SettingBoxKey.iosTransition, setKey: SettingBoxKey.iosTransition,
defaultVal: false, defaultVal: false,
), ),
SetSwitchItem( // SetSwitchItem(
title: '首页单列', // title: '首页单列',
subTitle: '每行展示一个内容卡片', // subTitle: '每行展示一个内容卡片',
setKey: SettingBoxKey.enableSingleRow, // setKey: SettingBoxKey.enableSingleRow,
defaultVal: false, // defaultVal: false,
callFn: (val) => {SmartDialog.showToast('下次启动时生效')}, // 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) => <PopupMenuEntry>[
for (var i in [1, 2, 3, 4, 5]) ...[
PopupMenuItem(
value: i,
child: Text(i.toString()),
),
]
],
),
), ),
ListTile( ListTile(
dense: false, dense: false,

View File

@ -132,6 +132,7 @@ class SettingBoxKey {
static const String customColor = 'customColor'; // 自定义主题色 static const String customColor = 'customColor'; // 自定义主题色
static const String iosTransition = 'iosTransition'; // ios路由 static const String iosTransition = 'iosTransition'; // ios路由
static const String enableSingleRow = 'enableSingleRow'; // 首页单列 static const String enableSingleRow = 'enableSingleRow'; // 首页单列
static const String customRows = 'customRows'; // 自定义列
} }
class LocalCacheKey { class LocalCacheKey {