123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- import 'package:flutter/material.dart';
- import 'package:flutter_habit/common/I18N.dart';
- import 'package:flutter_habit/common/components/PopMenus.dart';
- import 'package:flutter_habit/provider/DataProvider.dart';
- import 'package:flutter_habit/provider/UserProvider.dart';
- import 'package:flutter_habit/view/drawer/community/FollowedPage.dart';
- import 'package:flutter_habit/view/drawer/community/RankingListPage.dart';
- import 'package:flutter_habit/view/drawer/community/SearchUserPage.dart';
- import 'package:flutter_habit/view/drawer/setting/SettingPage.dart';
- import 'package:flutter_habit/view/drawer/shop/ShopPage.dart';
- import 'package:flutter_habit/view/drawer/user/UserPage.dart';
- import 'package:provider/provider.dart';
- class HomePageDrawer extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- UserProvider userProvider = Provider.of<UserProvider>(context);
- DataProvider dataProvider = Provider.of<DataProvider>(context);
- return Drawer(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Container(
- color: Theme.of(context).primaryColor,
- padding: EdgeInsets.only(top: 36, bottom: 10, left: 16, right: 16),
- child: Column(
- children: <Widget>[
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- I18N.of("欢迎"),
- style: Theme.of(context).textTheme.displayLarge!.copyWith(
- color: Theme.of(context).colorScheme.onPrimary),
- ),
- Text(
- I18N.of("来到"),
- style: TextStyle(
- color: Theme.of(context).colorScheme.onPrimary),
- ),
- Text(
- "Habit",
- style: Theme.of(context)
- .textTheme
- .titleLarge!
- .copyWith(
- color: Theme.of(context).colorScheme.onPrimary),
- ),
- ],
- ),
- Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- userProvider.photo == null
- ? Icon(
- Icons.account_circle,
- size: 70,
- color: Theme.of(context).colorScheme.onPrimary,
- )
- : ClipOval(
- child: Image.memory(
- userProvider.photo!,
- width: 70,
- height: 70,
- ),
- ),
- Container(height: 10),
- Text(
- userProvider.userName != null &&
- userProvider.userName != null
- ? userProvider.userName!
- : I18N.of("未登录"),
- style: TextStyle(
- color: Theme.of(context).colorScheme.onPrimary),
- ),
- Row(
- children: <Widget>[
- Text(
- "${I18N.of("今日状态")}: ",
- style: Theme.of(context)
- .textTheme
- .titleMedium!
- .copyWith(
- color: Theme.of(context)
- .colorScheme
- .onPrimary),
- ),
- Icon(
- dataProvider.todayEvaluate <= 4
- ? Icons.sentiment_dissatisfied
- : dataProvider.todayEvaluate <= 9
- ? Icons.sentiment_neutral
- : Icons.sentiment_satisfied,
- color: Theme.of(context).colorScheme.onPrimary,
- size: 20,
- )
- ],
- ),
- ],
- ),
- ],
- ),
- ],
- ),
- ),
- Expanded(
- flex: 3,
- child: Column(
- children: <Widget>[
- ListTile(
- leading: Icon(Icons.account_box),
- title: Text(I18N.of("用户")),
- onTap: () {
- Navigator.of(context).pop();
- Navigator.of(context)
- .push(MaterialPageRoute(builder: (_) => UserPage()));
- },
- ),
- ListTile(
- leading: Icon(Icons.trending_up),
- title: Text(I18N.of("排行榜")),
- onTap: () {
- Navigator.of(context).pop();
- Navigator.of(context).push(
- MaterialPageRoute(builder: (_) => RankingListPage()));
- },
- ),
- userProvider.token == null
- ? Container()
- : ListTile(
- leading: Icon(Icons.face),
- title: Text(I18N.of("我的关注")),
- onTap: () {
- Navigator.of(context).pop();
- Navigator.of(context).push(MaterialPageRoute(
- builder: (_) => FollowedPage()));
- },
- ),
- userProvider.token == null
- ? Container()
- : ListTile(
- leading: Icon(Icons.search),
- title: Text(I18N.of("搜索用户")),
- onTap: () {
- Navigator.of(context).pop();
- Navigator.of(context).push(MaterialPageRoute(
- builder: (_) => SearchUserPage()));
- },
- ),
- ListTile(
- leading: Icon(Icons.store),
- title: Text(I18N.of("商城")),
- onTap: () {
- Navigator.of(context).pop();
- Navigator.of(context)
- .push(MaterialPageRoute(builder: (_) => ShopPage()));
- },
- ),
- ListTile(
- leading: Icon(Icons.settings),
- title: Text(I18N.of("设置")),
- onTap: () async {
- Navigator.of(context).pop();
- await Navigator.of(context)
- .push(MaterialPageRoute(builder: (_) => SettingPage()));
- },
- ),
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: 5),
- child: InkWell(
- child: Text(
- "@2020 ZXZhang All rights reserved.",
- style: Theme.of(context).textTheme.bodySmall,
- ),
- onTap: () {
- PopMenus.baseMenu(
- context: context,
- title: Text("About"),
- children: <Widget>[
- Padding(
- padding: EdgeInsets.all(25),
- child: Text(
- "本软件由张子玄独立设计、开发完成\n移动端使用Flutter开发\n后端使用SpringBoot开发\n使用docker在阿里云部署",
- ),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: 10),
- child: Center(
- child: Text(
- "@2020 ZXZhang All rights reserved.",
- style: Theme.of(context).textTheme.bodySmall,
- ),
- ),
- ),
- ],
- );
- },
- )),
- ],
- ),
- );
- }
- }
|