mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-19 18:10:15 +08:00
refa: settings page
This commit is contained in:
@@ -4,12 +4,7 @@ import 'package:PiliPlus/http/login.dart';
|
||||
import 'package:PiliPlus/models/common/setting_type.dart';
|
||||
import 'package:PiliPlus/pages/about/view.dart';
|
||||
import 'package:PiliPlus/pages/login/controller.dart';
|
||||
import 'package:PiliPlus/pages/setting/extra_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/play_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/privacy_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/recommend_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/style_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/video_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/common_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/widgets/multi_select_dialog.dart';
|
||||
import 'package:PiliPlus/pages/webdav/view.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
@@ -43,6 +38,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
late SettingType _type = SettingType.privacySetting;
|
||||
final RxBool _noAccount = Accounts.account.isEmpty.obs;
|
||||
late bool _isPortrait;
|
||||
late ThemeData theme;
|
||||
|
||||
static const List<_SettingsModel> _items = [
|
||||
_SettingsModel(
|
||||
@@ -86,9 +82,15 @@ class _SettingPageState extends State<SettingPage> {
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
|
||||
theme = Theme.of(context);
|
||||
_isPortrait = MediaQuery.sizeOf(context).isPortrait;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(
|
||||
@@ -111,28 +113,20 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: switch (_type) {
|
||||
SettingType.privacySetting => const PrivacySetting(
|
||||
.privacySetting ||
|
||||
.recommendSetting ||
|
||||
.videoSetting ||
|
||||
.playSetting ||
|
||||
.styleSetting ||
|
||||
.extraSetting => CommonSetting(
|
||||
key: ValueKey(_type),
|
||||
settingType: _type,
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.recommendSetting => const RecommendSetting(
|
||||
.webdavSetting => const WebDavSettingPage(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.videoSetting => const VideoSetting(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.playSetting => const PlaySetting(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.styleSetting => const StyleSetting(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.extraSetting => const ExtraSetting(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.webdavSetting => const WebDavSettingPage(
|
||||
showAppBar: false,
|
||||
),
|
||||
SettingType.about => const AboutPage(showAppBar: false),
|
||||
.about => const AboutPage(showAppBar: false),
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -149,7 +143,18 @@ class _SettingPageState extends State<SettingPage> {
|
||||
|
||||
void _toPage(SettingType type) {
|
||||
if (_isPortrait) {
|
||||
Get.toNamed('/${type.name}');
|
||||
Get.to(
|
||||
() => switch (type) {
|
||||
.privacySetting ||
|
||||
.recommendSetting ||
|
||||
.videoSetting ||
|
||||
.playSetting ||
|
||||
.styleSetting ||
|
||||
.extraSetting => CommonSetting(settingType: type),
|
||||
.webdavSetting => const WebDavSettingPage(),
|
||||
.about => const AboutPage(),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
_type = type;
|
||||
setState(() {});
|
||||
|
||||
Reference in New Issue
Block a user