import 'package:flutter/material.dart'; import 'package:pikapika/basic/Common.dart'; import 'package:pikapika/basic/config/Themes.dart'; import 'package:pikapika/basic/config/Version.dart'; 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'; import 'SettingsScreen.dart'; import 'components/Badge.dart'; import 'components/UserProfileCard.dart'; // 个人空间页面 class SpaceScreen extends StatefulWidget { const SpaceScreen(); @override State createState() => _SpaceScreenState(); } class _SpaceScreenState extends State with AutomaticKeepAliveClientMixin { @override bool get wantKeepAlive => true; @override void initState() { versionEvent.subscribe(_onVersion); super.initState(); } @override void dispose() { versionEvent.unsubscribe(_onVersion); super.dispose(); } void _onVersion(dynamic a) { setState(() {}); } @override Widget build(BuildContext context) { super.build(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()), ); }, icon: Badged( child: Icon(Icons.info_outline), badge: latestVersion() == null ? null : "1", ), ), 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(), ], ), ); } }