123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- import 'package:ysairplane/code/YSCollection.dart';
- import 'package:ysairplane/code/YSFeedback.dart';
- import 'package:ysairplane/code/YSMoney.dart';
- import 'package:ysairplane/code/YSSetting.dart';
- import 'package:ysairplane/code/YSTabbar.dart';
- import 'package:ysairplane/code/YSUserInfo.dart';
- import 'package:ysairplane/code/YSVipCode.dart';
- import 'package:ysairplane/tools/YSNetWorking.dart';
- import 'package:ysairplane/tools/YSTools.dart';
- class YSMine extends StatefulWidget {
- @override
- _YSMineState createState() => _YSMineState();
- }
- class _YSMineState extends State<YSMine> with AutomaticKeepAliveClientMixin{
- Map _msgDict;
- @override
- // TODO: implement wantKeepAlive
- bool get wantKeepAlive => true;
- @override
- void initState() {
- Future.delayed(Duration(seconds: 0)).then((value){
- _getUserData();
- });
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- super.build(context);
- return Scaffold(
- backgroundColor: Color(0xFFF5F6F8),
- body: SingleChildScrollView(
- child: Column(
- children: [
- Container(
- height: MediaQuery.of(context).padding.top+200,
- width: MediaQuery.of(context).size.width,
- decoration: BoxDecoration(
- color: Color(0xFF00A8FF),
- // image: DecorationImage(
- // image: AssetImage('lib/images/top.png'),
- // fit: BoxFit.fill
- // ),
- ),
- child: Stack(
- children: [
- Container(
- margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+30,left: MediaQuery.of(context).size.width-50),
- child: Icon(Icons.settings,size: 25,color: Colors.white,),
- ),
- Container(
- margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+100,left: 20,right: 10),
- height: 70,
- width: 70,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(35))
- ),
- child: _msgDict!=null?ClipRRect(
- borderRadius: BorderRadius.all(Radius.circular(35)),
- child: CachedNetworkImage(
- imageUrl: '${_msgDict['avatar']}',
- fit: BoxFit.fill,
- ),
- ):Container(),
- ),
- Container(
- margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+110,left: 100),
- width: MediaQuery.of(context).size.width-150,
- child: Text(_msgDict!=null?'${_msgDict['nickname']}':'',style: TextStyle(fontSize: 18,color: Colors.white,fontWeight: FontWeight.bold),overflow: TextOverflow.ellipsis,),
- ),
- if(_msgDict!=null)Container(
- margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+145,left: 100),
- child: Row(
- children: [
- Container(
- child: Row(
- children: [
- Text(getSecretStr('${_msgDict['phoneNumber']}'),style: TextStyle(fontSize: 10,color: Colors.white),),
- Icon(Icons.keyboard_arrow_right,size: 15,color: Colors.white,),
- ],
- ),
- height: 20,
- alignment: Alignment.center,
- padding: EdgeInsets.only(left: 10,right: 5),
- decoration: BoxDecoration(
- color: Color(0xFF009DFF).withOpacity(0.6),
- borderRadius: BorderRadius.all(Radius.circular(10))
- ),
- ),
- // GestureDetector(
- // onTap: (){
- // Navigator.of(context,rootNavigator: true).push(
- // CupertinoPageRoute(
- // builder: (context){
- // return YSVipCode();
- // }
- // )
- // );
- // },
- // child: Container(
- // child: Row(
- // children: [
- // Icon(Icons.crop_square,size: 15,color: Colors.white,),
- // Text('会员码',style: TextStyle(fontSize: 10,color: Colors.white),),
- // ],
- // ),
- // height: 20,
- // alignment: Alignment.center,
- // margin: EdgeInsets.only(left: 5),
- // padding: EdgeInsets.only(left: 5,right: 10),
- // decoration: BoxDecoration(
- // color: Color(0xFF009DFF).withOpacity(0.6),
- // borderRadius: BorderRadius.all(Radius.circular(10))
- // ),
- // ),
- // )
- ],
- )
- ),
- GestureDetector(
- onTap: (){
- Navigator.of(context,rootNavigator: true).push(
- CupertinoPageRoute(
- builder: (context){
- return YSUserInfo();
- }
- )
- );
- },
- child: Container(
- margin: EdgeInsets.only(left: MediaQuery.of(context).size.width-50,top: MediaQuery.of(context).padding.top+120),
- child: Icon(Icons.keyboard_arrow_right,size: 30,color: Colors.white,),
- ),
- )
- ],
- ),
- ),
- Container(
- child: ListView.separated(
- shrinkWrap: true,
- itemBuilder: (context,index){
- return GestureDetector(
- onTap: (){
- if(index==1){
- ShowNotification(true).dispatch(context);
- }else{
- Navigator.of(context,rootNavigator: true).push(
- CupertinoPageRoute(
- builder: (context){
- return index==0?YSMoney():index==2?YSCollection():index==3?YSFeedback():YSSetting();
- }
- )
- );
- }
- },
- child: Container(
- height: 50,
- color: Colors.white,
- padding: EdgeInsets.only(left: 15,right: 15),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Row(
- children: [
- Container(
- child: Image.asset(index==0?'lib/images/money.png':index==1?'lib/images/travel.png':index==2?
- 'lib/images/collection.png':index==3?'lib/images/feedback.png':'lib/images/setting.png'),
- height: 20,
- width: 20,
- margin: EdgeInsets.only(right: 13),
- ),
- Text(index==0?'钱包':index==1?'行程':index==2?'收藏':index==3?'反馈':'设置',style: TextStyle(fontSize: 16,color: Color(0xFF000000)),)
- ],
- ),
- Icon(Icons.keyboard_arrow_right,size: 25,color: Color(0xFFCDCDCD),)
- ],
- ),
- ),
- );
- },
- separatorBuilder: (context,index){
- return Container(
- color: Color(0xFFF5F6F8),
- height: index==0||index==3?10:0.5,
- );
- },
- itemCount: 5,
- padding: EdgeInsets.all(0),
- physics: NeverScrollableScrollPhysics(),
- ),
- )
- ],
- ),
- ),
- );
- }
- _getUserData() async{
- SharedPreferences prefer = await SharedPreferences.getInstance();
- Map dict = await ysRequestHttp(context, type: requestType.get, api: '/app/applets/center/info', parameter: {},
- isLoading: false,refresh: (){},isToken: true);
- if(dict!=null){
- setState(() {
- _msgDict = dict['data'];
- prefer.setString('name', '${_msgDict['nickname']}');
- prefer.setString('phone', '${_msgDict['phoneNumber']}');
- prefer.setString('avatar', '${_msgDict['avatar']}');
- });
- }
- }
- }
|