| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- import 'package:flutter/material.dart';
- import 'package:redux/redux.dart';
- import 'package:flutter_redux/flutter_redux.dart';
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/cupertino.dart';
- import '../redux/AppState.dart';
- import '../model/UserInfo.dart';
- import '../pages/MyWallet.dart';
- import '../pages/BindGame.dart';
- import '../pages/RecordList.dart';
- import '../net/HttpManager.dart';
- import '../net/Result.dart';
- import '../redux/UserRedux.dart';
- import '../pages/UserChange.dart';
- import '../pages/RoomCardList.dart';
- import '../pages/MyTeam.dart';
- import '../pages/MyCode.dart';
- class HomeDrawer extends StatefulWidget {
- @override
- HomeDrawerState createState() => HomeDrawerState();
- }
- class HomeDrawerState extends State<HomeDrawer> {
- Future<void> getUserInfo() async {
- Result res = await HttpManager.get('userInfo/getUserInfo');
- if (res.success) {
- print(res.data);
- StoreProvider.of<AppState>(context)
- .dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
- } else {}
- }
- @override
- void initState() {
- super.initState();
- Future.delayed(Duration.zero, () => getUserInfo());
- }
- @override
- Widget build(BuildContext context) {
- return StoreConnector<AppState, UserInfo>(
- converter: (Store store) => store.state.userInfo,
- builder: (context, userInfo) {
- return Drawer(
- child: Container(
- // decoration: BoxDecoration(
- // gradient: LinearGradient(
- // begin: Alignment.bottomRight,
- // colors: [Color(0xFF3D3E6C), Color(0xFF626C85)],
- // )),
- color: Color(0xFF3A3E61),
- child: Column(
- children: <Widget>[
- Container(
- height: 210,
- padding: EdgeInsets.only(left: 35),
- decoration: BoxDecoration(color: Color(0x4D000000)),
- child: SafeArea(
- child: Row(
- // mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- ClipOval(
- child: InkWell(
- child: Image.network(
- userInfo.icon,
- width: 86,
- height: 86,
- fit: BoxFit.cover,
- ),
- onTap: () {
- Navigator.push(
- context,
- CupertinoPageRoute(
- builder: (context) => UserChange()));
- },
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 16),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- userInfo.nickname,
- style: TextStyle(
- fontSize: 27,
- color: Colors.white,
- fontWeight: FontWeight.w700),
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- margin: EdgeInsets.only(right: 4),
- child: SizedBox(
- width: 20,
- height: 20,
- child: Image.asset(
- 'images/icon_menpiao.png'),
- ),
- ),
- Text(
- userInfo.moneyTicket.toString(),
- style: TextStyle(
- fontSize: 16,
- color: Colors.white,
- fontWeight: FontWeight.w700),
- )
- ],
- ),
- ],
- ),
- )
- ],
- ),
- ),
- ),
- Expanded(
- flex: 1,
- child: Container(
- padding: EdgeInsets.only(top: 10),
- child: Column(
- children: <Widget>[
- DrawerMenu(
- 'images/icon_qianbao.png',
- '我的门票',
- onTap: () {
- Navigator.push(
- context,
- CupertinoPageRoute(
- builder: (context) => MyWallet()));
- },
- ),
- Divder(),
- DrawerMenu(
- 'images/icon_fangka.png',
- '房卡人数',
- tipValue: userInfo.houseCard,
- onTap: () {
- Navigator.push(
- context,
- CupertinoPageRoute(
- builder: (context) => RoomCardList()));
- },
- ),
- Divder(),
- DrawerMenu('images/icon_zhanji.png', '我的赛事', onTap: () {
- Navigator.push(
- context,
- CupertinoPageRoute(
- builder: (context) => RecordList()));
- }),
- Divder(),
- DrawerMenu(
- 'images/icon_bangding.png',
- '游戏绑定',
- onTap: () {
- Navigator.push(
- context,
- CupertinoPageRoute(
- builder: (context) => BindGame()));
- },
- ),
- Divder(),
- DrawerMenu(
- 'images/icon_tuandui.png',
- '我的团队',
- onTap: () {
- Navigator.push(
- context,
- CupertinoPageRoute(
- builder: (context) => MyTeam()));
- },
- ),
- Divder(),
- DrawerMenu(
- 'images/icon_tuiguangma.png',
- '我的推广码',
- onTap: () {
- Navigator.push(
- context,
- CupertinoPageRoute(
- builder: (context) => MyCode()));
- },
- )
- ],
- ),
- ),
- )
- ],
- ),
- ));
- },
- );
- }
- }
- typedef void OnDrawerMenuTap();
- class Divder extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return Container(
- height: 1,
- padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
- child: Container(
- decoration: BoxDecoration(color: Color(0x2E000000)),
- ),
- );
- }
- }
- class DrawerMenu extends StatelessWidget {
- final String icon;
- final String title;
- final OnDrawerMenuTap onTap;
- final num tipValue;
- DrawerMenu(this.icon, this.title, {this.onTap, this.tipValue});
- @override
- Widget build(BuildContext context) {
- return Container(
- height: 60,
- padding: EdgeInsets.fromLTRB(30, 0, 28, 0),
- child: GestureDetector(
- onTap: onTap,
- child: Row(
- children: <Widget>[
- Image.asset(icon),
- Expanded(
- flex: 1,
- child: Container(
- margin: EdgeInsets.only(left: 16),
- child: Text(
- title,
- style: TextStyle(
- color: Colors.white,
- fontSize: 15,
- fontWeight: FontWeight.w700),
- ),
- ),
- ),
- tipValue != null
- ? Text(
- tipValue.toString(),
- style: TextStyle(fontSize: 13, color: Theme.of(context).primaryColor),
- )
- : Container(),
- Image.asset('images/icon_inter.png')
- ],
- ),
- ),
- );
- }
- }
|