panhui 6 жил өмнө
parent
commit
9e199d7b5f

+ 2 - 1
lib/main.dart

@@ -16,7 +16,8 @@ CountState updateState(CountState state, dynamic value){
   return CountState(state.usetoken=value['val']);
  }
  else if(value['action']==Actions.updateUser){
-   return CountState(state.userInfo=value['val']);
+   state.userInfo=value['val'];
+   return state;
  }
  else if (value['action']==Actions.updateAll){
    

+ 137 - 0
lib/pages/changeUserInfo.dart

@@ -0,0 +1,137 @@
+import 'package:flutter/material.dart';
+import '../styles/colors.dart';
+import 'dart:ui';
+import '../styles/totast.dart';
+import '../widget/ITextInput.dart';
+import 'package:flutter_redux/flutter_redux.dart';
+import '../state.dart';
+import 'package:dio/dio.dart';
+import 'dart:convert';
+import '../styles/api.dart';
+import '../styles/totast.dart';
+
+class ChangeUserInfo extends StatefulWidget {
+  ChangeUserInfo({Key key, this.title}) : super(key: key);
+  final String title; // 用来储存传递过来的值
+  @override
+  ChangeUserInfoState createState() => ChangeUserInfoState();
+}
+
+class ChangeUserInfoState extends State<ChangeUserInfo> {
+  Map userInfo = {};
+  String changeText = '';
+  String changekey = 'nickname';
+  @override
+  void didChangeDependencies() {
+    // TODO: implement didChangeDependencies
+    super.didChangeDependencies();
+    userInfo = StoreProvider.of<CountState>(context).state.userInfo;
+    switch (widget.title) {
+      case '昵称':
+        changekey = 'nickname';
+        break;
+      case '手机号':
+        changekey = 'phone';
+        break;
+    }
+    changeText = userInfo.containsKey(changekey) ? userInfo[changekey] : '';
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return new WillPopScope(
+        child: Scaffold(
+            appBar: AppBar(
+              backgroundColor: PRIMARY_COLOR,
+              title: Text('修改' + widget.title),
+              centerTitle: true,
+              elevation: 0,
+            ),
+            body: Container(
+              padding: EdgeInsets.symmetric(vertical: 30, horizontal: 15),
+              color: BG_COLOR,
+              child: Column(
+                children: <Widget>[
+                  Container(
+                    child: ITextField(
+                      autofocus: true,
+                      inputText: changeText,
+                      maxLength: 15,
+                      hintText: '输入用户昵称',
+                      hintStyle: TextStyle(
+                        fontSize: 16,
+                        color: Color(0xFF727785),
+                      ),
+                      textStyle: TextStyle(
+                          color: Colors.white,
+                          fontSize: 18,
+                          fontWeight: FontWeight.w500),
+                      fieldCallBack: (content) {
+                        setState(() {
+                          changeText = content;
+                        });
+                      },
+                      counterStyle: TextStyle(color: BG_SUB_COLOR, fontSize: 0),
+                    ),
+                  ),
+                  Container(
+                    margin: EdgeInsets.only(top: 30),
+                    width: double.infinity,
+                    height: 48,
+                    child: FlatButton(
+                        textColor: Colors.white,
+                        color: PRIMARY_COLOR,
+                        highlightColor: Color(0xFF763434),
+                        child: Text(
+                          "确定修改",
+                          style: TextStyle(
+                              fontSize: 16, fontWeight: FontWeight.w500),
+                        ),
+                        onPressed: () async {
+                          if(changeText.isEmpty){
+                            Toast.show(context, '修改内容不能为空', 1500, 'info');
+                            return;
+                          }
+                           Toast.show(context, '加载中', -1, 'loading');
+                          FormData formdata = new FormData.from(
+                              {changekey: changeText, "id": userInfo['id']});
+                          final response = await Dio().post(
+                              domain + 'userInfo/update',
+                              data: formdata,
+                              options: Options(headers: {
+                                "token": StoreProvider.of<CountState>(context)
+                                    .state
+                                    .usetoken
+                              }));
+                          final res = json.decode(response.toString());
+                          print(res);
+                          if (res['success']) {
+                            Toast.hide();
+                            getUserInfo();
+                            Toast.show(context, '修改成功', 1500, 'success');
+                          }
+                        }),
+                  ),
+                ],
+              ),
+            )),
+        onWillPop: () {
+          Toast.hide();
+          print("返回键点击了");
+          Navigator.pop(context);
+        });
+  }
+
+  void getUserInfo() async {
+    final response = await Dio().get(domain + 'userInfo/getUserInfo',
+        options: Options(headers: {
+          "token": StoreProvider.of<CountState>(context).state.usetoken
+        }));
+    final res = json.decode(response.toString());
+    if (res['success']) {
+      StoreProvider.of<CountState>(context)
+          .dispatch({"action": Actions.updateUser, "val": res['data']});
+      Navigator.pop(context);
+    }
+  }
+}

+ 10 - 4
lib/pages/home.dart

@@ -75,6 +75,15 @@ class _MyHomePageState extends State<MyHomePage> {
     });
   }
 
