pikapika/lib/screens/SpaceScreen.dart

149 lines
4.3 KiB
Dart
Raw Normal View History

2021-09-29 23:57:09 +00:00
import 'package:flutter/material.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/Common.dart';
2023-04-12 09:48:48 +00:00
import 'package:pikapika/basic/config/HiddenFdIcon.dart';
2021-11-11 09:05:48 +00:00
import 'package:pikapika/basic/config/Version.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/screens/AboutScreen.dart';
import 'package:pikapika/screens/AccountScreen.dart';
import 'package:pikapika/screens/DownloadListScreen.dart';
import 'package:pikapika/screens/FavouritePaperScreen.dart';
2022-07-09 07:11:26 +00:00
import 'package:pikapika/screens/ProScreen.dart';
2022-03-23 10:51:38 +00:00
import 'package:pikapika/screens/ThemeScreen.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/screens/ViewLogsScreen.dart';
import 'package:pikapika/basic/Method.dart';
2021-09-29 23:57:09 +00:00
2023-01-31 10:50:51 +00:00
import '../basic/config/IconLoading.dart';
2022-07-09 07:11:26 +00:00
import '../basic/config/IsPro.dart';
2022-03-23 10:51:38 +00:00
import '../basic/config/Themes.dart';
2021-09-29 23:57:09 +00:00
import 'SettingsScreen.dart';
2021-11-11 09:05:48 +00:00
import 'components/Badge.dart';
2021-09-29 23:57:09 +00:00
import 'components/UserProfileCard.dart';
// 个人空间页面
class SpaceScreen extends StatefulWidget {
2022-03-17 03:31:25 +00:00
const SpaceScreen({Key? key}) : super(key: key);
2021-09-29 23:57:09 +00:00
@override
State<StatefulWidget> createState() => _SpaceScreenState();
}
2021-11-29 03:26:30 +00:00
class _SpaceScreenState extends State<SpaceScreen> {
2021-09-29 23:57:09 +00:00
@override
void initState() {
2022-07-09 07:11:26 +00:00
versionEvent.subscribe(_onEvent);
proEvent.subscribe(_onEvent);
2023-04-12 09:48:48 +00:00
hiddenFdIconEvent.subscribe(_onEvent);
2021-09-29 23:57:09 +00:00
super.initState();
}
2021-11-11 09:05:48 +00:00
@override
void dispose() {
2022-07-09 07:11:26 +00:00
versionEvent.unsubscribe(_onEvent);
proEvent.unsubscribe(_onEvent);
2023-04-12 09:48:48 +00:00
hiddenFdIconEvent.unsubscribe(_onEvent);
2021-11-11 09:05:48 +00:00
super.dispose();
}
2022-07-09 07:11:26 +00:00
void _onEvent(dynamic a) {
2021-11-11 09:05:48 +00:00
setState(() {});
}
2021-09-29 23:57:09 +00:00
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
2022-03-23 10:51:38 +00:00
title: const Text('我的'),
2021-09-29 23:57:09 +00:00
actions: [
IconButton(
onPressed: () async {
bool result =
2023-04-12 09:48:48 +00:00
await confirmDialog(context, '退出登录', '您确认要退出当前账号吗?');
2021-09-29 23:57:09 +00:00
if (result) {
await method.clearToken();
await method.setPassword("");
Navigator.pushReplacement(
context,
2023-04-12 09:48:48 +00:00
mixRoute(builder: (context) => const AccountScreen()),
2021-09-29 23:57:09 +00:00
);
}
},
2022-03-17 03:31:25 +00:00
icon: const Icon(Icons.exit_to_app),
2021-09-29 23:57:09 +00:00
),
IconButton(
onPressed: () {
Navigator.push(
context,
2023-01-31 10:50:51 +00:00
mixRoute(builder: (context) => const AboutScreen()),
2021-09-29 23:57:09 +00:00
);
},
2021-11-11 09:05:48 +00:00
icon: Badged(
2022-03-17 03:31:25 +00:00
child: const Icon(Icons.info_outline),
2021-11-11 09:05:48 +00:00
badge: latestVersion() == null ? null : "1",
),
2021-09-29 23:57:09 +00:00
),
2023-04-12 09:48:48 +00:00
...hiddenFdIcon
? []
: [
IconButton(
onPressed: () {
Navigator.of(context)
.push(mixRoute(builder: (BuildContext context) {
return const ProScreen();
}));
},
icon: Icon(
isPro ? Icons.offline_bolt : Icons.offline_bolt_outlined,
),
),
],
2021-09-29 23:57:09 +00:00
IconButton(
onPressed: () {
Navigator.push(
context,
2023-01-31 10:50:51 +00:00
mixRoute(builder: (context) => const SettingsScreen()),
2021-09-29 23:57:09 +00:00
);
},
2022-03-17 03:31:25 +00:00
icon: const Icon(Icons.settings),
2021-09-29 23:57:09 +00:00
),
],
),
body: ListView(
children: [
2022-03-17 03:31:25 +00:00
const Divider(),
const UserProfileCard(),
const Divider(),
2021-09-29 23:57:09 +00:00
ListTile(
onTap: () {
Navigator.push(
context,
2023-04-12 09:48:48 +00:00
mixRoute(builder: (context) => const FavouritePaperScreen()),
2021-09-29 23:57:09 +00:00
);
},
2022-03-23 10:51:38 +00:00
title: const Text('我的收藏'),
2021-09-29 23:57:09 +00:00
),
2022-03-17 03:31:25 +00:00
const Divider(),
2021-09-29 23:57:09 +00:00
ListTile(
onTap: () {
Navigator.push(
context,
2023-01-31 10:50:51 +00:00
mixRoute(builder: (context) => const ViewLogsScreen()),
2021-09-29 23:57:09 +00:00
);
},
2022-03-23 10:51:38 +00:00
title: const Text('浏览记录'),
2021-09-29 23:57:09 +00:00
),
2022-03-17 03:31:25 +00:00
const Divider(),
2021-09-29 23:57:09 +00:00
ListTile(
onTap: () {
Navigator.push(
context,
2023-04-12 09:48:48 +00:00
mixRoute(builder: (context) => const DownloadListScreen()),
2021-09-29 23:57:09 +00:00
);
},
2022-03-17 03:31:25 +00:00
title: const Text('我的下载'),
2021-09-29 23:57:09 +00:00
),
2022-03-17 03:31:25 +00:00
const Divider(),
2021-09-29 23:57:09 +00:00
],
),
);
}
}