feat: #30 动态默认展示某项
This commit is contained in:
@ -50,17 +50,21 @@ class DynamicsController extends GetxController {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
RxInt initialValue = 1.obs;
|
RxInt initialValue = 0.obs;
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
RxBool userLogin = false.obs;
|
RxBool userLogin = false.obs;
|
||||||
var userInfo;
|
var userInfo;
|
||||||
RxBool isLoadingDynamic = false.obs;
|
RxBool isLoadingDynamic = false.obs;
|
||||||
|
Box setting = GStrorage.setting;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
userInfo = userInfoCache.get('userInfoCache');
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
userLogin.value = userInfo != null;
|
userLogin.value = userInfo != null;
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
initialValue.value =
|
||||||
|
setting.get(SettingBoxKey.defaultDynamicType, defaultValue: 0);
|
||||||
|
dynamicsType = DynamicsType.values[initialValue.value].obs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future queryFollowDynamic({type = 'init'}) async {
|
Future queryFollowDynamic({type = 'init'}) async {
|
||||||
@ -99,7 +103,7 @@ class DynamicsController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSelectType(value) async {
|
onSelectType(value) async {
|
||||||
dynamicsType.value = filterTypeList[value - 1]['value'];
|
dynamicsType.value = filterTypeList[value]['value'];
|
||||||
dynamicsList.value = [DynamicItemModel()];
|
dynamicsList.value = [DynamicItemModel()];
|
||||||
page = 1;
|
page = 1;
|
||||||
initialValue.value = value;
|
initialValue.value = value;
|
||||||
@ -247,7 +251,7 @@ class DynamicsController extends GetxController {
|
|||||||
void resetSearch() {
|
void resetSearch() {
|
||||||
mid.value = -1;
|
mid.value = -1;
|
||||||
dynamicsType.value = DynamicsType.values[0];
|
dynamicsType.value = DynamicsType.values[0];
|
||||||
initialValue.value = 1;
|
initialValue.value = 0;
|
||||||
SmartDialog.showToast('还原默认加载');
|
SmartDialog.showToast('还原默认加载');
|
||||||
dynamicsList.value = [DynamicItemModel()];
|
dynamicsList.value = [DynamicItemModel()];
|
||||||
queryFollowDynamic();
|
queryFollowDynamic();
|
||||||
|
|||||||
@ -132,7 +132,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
initialValue:
|
initialValue:
|
||||||
_dynamicsController.initialValue.value,
|
_dynamicsController.initialValue.value,
|
||||||
children: {
|
children: {
|
||||||
1: Text(
|
0: Text(
|
||||||
'全部',
|
'全部',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: Theme.of(context)
|
fontSize: Theme.of(context)
|
||||||
@ -140,19 +140,19 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
.labelMedium!
|
.labelMedium!
|
||||||
.fontSize),
|
.fontSize),
|
||||||
),
|
),
|
||||||
2: Text('投稿',
|
1: Text('投稿',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: Theme.of(context)
|
fontSize: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.labelMedium!
|
.labelMedium!
|
||||||
.fontSize)),
|
.fontSize)),
|
||||||
3: Text('番剧',
|
2: Text('番剧',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: Theme.of(context)
|
fontSize: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.labelMedium!
|
.labelMedium!
|
||||||
.fontSize)),
|
.fontSize)),
|
||||||
4: Text('专栏',
|
3: Text('专栏',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: Theme.of(context)
|
fontSize: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/models/common/dynamics_type.dart';
|
||||||
import 'package:pilipala/models/common/reply_sort_type.dart';
|
import 'package:pilipala/models/common/reply_sort_type.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ class ExtraSetting extends StatefulWidget {
|
|||||||
class _ExtraSettingState extends State<ExtraSetting> {
|
class _ExtraSettingState extends State<ExtraSetting> {
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
late dynamic defaultReplySort;
|
late dynamic defaultReplySort;
|
||||||
|
late dynamic defaultDynamicType;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -22,6 +24,9 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
// 默认优先显示最新评论
|
// 默认优先显示最新评论
|
||||||
defaultReplySort =
|
defaultReplySort =
|
||||||
setting.get(SettingBoxKey.replySortType, defaultValue: 0);
|
setting.get(SettingBoxKey.replySortType, defaultValue: 0);
|
||||||
|
// 优先展示全部动态 all
|
||||||
|
defaultDynamicType =
|
||||||
|
setting.get(SettingBoxKey.defaultDynamicType, defaultValue: 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -67,6 +72,31 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
title: Text('动态展示', style: titleStyle),
|
||||||
|
subtitle: Text(
|
||||||
|
'当前优先展示「${DynamicsType.values[defaultDynamicType].labels}」',
|
||||||
|
style: subTitleStyle,
|
||||||
|
),
|
||||||
|
trailing: PopupMenuButton(
|
||||||
|
initialValue: defaultDynamicType,
|
||||||
|
icon: const Icon(Icons.more_vert_outlined, size: 22),
|
||||||
|
onSelected: (item) {
|
||||||
|
defaultDynamicType = item;
|
||||||
|
setting.put(SettingBoxKey.defaultDynamicType, item);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
||||||
|
for (var i in DynamicsType.values) ...[
|
||||||
|
PopupMenuItem(
|
||||||
|
value: i.index,
|
||||||
|
child: Text(i.labels),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
const SetSwitchItem(
|
const SetSwitchItem(
|
||||||
title: '检查更新',
|
title: '检查更新',
|
||||||
subTitle: '每次启动时检查是否需要更新',
|
subTitle: '每次启动时检查是否需要更新',
|
||||||
|
|||||||
@ -103,6 +103,7 @@ class SettingBoxKey {
|
|||||||
/// 其他
|
/// 其他
|
||||||
static const String autoUpdate = 'autoUpdate';
|
static const String autoUpdate = 'autoUpdate';
|
||||||
static const String replySortType = 'replySortType';
|
static const String replySortType = 'replySortType';
|
||||||
|
static const String defaultDynamicType = 'defaultDynamicType';
|
||||||
|
|
||||||
/// 外观
|
/// 外观
|
||||||
static const String themeMode = 'themeMode';
|
static const String themeMode = 'themeMode';
|
||||||
|
|||||||
Reference in New Issue
Block a user