+  @override
+  void didChangeDependencies() {
+    // TODO: implement didChangeDependencies
+    super.didChangeDependencies();
+    print('来一次');
+     allToken = StoreProvider.of<CountState>(context).state.usetoken;
+      userInfo = StoreProvider.of<CountState>(context).state.userInfo;
+  }
+
   @override
   void dispose() {
     super.dispose();
@@ -280,7 +289,7 @@ class _MyHomePageState extends State<MyHomePage> {
             onLongPress: null,
             onTap: () {
               print(tabList[index]["title"]);
-              if (tabList[index]["title"] == '快速进入') {
+              if (tabList[index]["title"] == '搜索') {
                 Navigator.push(
                     context,
                     new CupertinoPageRoute(
@@ -515,12 +524,9 @@ class _MyHomePageState extends State<MyHomePage> {
   }
 
   void getUserInfo() async {
-    print('检查登录');
-    print(allToken);
     final response = await Dio().get(domain + 'userInfo/getUserInfo',
         options: Options(headers: {"token": allToken}));
     final res = json.decode(response.toString());
-    print(res);
     if (res['success']) {
       StoreProvider.of<CountState>(context)
           .dispatch({"action": Actions.updateUser, "val": res['data']});

+ 102 - 93
lib/pages/loginFirst.dart

@@ -18,102 +18,111 @@ class LoginFirstState extends State<LoginFirst> {
   Widget build(BuildContext context) {
     return new WillPopScope(
         child: Scaffold(
-          appBar: AppBar(
-            backgroundColor: BG_SUB_COLOR,
-            centerTitle: true,
-            elevation: 0,
-            leading: Container(),
-          ),
-          body: Container(
-            width: double.infinity,
-            padding: EdgeInsets.symmetric(vertical: 20, horizontal: 15),
-            color: BG_SUB_COLOR,
-            child: Column(
-              crossAxisAlignment: CrossAxisAlignment.start,
-              children: <Widget>[
-                Text(
-                  'LOGO',
-                  style: TextStyle(
-                    color: Colors.white,
-                    fontSize: 64,
-                  ),
-                ),
-                Container(
-                  margin: EdgeInsets.only(top: 30),
-                  child: Text('手机快捷登录',
-                      style: TextStyle(
-                          color: Colors.white,
-                          fontSize: 28,
-                          fontWeight: FontWeight.w500)),
-                ),
-                Container(
-                    margin: EdgeInsets.only(top: 20),
-                    child: TextField(
-                        autofocus: true,
-                        keyboardType: TextInputType.phone,
-                        maxLength: 11,
-                        style: TextStyle(
-                            color: Colors.white,
-                            fontSize: 18,
-                            fontWeight: FontWeight.w500),
-                        decoration: InputDecoration(
-                            hintText: "输入手机号",
-                            hintStyle: TextStyle(
-                              fontSize: 16,
-                              color: Color(0xFF727785),
-                            ),
-                            prefixIcon: Container(
-                              padding: EdgeInsets.all(10),
-                              // color: PRIMARY_COLOR,
-                              child: Image.asset(
-                                'images/list_icon_shouji.png',
-                                width: 20,
-                              ),
-                            ),
-                            // suffixIcon:Container(
-                            //   padding: EdgeInsets.all(10),
-                            //   // color: PRIMARY_COLOR,
-                            //   child: Image.asset(
-                            //     'images/list_icon_shouji.png',
-                            //     width: 20,
-                            //   ),
-                            // ),
-                            counterStyle:
-                                TextStyle(color: BG_SUB_COLOR, fontSize: 0)),
-                        onChanged: (value) {
-                          inputVal = value;
-                        })),
-                Text('未注册的手机号验证后自动创建账户',
-                    style: TextStyle(color: Color(0xFF727785), fontSize: 13)),
-                Container(
-                  margin: EdgeInsets.symmetric(vertical: 22),
+            body: Container(
+          color: BG_SUB_COLOR,
+          child: CustomScrollView(
+            slivers: <Widget>[
+              SliverAppBar(
+                backgroundColor: BG_SUB_COLOR,
+                centerTitle: true,
+                elevation: 0,
+                leading: Container(),
+              ),
+              SliverToBoxAdapter(
+                child: Container(
                   width: double.infinity,
-                  height: 48,
-                  child: FlatButton(
-                    textColor: Colors.white,
-                    color: PRIMARY_COLOR,
-                    highlightColor: Color(0xFFC2524D),
-                    child: Text("下一步"),
-                    onPressed: () {
-                      print(inputVal);
-                      if (!checkPhone(inputVal)) {
-                        Toast.show(context, '手机号格式错误', 1500, 'info');
-                      } else {
-                        Navigator.push(
-                          context,
-                          new CupertinoPageRoute(
-                            builder: (context) =>
-                                new LoginSecond(phone: inputVal),
-                          ),
-                        );
-                      }
-                    },
+                  padding: EdgeInsets.symmetric(vertical: 20, horizontal: 15),
+                  color: BG_SUB_COLOR,
+                  child: Column(
+                    crossAxisAlignment: CrossAxisAlignment.start,
+                    children: <Widget>[
+                      Text(
+                        'LOGO',
+                        style: TextStyle(
+                          color: Colors.white,
+                          fontSize: 64,
+                        ),
+                      ),
+                      Container(
+                        margin: EdgeInsets.only(top: 30),
+                        child: Text('手机快捷登录',
+                            style: TextStyle(
+                                color: Colors.white,
+                                fontSize: 28,
+                                fontWeight: FontWeight.w500)),
+                      ),
+                      Container(
+                          margin: EdgeInsets.only(top: 20),
+                          child: TextField(
+                              autofocus: true,
+                              keyboardType: TextInputType.phone,
+                              maxLength: 11,
+                              style: TextStyle(
+                                  color: Colors.white,
+                                  fontSize: 18,
+                                  fontWeight: FontWeight.w500),
+                              decoration: InputDecoration(
+                                  hintText: "输入手机号",
+                                  hintStyle: TextStyle(
+                                    fontSize: 16,
+                                    color: Color(0xFF727785),
+                                  ),
+                                  prefixIcon: Container(
+                                    padding: EdgeInsets.all(10),
+                                    // color: PRIMARY_COLOR,
+                                    child: Image.asset(
+                                      'images/list_icon_shouji.png',
+                                      width: 20,
+                                    ),
+                                  ),
+                                  // suffixIcon:Container(
+                                  //   padding: EdgeInsets.all(10),
+                                  //   // color: PRIMARY_COLOR,
+                                  //   child: Image.asset(
+                                  //     'images/list_icon_shouji.png',
+                                  //     width: 20,
+                                  //   ),
+                                  // ),
+                                  counterStyle: TextStyle(
+                                      color: BG_SUB_COLOR, fontSize: 0)),
+                              onChanged: (value) {
+                                inputVal = value;
+                              })),
+                      Text('未注册的手机号验证后自动创建账户',
+                          style: TextStyle(
+                              color: Color(0xFF727785), fontSize: 13)),
+                      Container(
+                        margin: EdgeInsets.symmetric(vertical: 22),
+                        width: double.infinity,
+                        height: 48,
+                        child: FlatButton(
+                          textColor: Colors.white,
+                          color: PRIMARY_COLOR,
+                          highlightColor: Color(0xFF763434),
+                          child: Text("下一步"),
+                          onPressed: () {
+                            print(inputVal);
+                            if (!checkPhone(inputVal)) {
+                              Toast.show(context, '手机号格式错误', 1500, 'info');
+                            } else {
+                              Navigator.push(
+                                context,
+                                new CupertinoPageRoute(
+                                  builder: (context) =>
+                                      new LoginSecond(phone: inputVal),
+                                ),
+                              );
+                            }
+                          },
+                        ),
+                      )
+                    ],
                   ),
-                )
-              ],
-            ),
+                ),
+              )
+            ],
           ),
-        ),
+        )),
         onWillPop: () {
           Toast.hide();
           print("返回键点击了");

+ 144 - 118
lib/pages/loginSecond.dart

@@ -7,7 +7,6 @@ import 'package:dio/dio.dart';
 import '../styles/api.dart';
 import 'dart:convert';
 import '../widget/ITextInput.dart';
-import 'home.dart';
 import 'package:flutter_redux/flutter_redux.dart';
 import '../state.dart';
 
@@ -38,125 +37,152 @@ class LoginSecondState extends State<LoginSecond> {
   @override
   Widget build(BuildContext context) {
     return new WillPopScope(
-        child: Scaffold(
-          appBar: AppBar(
-            backgroundColor: BG_SUB_COLOR,
-            centerTitle: true,
-            elevation: 0,
-          ),
-          body: Container(
-            color: BG_SUB_COLOR,
-            padding: EdgeInsets.symmetric(vertical: 30, horizontal: 15),
-            child: Column(
-              crossAxisAlignment: CrossAxisAlignment.start,
-              children: <Widget>[
-                Text(
-                  '验证码已发送至',
-                  style: TextStyle(
-                      color: Colors.white,
-                      fontSize: 28,
-                      fontWeight: FontWeight.w600),
-                ),
-                Container(
-                  margin: EdgeInsets.only(top: 45),
-                  child: Row(
-                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
-                    children: <Widget>[
-                      Text(widget.phone,
-                          style: TextStyle(
-                              color: Color(0xFFF15436),
-                              fontSize: 20,
-                              fontWeight: FontWeight.w500)),
-                      FlatButton(
-                        highlightColor: BG_SUB_COLOR,
-                        textColor: PRIMARY_COLOR,
-                        child: Text(isSend ? '(' + '$sendTime' + '秒)' : '重新发送'),
-                        disabledTextColor: Color(0xFF8D8E9C),
-                        onPressed: isSend
-                            ? null
-                            : () {
-                                sendMsg();
-                              },
-                      )
-                    ],
-                  ),
-                ),
-                Container(
-                  margin: EdgeInsets.only(top: 10),
-                  child: ITextField(
-                    maxLength: 6,
-                    keyboardType: ITextInputType.number,
-                    prefixIcon: Container(
-                      padding: EdgeInsets.all(10),
-                      // color: PRIMARY_COLOR,
-                      child: Image.asset(
-                        'images/list_icon_yanzhengma.png',
-                        width: 20,
+        child: Container(
+          color: BG_SUB_COLOR,
+          child: Scaffold(
+              appBar: AppBar(
+                backgroundColor: BG_SUB_COLOR,
+                centerTitle: true,
+                elevation: 0,
+              ),
+              body: Container(
+                color: BG_SUB_COLOR,
+                child: CustomScrollView(
+                  slivers: <Widget>[
+                    SliverToBoxAdapter(
+                      child: Container(
+                        color: BG_SUB_COLOR,
+                        padding:
+                            EdgeInsets.symmetric(vertical: 30, horizontal: 15),
+                        child: Column(
+                          crossAxisAlignment: CrossAxisAlignment.start,
+                          children: <Widget>[
+                            Text(
+                              '验证码已发送至',
+                              style: TextStyle(
+                                  color: Colors.white,
+                                  fontSize: 28,
+                                  fontWeight: FontWeight.w600),
+                            ),
+                            Container(
+                              margin: EdgeInsets.only(top: 45),
+                              child: Row(
+                                mainAxisAlignment:
+                                    MainAxisAlignment.spaceBetween,
+                                children: <Widget>[
+                                  Text(widget.phone,
+                                      style: TextStyle(
+                                          color: Color(0xFFF15436),
+                                          fontSize: 20,
+                                          fontWeight: FontWeight.w500)),
+                                  FlatButton(
+                                    highlightColor: BG_SUB_COLOR,
+                                    textColor: PRIMARY_COLOR,
+                                    child: Text(isSend
+                                        ? '(' + '$sendTime' + '秒)'
+                                        : '重新发送'),
+                                    disabledTextColor: Color(0xFF8D8E9C),
+                                    onPressed: isSend
+                                        ? null
+                                        : () {
+                                            sendMsg();
+                                          },
+                                  )
+                                ],
+                              ),
+                            ),
+                            Container(
+                              margin: EdgeInsets.only(top: 10),
+                              child: ITextField(
+                                maxLength: 6,
+                                keyboardType: ITextInputType.number,
+                                prefixIcon: Container(
+                                  padding: EdgeInsets.all(10),
+                                  // color: PRIMARY_COLOR,
+                                  child: Image.asset(
+                                    'images/list_icon_yanzhengma.png',
+                                    width: 20,
+                                  ),
+                                ),
+                                hintText: '输入短信验证码',
+                                hintStyle: TextStyle(
+                                  fontSize: 16,
+                                  color: Color(0xFF727785),
+                                ),
+                                textStyle: TextStyle(color: Colors.white),
+                                fieldCallBack: (content) {
+                                  setState(() {
+                                    inputCode = content;
+                                  });
+                                },
+                                counterStyle:
+                                    TextStyle(color: BG_SUB_COLOR, fontSize: 0),
+                              ),
+                            ),
+                            Container(
+                                margin: EdgeInsets.only(top: 63, bottom: 20),
+                                width: double.infinity,
+                                height: 48,
+                                child: FlatButton(
+                                  textColor: Colors.white,
+                                  color: PRIMARY_COLOR,
+                                  highlightColor: Color(0xFF763434),
+                                  child: Text("注册/登录"),
+                                  onPressed: () async {
+                                    if (_sessionID == null) {
+                                      Toast.show(
+                                          context, '请发送验证码', 1500, 'info');
+                                    } else if (inputCode.length != 6) {
+                                      Toast.show(
+                                          context, '请输入验证码', 1500, 'info');
+                                    } else {
+                                      FormData formdata = FormData.from({
+                                        "phone": widget.phone,
+                                        "code": inputCode,
+                                        "sessionId": _sessionID,
+                                        "requireToken": true
+                                      });
+                                      Toast.show(context, '加载中', -1, 'loading');
+                                      final response = await Dio().post(
+                                          domain + 'auth/loginSms',
+                                          data: formdata);
+                                      final res =
+                                          json.decode(response.toString());
+                                      Toast.hide();
+                                      print(res);
+                                      if (res['success']) {
+                                        StoreProvider.of<CountState>(context)
+                                            .dispatch({
+                                          "action": Actions.updateAll,
+                                          "token": res['token'],
+                                          "user": res['data']
+                                        });
+                                        Toast.show(
+                                            context, '登录成功', 1500, 'success');
+                                        // Navigator.pushAndRemoveUntil(
+                                        //   context,
+                                        //   new CupertinoPageRoute(
+                                        //     builder: (context) => new MyHomePage(),
+                                        //   ),
+                                        //    ModalRoute.withName('/'),
+                                        // );
+
+                                        Navigator.popUntil(
+                                            context, ModalRoute.withName('/'));
+                                      } else {
+                                        Toast.show(context, res['error'], 1500,
+                                            'info');
+                                      }
+                                    }
+                                  },
+                                ))
+                          ],
+                        ),
                       ),
-                    ),
-                    hintText: '输入短信验证码',
-                    hintStyle: TextStyle(
-                      fontSize: 16,
-                      color: Color(0xFF727785),
-                    ),
-                    textStyle: TextStyle(color: Colors.white),
-                    fieldCallBack: (content) {
-                      setState(() {
-                        inputCode = content;
-                      });
-                    },
-                    counterStyle: TextStyle(color: BG_SUB_COLOR, fontSize: 0),
-                  ),
+                    )
+                  ],
                 ),
-                Container(
-                    margin: EdgeInsets.only(top: 63, bottom: 20),
-                    width: double.infinity,
-                    height: 48,
-                    child: FlatButton(
-                      textColor: Colors.white,
-                      color: PRIMARY_COLOR,
-                      highlightColor: Color(0xFFC2524D),
-                      child: Text("注册/登录"),
-                      onPressed: () async {
-                        if (_sessionID == null) {
-                          Toast.show(context, '请发送验证码', 1500, 'info');
-                        } else if (inputCode.length != 6) {
-                          Toast.show(context, '请输入验证码', 1500, 'info');
-                        } else {
-                          FormData formdata = FormData.from({
-                            "phone": widget.phone,
-                            "code": inputCode,
-                            "sessionId": _sessionID,
-                            "requireToken": true
-                          });
-                          Toast.show(context, '加载中', -1, 'loading');
-                          final response = await Dio()
-                              .post(domain + 'auth/loginSms', data: formdata);
-                          final res = json.decode(response.toString());
-                          Toast.hide();
-                          print(res);
-                          if (res['success']) {
-                            StoreProvider.of<CountState>(context).dispatch({
-                              "action": Actions.updateAll,
-                              "token": res['token'],
-                              "user":res['data']
-                            });
-                            Toast.show(context, '登录成功', 1500, 'success');
-                            Navigator.push(
-                              context,
-                              new CupertinoPageRoute(
-                                builder: (context) => new MyHomePage(),
-                              ),
-                            );
-                          } else {
-                            Toast.show(context, res['error'], 1500, 'info');
-                          }
-                        }
-                      },
-                    ))
-              ],
-            ),
-          ),
+              )),
         ),
         onWillPop: () {
           Toast.hide();

+ 42 - 0
lib/pages/rankList.dart

@@ -0,0 +1,42 @@
+import 'package:flutter/material.dart';
+import '../styles/colors.dart';
+import 'dart:ui';
+import '../styles/totast.dart';
+
+class RankList extends StatefulWidget {
+  @override
+  RankListState createState() => RankListState();
+}
+
+class RankListState extends State<RankList> {
+  @override
+  Widget build(BuildContext context) {
+
+
+    return new WillPopScope(
+        child: Scaffold(
+        appBar: AppBar(
+          backgroundColor: PRIMARY_COLOR,
+          title: Text('排行榜'),
+          centerTitle: true,
+          elevation:0,
+        ),
+        body: RefreshIndicator(
+          color: PRIMARY_COLOR,
+          backgroundColor: BG_COLOR,
+          onRefresh: () async {
+            await new Future.delayed(const Duration(seconds: 1));
+            
+          },
+          child: Container(
+            color: BG_COLOR,
+          ),
+        )),
+        onWillPop: () {
+          Toast.hide();
+          print("返回键点击了");
+          Navigator.pop(context);
+        });
+ 
+  }
+}

+ 279 - 67
lib/pages/setting.dart

@@ -1,6 +1,8 @@
 import 'package:flutter/material.dart';
 import "package:image_picker/image_picker.dart";
+import 'package:flutter/cupertino.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:flutter_picker/flutter_picker.dart';
 import 'package:dio/dio.dart';
 import '../styles/colors.dart';
 import '../styles/api.dart';
@@ -10,6 +12,10 @@ import 'dart:typed_data';
 import 'dart:convert';
 import 'dart:ui';
 import '../styles/totast.dart';
+import 'package:flutter_redux/flutter_redux.dart';
+import '../state.dart';
+import 'changeUserInfo.dart'; //修改信息页面
+import 'loginFirst.dart'; //登录
 
 class Setting extends StatefulWidget {
   @override
@@ -45,7 +51,14 @@ class SettingState extends State<Setting> {
     // TODO: implement initState
     super.initState();
 
-    getUserInfo(false);
+    // getUserInfo(false);
+  }
+
+  @override
+  void didChangeDependencies() {
+    // TODO: implement didChangeDependencies
+    super.didChangeDependencies();
+    userInfo = StoreProvider.of<CountState>(context).state.userInfo;
   }
 
   @override
@@ -60,44 +73,92 @@ class SettingState extends State<Setting> {
               centerTitle: true,
               elevation: 0,
             ),
-            body: RefreshIndicator(
-                color: PRIMARY_COLOR,
-                backgroundColor: BG_SUB_COLOR,
-                displacement: 10,
-                onRefresh: () async {
-                  await new Future.delayed(const Duration(seconds: 1));
-                  getUserInfo(false);
-                },
-                child: SingleChildScrollView(
-                    physics: AlwaysScrollableScrollPhysics(),
-                    child: ConstrainedBox(
-                      constraints: BoxConstraints(
-                          minHeight: window.physicalSize.height /
-                                  window.devicePixelRatio -
-                              56 -
-                              MediaQueryData.fromWindow(window).padding.top),
-                      child: Container(
-                        color: BG_COLOR,
-                        child: Column(
-                          children: <Widget>[
-                            Container(
-                              color: BG_SUB_COLOR,
-                              padding: EdgeInsets.only(top: 10),
-                              child: Column(
-                                children: <Widget>[_settingItem('头像')],
-                              ),
-                            )
-                          ],
-                        ),
-                      ),
-                    ))),
-            floatingActionButton: FloatingActionButton(
-              onPressed: () {
-                print('点击照片');
-                Toast.show(context, '加载中', -1, 'loading');
-              },
-              tooltip: 'Pick Image',
-              child: Icon(Icons.add_a_photo),
+            body: Stack(
+              children: <Widget>[
+                RefreshIndicator(
+                    color: PRIMARY_COLOR,
+                    backgroundColor: BG_SUB_COLOR,
+                    displacement: 10,
+                    onRefresh: () async {
+                      await new Future.delayed(const Duration(seconds: 1));
+                      getUserInfo(false);
+                    },
+                    child: SingleChildScrollView(
+                        physics: AlwaysScrollableScrollPhysics(),
+                        child: ConstrainedBox(
+                          constraints: BoxConstraints(
+                              minHeight: window.physicalSize.height /
+                                      window.devicePixelRatio -
+                                  56 -
+                                  MediaQueryData.fromWindow(window)
+                                      .padding
+                                      .top),
+                          child: Container(
+                            padding: EdgeInsets.only(bottom: 100),
+                            color: BG_COLOR,
+                            child: Column(
+                              children: <Widget>[
+                                Container(
+                                  color: BG_SUB_COLOR,
+                                  padding: EdgeInsets.only(top: 10),
+                                  child: Column(
+                                    children: <Widget>[
+                                      _settingItem('头像', true),
+                                      _settingItem('昵称', true),
+                                      _settingItem('性别', true),
+                                      _settingItem('生日', true),
+                                      _settingItem('手机', false),
+                                    ],
+                                  ),
+                                ),
+                                Container(
+                                  color: BG_SUB_COLOR,
+                                  padding: EdgeInsets.only(top: 10),
+                                  child: Column(
+                                    children: <Widget>[
+                                      _settingItem('是否接受消息提示', false),
+                                    ],
+                                  ),
+                                ),
+                                Container(
+                                  color: BG_SUB_COLOR,
+                                  padding: EdgeInsets.only(top: 10),
+                                  child: Column(
+                                    children: <Widget>[
+                                      _settingItem('检查更新', true),
+                                      _settingItem('版本号', false),
+                                    ],
+                                  ),
+                                )
+                              ],
+                            ),
+                          ),
+                        ))),
+                Positioned(
+                  bottom: 10,
+                  width: ScreenUtil().setWidth(345),
+                  left: ScreenUtil().setWidth(15),
+                  height: 48,
+                  child: FlatButton(
+                      textColor: Colors.white,
+                      color: PRIMARY_COLOR,
+                      highlightColor: Color(0xFF763434),
+                      child: Text("退出登录"),
+                      onPressed: () {
+                        print('退出登录');
+                        StoreProvider.of<CountState>(context).dispatch({
+                          "action": Actions.updateAll,
+                          "token": "",
+                          "user": {}
+                        });
+                        Toast.show(context, '退出成功', 1500, 'success');
+                        Navigator.push(
+                            context,
+                            new MaterialPageRoute(
+                                builder: (context) => new LoginFirst()));
+                      }),
+                )
+              ],
             )),
         onWillPop: () {
           Toast.hide();
@@ -106,29 +167,55 @@ class SettingState extends State<Setting> {
         });
   }
 
-  Widget _settingItem(name) {
+  Widget _settingItem(name, isNext) {
     return Container(
       padding: EdgeInsets.only(left: 15, right: 15),
-      height: 60,
       color: BG_COLOR,
       child: GestureDetector(
-        child: Row(
+        child: Column(
           children: <Widget>[
-            Text(name,
-                style: TextStyle(
-                    color: Colors.white,
-                    fontSize: 14,
-                    fontWeight: FontWeight.w400)),
-            Expanded(flex: 1, child: _centerWidget('头像')),
-            Image.asset(
-              'images/icon_inter.png',
-              width: 24,
+            Container(
+              height: 60,
+              child: Row(
+                crossAxisAlignment: CrossAxisAlignment.center,
+                children: <Widget>[
+                  Text(name,
+                      style: TextStyle(
+                          color: Colors.white,
+                          fontSize: 14,
+                          fontWeight: FontWeight.w400)),
+                  Expanded(flex: 1, child: _centerWidget(name)),
+                  Image.asset(
+                    'images/icon_inter.png',
+                    width: name != '是否接受消息提示' && name != '版本号' ? 24 : 0,
+                  )
+                ],
+              ),
+            ),
+            Container(
+              height: isNext ? 1 : 0,
+              color: BG_SUB_COLOR,
+              width: double.infinity,
             )
           ],
         ),
         onTap: () {
           if (name == '头像') {
             getImage();
+          } else if (name == '昵称') {
+            Navigator.push(
+                context,
+                new CupertinoPageRoute(
+                    builder: (context) => new ChangeUserInfo(title: '昵称')));
+          } else if (name == '性别') {
+            showPicker(context);
+          } else if (name == '生日') {
+            showPickerDate(context);
+          } else if (name == '手机') {
+            Navigator.push(
+                context,
+                new CupertinoPageRoute(
+                    builder: (context) => new ChangeUserInfo(title: '手机号')));
           }
         },
       ),
@@ -138,6 +225,19 @@ class SettingState extends State<Setting> {
   Widget _centerWidget(name) {
     Widget _wiget;
     print(name);
+
+    TextStyle mainText = TextStyle(
+      color: Colors.white,
+      fontSize: 15,
+      fontWeight: FontWeight.w500,
+    );
+
+    TextStyle placText = TextStyle(
+      color: Color(0xFF727785),
+      fontSize: 13,
+      fontWeight: FontWeight.w400,
+    );
+
     if (name == '头像') {
       _wiget = UnconstrainedBox(
         alignment: Alignment.centerRight,
@@ -149,6 +249,79 @@ class SettingState extends State<Setting> {
                   userInfo.containsKey('icon') ? userInfo['icon'] : '')),
         ),
       );
+    } else if (name == '昵称') {
+      _wiget = Text(
+        userInfo.containsKey('nickname') ? userInfo['nickname'] : '',
+        style: mainText,
+        textAlign: TextAlign.right,
+      );
+    } else if (name == '性别') {
+      if (userInfo.containsKey('sex')) {
+        _wiget = Text(
+          userInfo['sex'],
+          style: mainText,
+          textAlign: TextAlign.right,
+        );
+      } else {
+        _wiget = Text(
+          '请添加性别信息',
+          style: placText,
+          textAlign: TextAlign.right,
+        );
+      }
+    } else if (name == '生日') {
+      if (userInfo.containsKey('birthday')) {
+        _wiget = Text(
+          readTimestamp(userInfo['birthday']),
+          style: mainText,
+          textAlign: TextAlign.right,
+        );
+      } else {
+        _wiget = Text(
+          '选择生日',
+          style: placText,
+          textAlign: TextAlign.right,
+        );
+      }
+    } else if (name == '手机') {
+      if (userInfo.containsKey('phone')) {
+        _wiget = Text(
+          userInfo['phone'],
+          style: mainText,
+          textAlign: TextAlign.right,
+        );
+      } else {
+        _wiget = Text(
+          '请输入手机号',
+          style: placText,
+          textAlign: TextAlign.right,
+        );
+      }
+    } else if (name == '是否接受消息提示') {
+      _wiget = UnconstrainedBox(
+          alignment: Alignment.centerRight,
+          child: Container(
+            width: 60,
+            child: Switch(
+              value: true,
+              activeColor: PRIMARY_COLOR, // 激活时原点颜色
+              onChanged: (bool val) {},
+            ),
+          ));
+    } else if (name == '版本号') {
+      if (userInfo.containsKey('phone')) {
+        _wiget = Text(
+          'V1.2.20',
+          style: mainText,
+          textAlign: TextAlign.right,
+        );
+      }
+    } else {
+      _wiget = Text(
+        '',
+        style: mainText,
+        textAlign: TextAlign.right,
+      );
     }
 
     return _wiget;
@@ -157,12 +330,14 @@ class SettingState extends State<Setting> {
   void updateUserInfo(value, key) async {
     print(value);
     print(key);
-    FormData formdata =
-        new FormData.from({key: value, "id": isDebug ? debugID : ''});
+    FormData formdata = new FormData.from({key: value, "id": userInfo['id']});
     print(formdata);
-    final response =
-        await Dio().post(domain + 'userInfo/update', data: formdata);
-        print(response);
+    final response = await Dio().post(domain + 'userInfo/update',
+        data: formdata,
+        options: Options(headers: {
+          "token": StoreProvider.of<CountState>(context).state.usetoken
+        }));
+    print(response);
     final res = json.decode(response.toString());
     if (res['success']) {
       Toast.hide();
@@ -172,23 +347,60 @@ class SettingState extends State<Setting> {
   }
 
   void getUserInfo(isFreash) async {
-    Future.delayed(Duration(seconds: 1000), () {
-      if (!userInfo.containsKey('nickname')) {
-        Toast.show(context, '加载中', -1, 'loading');
-        isFreash = true;
-      }
-    });
     final response = await Dio().get(domain + 'userInfo/getUserInfo',
-        data: {"id": isDebug ? debugID : ''});
+        options: Options(headers: {
+          "token": StoreProvider.of<CountState>(context).state.usetoken
+        }));
     final res = json.decode(response.toString());
-    if (isFreash) {
-      Toast.hide();
-    }
     if (res['success']) {
-      print(res['data']);
+      StoreProvider.of<CountState>(context)
+          .dispatch({"action": Actions.updateUser, "val": res['data']});
       setState(() {
         userInfo = res['data'];
       });
     }
   }
+
+  showPicker(BuildContext context) {
+    String PickerData = '''["男","女"]''';
+    new Picker(
+        confirmText: '确定',
+        cancelText: "取消",
+        adapter: PickerDataAdapter<String>(
+            pickerdata: new JsonDecoder().convert(PickerData)),
+        changeToFirst: true,
+        textAlign: TextAlign.left,
+        columnPadding: const EdgeInsets.all(8.0),
+        onConfirm: (Picker picker, List value) {
+          Toast.show(context, '加载中', -1, 'loading');
+          updateUserInfo(
+              picker.getSelectedValues()[0].toString().trim(), 'sex');
+        }).showModal(this.context);
+  }
+
+  showPickerDate(BuildContext context) {
+    new Picker(
+        hideHeader: true,
+        confirmText: '确定',
+        cancelText: "取消",
+        adapter: new DateTimePickerAdapter(
+            type: PickerDateTimeType.kYMD,
+            isNumberMonth: true,
+            //strAMPM: const["上午", "下午"],
+            yearSuffix: "年",
+            monthSuffix: "月",
+            daySuffix: "日"),
+        title: new Text("选择出生日期"),
+        onConfirm: (Picker picker, List value) {
+          if (DateTime.parse(picker.adapter.toString()).millisecondsSinceEpoch >
+              DateTime.now().millisecondsSinceEpoch) {
+            Toast.show(context, '日期错误', 1500, 'info');
+            return;
+          }
+          Toast.show(context, '加载中', -1, 'loading');
+          updateUserInfo(
+              DateTime.parse(picker.adapter.toString()).millisecondsSinceEpoch,
+              'birthday');
+        }).showDialog(context);
+  }
 }

+ 8 - 2
lib/styles/api.dart

@@ -1,5 +1,5 @@
 import 'package:flutter/material.dart';
-
+import 'package:intl/intl.dart';
 
 String domain='http://49.4.66.233:8201/';
 // String domain='http://192.168.50.226:8080/'; //本地ip
@@ -15,4 +15,10 @@ bool checkPhone (phone){
         result = true;
     }
     return result;
-}
+}
+
+String readTimestamp(int timestamp) {
+   
+
+    return DateFormat('yy/MM/dd').format(DateTime.fromMillisecondsSinceEpoch(timestamp));
+  }

+ 29 - 2
lib/widget/ITextInput.dart

@@ -28,6 +28,8 @@ class ITextField extends StatefulWidget {
   final TextStyle textStyle;
   final FormFieldValidator<String> validator;
   final TextStyle counterStyle;
+  final String inputText;
+  final bool autofocus;
 
   ITextField(
       {Key key,
@@ -42,7 +44,9 @@ class ITextField extends StatefulWidget {
       this.textStyle,
       this.prefixIcon,
       this.validator,
-      this.counterStyle})
+      this.counterStyle,
+      this.inputText,
+      this.autofocus=false})
       : assert(maxLines == null || maxLines > 0),
         assert(maxLength == null || maxLength > 0),
         keyboardType = maxLines == 1 ? keyboardType : ITextInputType.multiline,
@@ -53,10 +57,11 @@ class ITextField extends StatefulWidget {
 }
 
 class _ITextFieldState extends State<ITextField> {
-  String _inputText = "";
+  String _inputText = '';
   bool _hasdeleteIcon = false;
   bool _isNumber = false;
   bool _isPassword = false;
+  FocusNode _focusNode = FocusNode();
 
   ///输入类型
   TextInputType _getTextInputType() {
@@ -92,6 +97,26 @@ class _ITextFieldState extends State<ITextField> {
         : null;
   }
 
+  @override
+  void initState() {
+    // TODO: implement initState
+    super.initState();
+    _inputText = widget.inputText != null ? widget.inputText : '';
+    _focusNode.addListener(() {
+      if (!_focusNode.hasFocus) {
+        print('失去焦点');
+        setState(() {
+          _hasdeleteIcon = false;
+        });
+      } else {
+        print('获取焦点');
+        setState(() {
+          _hasdeleteIcon = (_inputText.isNotEmpty);
+        });
+      }
+    });
+  }
+
   @override
   Widget build(BuildContext context) {
     TextEditingController _controller = new TextEditingController.fromValue(
@@ -101,6 +126,8 @@ class _ITextFieldState extends State<ITextField> {
                 affinity: TextAffinity.downstream,
                 offset: _inputText.length))));
     TextField textField = new TextField(
+      autofocus: widget.autofocus,
+      focusNode: _focusNode,
       controller: _controller,
       decoration: InputDecoration(
         counterStyle: widget.counterStyle,

+ 2 - 0
pubspec.yaml

@@ -21,6 +21,8 @@ dependencies:
   flutter_redux: ^0.5.2
   redux_persist: ^0.8.0
   redux_persist_flutter: ^0.8.0
+  flutter_picker: ^1.0.7
+  intl: "^0.15.6"
 
 dev_dependencies:
   flutter_test: