pikapika/lib/screens/SpaceScreen.dart

136 lines
3.7 KiB
Dart
Raw Permalink 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';
import 'package:pikapika/basic/config/Themes.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';
import 'package:pikapika/screens/ViewLogsScreen.dart';
import 'package:pikapika/basic/Method.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-11-11 09:05:48 +00:00
2021-09-29 23:57:09 +00:00
@override
void initState() {
2021-11-11 09:05:48 +00:00
versionEvent.subscribe(_onVersion);
2021-09-29 23:57:09 +00:00
super.initState();
}
2021-11-11 09:05:48 +00:00
@override
void dispose() {
versionEvent.unsubscribe(_onVersion);
super.dispose();
}
void _onVersion(dynamic a) {
setState(() {});
}
2021-09-29 23:57:09 +00:00
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('我的'),
actions: [
IconButton(
onPressed: () async {
bool result =
await confirmDialog(context, '退出登录', '您确认要退出当前账号吗?');
if (result) {
await method.clearToken();
await method.setPassword("");
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => AccountScreen()),
);
}
},
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,
2022-03-17 03:31:25 +00:00
MaterialPageRoute(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
),
IconButton(
onPressed: () {
Navigator.push(
context,
2022-03-17 03:31:25 +00:00
MaterialPageRoute(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: () async {
await chooseTheme(context);
setState(() {});
},
title: Text('主题'),
subtitle: Text(currentThemeName()),
),
2022-03-17 03:31:25 +00:00
const Divider(),
2021-09-29 23:57:09 +00:00
ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => FavouritePaperScreen()),
);
},
title: Text('我的收藏'),
),
2022-03-17 03:31:25 +00:00
const Divider(),
2021-09-29 23:57:09 +00:00
ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ViewLogsScreen()),
);
},
title: Text('浏览记录'),
),
2022-03-17 03:31:25 +00:00
const Divider(),
2021-09-29 23:57:09 +00:00
ListTile(
onTap: () {
Navigator.push(
context,
2022-03-17 03:31:25 +00:00
MaterialPageRoute(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
],
),
);
}
}