diff --git a/lib/pages/follow/child/child_controller.dart b/lib/pages/follow/child/child_controller.dart index 6afc7f4d7..acc0115c1 100644 --- a/lib/pages/follow/child/child_controller.dart +++ b/lib/pages/follow/child/child_controller.dart @@ -7,6 +7,9 @@ import 'package:PiliPlus/models_new/follow/data.dart'; import 'package:PiliPlus/models_new/follow/list.dart'; import 'package:PiliPlus/pages/common/common_list_controller.dart'; import 'package:PiliPlus/pages/follow/controller.dart'; +import 'package:PiliPlus/utils/storage.dart'; +import 'package:PiliPlus/utils/storage_key.dart'; +import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:get/get.dart'; class FollowChildController @@ -21,7 +24,12 @@ class FollowChildController late final Rx?>> sameState = LoadingState?>.loading().obs; - late final Rx orderType = FollowOrderType.def.obs; + late final Rx orderType = Pref.followOrderType.obs; + + void setOrderType(FollowOrderType type) { + orderType.value = type; + GStorage.setting.put(SettingBoxKey.followOrderType, type.index); + } @override void onInit() { diff --git a/lib/pages/follow/child/child_view.dart b/lib/pages/follow/child/child_view.dart index cf6c3edca..99ea35b23 100644 --- a/lib/pages/follow/child/child_view.dart +++ b/lib/pages/follow/child/child_view.dart @@ -84,10 +84,11 @@ class _FollowChildPageState extends State bottom: kFloatingActionButtonMargin + padding.bottom, child: FloatingActionButton.extended( onPressed: () => _followController - ..orderType.value = - _followController.orderType.value == FollowOrderType.def - ? FollowOrderType.attention - : FollowOrderType.def + ..setOrderType( + _followController.orderType.value == FollowOrderType.def + ? FollowOrderType.attention + : FollowOrderType.def, + ) ..onReload(), icon: const Icon(Icons.format_list_bulleted, size: 20), label: Obx(() => Text(_followController.orderType.value.title)), diff --git a/lib/utils/storage_key.dart b/lib/utils/storage_key.dart index 9e72e5f18..b603f4d5f 100644 --- a/lib/utils/storage_key.dart +++ b/lib/utils/storage_key.dart @@ -145,7 +145,8 @@ abstract class SettingBoxKey { enablePlayAll = 'enablePlayAll', enableTapDm = 'enableTapDm', setSystemBrightness = 'setSystemBrightness', - downloadPath = 'downloadPath'; + downloadPath = 'downloadPath', + followOrderType = 'followOrderType'; static const String minimizeOnExit = 'minimizeOnExit', windowSize = 'windowSize', diff --git a/lib/utils/storage_pref.dart b/lib/utils/storage_pref.dart index 1f771b1a4..2cca959d7 100644 --- a/lib/utils/storage_pref.dart +++ b/lib/utils/storage_pref.dart @@ -5,6 +5,7 @@ import 'package:PiliPlus/common/widgets/pair.dart'; import 'package:PiliPlus/http/constants.dart'; import 'package:PiliPlus/models/common/dynamic/dynamic_badge_mode.dart'; import 'package:PiliPlus/models/common/dynamic/up_panel_position.dart'; +import 'package:PiliPlus/models/common/follow_order_type.dart'; import 'package:PiliPlus/models/common/member/tab_type.dart'; import 'package:PiliPlus/models/common/msg/msg_unread_type.dart'; import 'package:PiliPlus/models/common/sponsor_block/segment_type.dart'; @@ -877,4 +878,10 @@ abstract class Pref { SettingBoxKey.showBatteryLevel, defaultValue: Utils.isMobile, ); + + static FollowOrderType get followOrderType => + FollowOrderType.values[_setting.get( + SettingBoxKey.followOrderType, + defaultValue: FollowOrderType.def.index, + )]; }