pikapika/lib/screens/SpaceScreen.dart

138 lines
3.7 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';
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 {
const SpaceScreen();
@override
State<StatefulWidget> createState() => _SpaceScreenState();
}
2021-11-26 03:06:20 +00:00
class _SpaceScreenState extends State<SpaceScreen>
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
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()),
);
}
},
icon: Icon(Icons.exit_to_app),
),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AboutScreen()),
);
},
2021-11-11 09:05:48 +00:00
icon: Badged(
child: Icon(Icons.info_outline),
badge: latestVersion() == null ? null : "1",
),
2021-09-29 23:57:09 +00:00
),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SettingsScreen()),
);
},
icon: Icon(Icons.settings),
),
],
),
body: ListView(
children: [
Divider(),
UserProfileCard(),
Divider(),
ListTile(
onTap: () async {
await chooseTheme(context);
setState(() {});
},
title: Text('主题'),
subtitle: Text(currentThemeName()),
),
Divider(),
ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => FavouritePaperScreen()),
);
},
title: Text('我的收藏'),
),
Divider(),
ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ViewLogsScreen()),
);
},
title: Text('浏览记录'),
),
Divider(),
ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => DownloadListScreen()),
);
},
title: Text('我的下载'),
),
Divider(),
],
),
);
}
}