x1ongzhu 6 лет назад
Родитель
Сommit
2dea3261db

+ 3 - 0
android/app/src/main/AndroidManifest.xml

@@ -7,6 +7,9 @@
     -->
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.CAMERA" />
     <!-- io.flutter.app.FlutterApplication is an android.app.Application that
          calls FlutterMain.startInitialization(this); in its onCreate method.
          In most cases you can leave this as-is, but you if you want to provide

+ 4 - 0
ios/Runner/Info.plist

@@ -41,5 +41,9 @@
 	</array>
 	<key>UIViewControllerBasedStatusBarAppearance</key>
 	<false/>
+    <key>NSPhotoLibraryUsageDescription</key>
+    <string>需要相册权限才能继续使用</string>
+    <key>NSCameraUsageDescription</key>
+    <string>需要相机权限才能继续使用</string>
 </dict>
 </plist>

+ 141 - 0
lib/Localizations.dart

@@ -0,0 +1,141 @@
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_localizations/flutter_localizations.dart';
+
+class ChineseCupertinoLocalizations implements CupertinoLocalizations {
+  final materialDelegate = GlobalMaterialLocalizations.delegate;
+  final widgetsDelegate = GlobalWidgetsLocalizations.delegate;
+  final local = const Locale('zh');
+
+  MaterialLocalizations ml;
+
+  Future init() async {
+    ml = await materialDelegate.load(local);
+    print(ml.pasteButtonLabel);
+  }
+
+  @override
+  String get alertDialogLabel => ml.alertDialogLabel;
+
+  @override
+  String get anteMeridiemAbbreviation => ml.anteMeridiemAbbreviation;
+
+  @override
+  String get copyButtonLabel => ml.copyButtonLabel;
+
+  @override
+  String get cutButtonLabel => ml.cutButtonLabel;
+
+  @override
+  DatePickerDateOrder get datePickerDateOrder => DatePickerDateOrder.mdy;
+
+  @override
+  DatePickerDateTimeOrder get datePickerDateTimeOrder => DatePickerDateTimeOrder.date_time_dayPeriod;
+
+  @override
+  String datePickerDayOfMonth(int dayIndex) {
+    return dayIndex.toString() + '日';
+  }
+
+  @override
+  String datePickerHour(int hour) {
+    return hour.toString().padLeft(2, "0");
+  }
+
+  @override
+  String datePickerHourSemanticsLabel(int hour) {
+    return "$hour" + "时";
+  }
+
+  @override
+  String datePickerMediumDate(DateTime date) {
+    return ml.formatMediumDate(date);
+  }
+
+  @override
+  String datePickerMinute(int minute) {
+    return minute.toString().padLeft(2, '0');
+  }
+
+  @override
+  String datePickerMinuteSemanticsLabel(int minute) {
+    return "$minute" + "分";
+  }
+
+  @override
+  String datePickerMonth(int monthIndex) {
+    return "$monthIndex" + '月';
+  }
+
+  @override
+  String datePickerYear(int yearIndex) {
+    return yearIndex.toString() + '年';
+  }
+
+  @override
+  String get pasteButtonLabel => ml.pasteButtonLabel;
+
+  @override
+  String get postMeridiemAbbreviation => ml.postMeridiemAbbreviation;
+
+  @override
+  String get selectAllButtonLabel => ml.selectAllButtonLabel;
+
+  @override
+  String timerPickerHour(int hour) {
+    return hour.toString().padLeft(2, "0");
+  }
+
+  @override
+  String timerPickerHourLabel(int hour) {
+    return "$hour".toString().padLeft(2, "0") + "时";
+  }
+
+  @override
+  String timerPickerMinute(int minute) {
+    return minute.toString().padLeft(2, "0");
+  }
+
+  @override
+  String timerPickerMinuteLabel(int minute) {
+    return minute.toString().padLeft(2, "0") + "分";
+  }
+
+  @override
+  String timerPickerSecond(int second) {
+    return second.toString().padLeft(2, "0");
+  }
+
+  @override
+  String timerPickerSecondLabel(int second) {
+    return second.toString().padLeft(2, "0") + "秒";
+  }
+
+  static const LocalizationsDelegate<CupertinoLocalizations> delegate = _ChineseDelegate();
+
+  static Future<CupertinoLocalizations> load(Locale locale) async {
+    var localizaltions = ChineseCupertinoLocalizations();
+    await localizaltions.init();
+    return SynchronousFuture<CupertinoLocalizations>(localizaltions);
+  }
+}
+
+class _ChineseDelegate extends LocalizationsDelegate<CupertinoLocalizations> {
+  const _ChineseDelegate();
+
+  @override
+  bool isSupported(Locale locale) {
+    return locale.languageCode == 'zh';
+  }
+
+  @override
+  Future<CupertinoLocalizations> load(Locale locale) {
+    return ChineseCupertinoLocalizations.load(locale);
+  }
+
+  @override
+  bool shouldReload(LocalizationsDelegate<CupertinoLocalizations> old) {
+    return false;
+  }
+}

+ 12 - 0
lib/main.dart

@@ -1,3 +1,4 @@
+import 'package:flutter/cupertino.dart';
 import 'package:flutter/services.dart';
 import 'package:redux/redux.dart';
 import 'package:flutter/material.dart';
@@ -9,6 +10,8 @@ import 'net/HttpManager.dart';
 import 'model/UserInfo.dart';
 import 'net/Result.dart';
 import 'pages/loginFirst.dart';
+import 'package:flutter_localizations/flutter_localizations.dart';
+import './Localizations.dart';
 
 class MobileCyberGamesApp extends StatelessWidget {
   final Store<AppState> store;
@@ -21,6 +24,15 @@ class MobileCyberGamesApp extends StatelessWidget {
         store: this.store,
         child: new MaterialApp(
           title: '全民电竞',
+          supportedLocales: [
+            const Locale('en'), // English
+            const Locale('zh'), // China
+          ],
+          localizationsDelegates: [
+            GlobalMaterialLocalizations.delegate,
+            GlobalWidgetsLocalizations.delegate,
+            ChineseCupertinoLocalizations.delegate,
+          ],
           theme: ThemeData(
               cardColor: Color(0xFF2B2B42),
               backgroundColor: Color(0xFF222335),

+ 7 - 16
lib/pages/changeUserInfo.dart

@@ -12,7 +12,7 @@ import '../net/Result.dart';
 import 'dart:convert';
 
 class ChangeUserInfo extends StatefulWidget {
-  ChangeUserInfo({Key key, this.title,this.val}) : super(key: key);
+  ChangeUserInfo({Key key, this.title, this.val}) : super(key: key);
   final String title; // 用来储存传递过来的值
   final String val; // 用来储存传递过来的值
   @override
@@ -26,7 +26,6 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
 
   @override
   void initState() {
-    // TODO: implement initState
     super.initState();
     switch (widget.title) {
       case '昵称':
@@ -36,12 +35,9 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
         changekey = 'phone';
         break;
     }
-    changeText=widget.val;
+    changeText = widget.val;
   }
 
-  
-
- 
   @override
   Widget build(BuildContext context) {
     return StoreConnector<AppState, UserInfo>(
@@ -65,22 +61,18 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
                             autofocus: true,
                             inputText: changeText,
                             maxLength: 15,
-                            hintText: '输入用户'+widget.title,
+                            hintText: '输入用户' + widget.title,
                             hintStyle: TextStyle(
                               fontSize: 16,
                               color: Color(0xFF727785),
                             ),
-                            textStyle: TextStyle(
-                                color: Colors.white,
-                                fontSize: 18,
-                                fontWeight: FontWeight.w500),
+                            textStyle: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500),
                             fieldCallBack: (content) {
                               setState(() {
                                 changeText = content;
                               });
                             },
-                            counterStyle:
-                                TextStyle(color: BG_SUB_COLOR, fontSize: 0),
+                            counterStyle: TextStyle(color: BG_SUB_COLOR, fontSize: 0),
                           ),
                         ),
                         Container(
@@ -93,8 +85,7 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
                               highlightColor: Color(0xFF763434),
                               child: Text(
                                 "确定修改",
-                                style: TextStyle(
-                                    fontSize: 16, fontWeight: FontWeight.w500),
+                                style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
                               ),
                               onPressed: () async {
                                 if (changeText.isEmpty) {
@@ -126,8 +117,8 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
                   )),
               onWillPop: () {
                 Toast.hide();
-                print("返回键点击了");
                 Navigator.pop(context);
+                return Future.value(false);
               });
         });
   }

+ 303 - 310
lib/pages/setting.dart

@@ -2,8 +2,9 @@ import 'package:flutter/material.dart';
 import 'package:file_picker/file_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 'package:intl/intl.dart';
+import 'package:package_info/package_info.dart';
 import '../styles/colors.dart';
 import '../styles/api.dart';
 import 'dart:io';
@@ -26,19 +27,16 @@ class Setting extends StatefulWidget {
 }
 
 class SettingState extends State<Setting> {
-  Future getImage(userInfo) async {
-    var image = await FilePicker.getFilePath(type: FileType.IMAGE);
-    Toast.show(context, '加载中', -1, 'loading');
-    File _image = File(image);
-    _image.readAsBytes().then((bytes) async {
-      String encoded1 = 'data:image/jpeg;base64,' + base64Encode(bytes);
-      FormData formData = new FormData.from({"base64": encoded1});
-      final response =
-          await Dio().post(domain + 'assets/uploadImg', data: formData);
-      final res = json.decode(response.toString());
-      if (res['success']) {
-        updateUserInfo(userInfo, res['data'], 'icon');
-      }
+  String version = "";
+  bool receiveMsg = false;
+
+  @override
+  void initState() {
+    super.initState();
+    PackageInfo.fromPlatform().then((packageInfo) {
+      setState(() {
+        version = packageInfo.version;
+      });
     });
   }
 
@@ -49,275 +47,118 @@ class SettingState extends State<Setting> {
         converter: (Store store) => store.state.userInfo,
         builder: (context, userInfo) {
           return new WillPopScope(
+              key: Key("SettingsPage"),
               child: Scaffold(
-                  appBar: AppBar(
-                    backgroundColor: PRIMARY_COLOR,
-                    title: Text('系统设置'),
-                    centerTitle: true,
-                    elevation: 0,
-                  ),
-                  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();
-                          },
-                          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(userInfo, '头像', true),
-                                            _settingItem(userInfo, '昵称', true),
-                                            _settingItem(userInfo, '性别', true),
-                                            _settingItem(userInfo, '生日', true),
-                                            _settingItem(userInfo, '手机', false),
-                                          ],
-                                        ),
-                                      ),
-                                      Container(
-                                        color: BG_SUB_COLOR,
-                                        padding: EdgeInsets.only(top: 10),
-                                        child: Column(
-                                          children: <Widget>[
-                                            _settingItem(
-                                                userInfo, '是否接受消息提示', false),
-                                          ],
-                                        ),
-                                      ),
-                                      Container(
-                                        color: BG_SUB_COLOR,
-                                        padding: EdgeInsets.only(top: 10),
-                                        child: Column(
-                                          children: <Widget>[
-                                            _settingItem(
-                                                userInfo, '检查更新', true),
-                                            _settingItem(
-                                                userInfo, '版本号', false),
-                                          ],
-                                        ),
-                                      )
-                                    ],
+                backgroundColor: PAGE_BACKGROUND_COLOR,
+                appBar: AppBar(
+                  backgroundColor: PRIMARY_COLOR,
+                  title: Text('系统设置'),
+                  centerTitle: true,
+                  elevation: 0,
+                ),
+                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();
+                      },
+                      child: SizedBox.expand(
+                        child: SingleChildScrollView(
+                          physics: AlwaysScrollableScrollPhysics(),
+                          child: Column(
+                            children: <Widget>[
+                              _sectionDivier(),
+                              _section([
+                                _cell(
+                                  '头像',
+                                  ClipOval(child: Image.network(userInfo.icon, width: 36, height: 36)),
+                                ),
+                                _cell('昵称', userInfo.nickname, placeholder: '请填写昵称', onTap: () {
+                                  Navigator.push(
+                                      context, new CupertinoPageRoute(builder: (context) => new ChangeUserInfo(title: '昵称', val: userInfo.nickname)));
+                                }),
+                                _cell('性别', userInfo.sex, placeholder: '请添加性别信息', onTap: () {
+                                  _chooseSex(context);
+                                }),
+                                _cell(
+                                  '生日',
+                                  DateFormat('yyyy-MM-dd').format(
+                                    DateTime.fromMillisecondsSinceEpoch(userInfo.birthday),
                                   ),
+                                  placeholder: '选择生日',
+                                  onTap: () {
+                                    _chooseBirthday(context);
+                                  },
                                 ),
-                              ))),
-                      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: () {
-                              Future.delayed(const Duration(seconds: 1), () {
-                                StoreProvider.of<AppState>(context)
-                                    .dispatch({"action": Actions.logout});
-                              });
+                                _cell('手机', userInfo.phone, showBorder: false, onTap: () {
+                                  Navigator.push(context, new CupertinoPageRoute(builder: (context) => new ChangeUserInfo(title: '手机号', val: userInfo.phone)));
+                                })
+                              ]),
+                              _sectionDivier(),
+                              _section([
+                                _cell(
+                                    '是否接收消息',
+                                    Switch(
+                                        value: true,
+                                        onChanged: (val) {
+                                          setState(() {
+                                            receiveMsg = val;
+                                          });
+                                        }),
+                                    showBorder: false)
+                              ]),
+                              _sectionDivier(),
+                              _section([
+                                _cell('检查更新', ' '),
+                                _cell('版本号', version, showBorder: false),
+                              ]),
+                            ],
+                          ),
+                        ),
+                      ),
+                    ),
+                    Positioned(
+                      bottom: 10,
+                      right: 15,
+                      left: 15,
+                      height: 48,
+                      child: FlatButton(
+                          textColor: Colors.white,
+                          color: PRIMARY_COLOR,
+                          highlightColor: Color(0xFF763434),
+                          child: Text(
+                            "退出登录",
+                            style: TextStyle(fontSize: 16, fontWeight: FontWeight.w700),
+                          ),
+                          onPressed: () {
+                            Future.delayed(const Duration(seconds: 1), () {
+                              StoreProvider.of<AppState>(context).dispatch({"action": Actions.logout});
+                            });
 
-                              Toast.show(context, '退出成功', 1500, 'success');
-                              Navigator.push(
-                                  context,
-                                  new MaterialPageRoute(
-                                      builder: (context) => new LoginFirst()));
-                            }),
-                      )
-                    ],
-                  )),
+                            Toast.show(context, '退出成功', 1500, 'success');
+                            Navigator.push(context, new MaterialPageRoute(builder: (context) => new LoginFirst()));
+                          }),
+                    )
+                  ],
+                ),
+              ),
               onWillPop: () {
                 Toast.hide();
                 Navigator.pop(context);
+                return Future.value(false);
               });
         });
   }
 
-  Widget _settingItem(userInfo, name, isNext) {
-    return Container(
-      padding: EdgeInsets.only(left: 15, right: 15),
-      color: BG_COLOR,
-      child: GestureDetector(
-        child: Column(
-          children: <Widget>[
-            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(userInfo, 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(userInfo);
-          } else if (name == '昵称') {
-            Navigator.push(
-                context,
-                new CupertinoPageRoute(
-                    builder: (context) => new ChangeUserInfo(
-                        title: '昵称', val: userInfo.nickname)));
-          } else if (name == '性别') {
-            showPicker(userInfo, context);
-          } else if (name == '生日') {
-            showPickerDate(userInfo, context);
-          } else if (name == '手机') {
-            Navigator.push(
-                context,
-                new CupertinoPageRoute(
-                    builder: (context) =>
-                        new ChangeUserInfo(title: '手机号', val: userInfo.phone)));
-          }
-        },
-      ),
-    );
-  }
-
-  Widget _centerWidget(userInfo, name) {
-    Widget _wiget;
-
-    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,
-        child: SizedBox(
-          width: 36,
-          height: 36,
-          child: CircleAvatar(backgroundImage: NetworkImage(userInfo.icon)),
-        ),
-      );
-    } else if (name == '昵称') {
-      _wiget = Text(
-        userInfo.nickname,
-        style: mainText,
-        textAlign: TextAlign.right,
-      );
-    } else if (name == '性别') {
-      if (userInfo.sex != null) {
-        _wiget = Text(
-          userInfo.sex,
-          style: mainText,
-          textAlign: TextAlign.right,
-        );
-      } else {
-        _wiget = Text(
-          '请添加性别信息',
-          style: placText,
-          textAlign: TextAlign.right,
-        );
-      }
-    } else if (name == '生日') {
-      if (userInfo.birthday != null) {
-        _wiget = Text(
-          readTimestamp(userInfo.birthday,'yy/MM/dd'),
-          style: mainText,
-          textAlign: TextAlign.right,
-        );
-      } else {
-        _wiget = Text(
-          '选择生日',
-          style: placText,
-          textAlign: TextAlign.right,
-        );
-      }
-    } else if (name == '手机') {
-      if (userInfo.phone != null) {
-        _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.phone != null) {
-        _wiget = Text(
-          'V1.2.20',
-          style: mainText,
-          textAlign: TextAlign.right,
-        );
-      }
-    } else {
-      _wiget = Text(
-        '',
-        style: mainText,
-        textAlign: TextAlign.right,
-      );
-    }
-
-    return _wiget;
-  }
-
   void updateUserInfo(userInfo, value, key) async {
     if (Toast.preToast == null) {
       Toast.show(context, '加载中', -1, 'loading');
     }
-    final Result res = await HttpManager.post('userInfo/update',
-        data: {"id": userInfo.id, key: value});
+    final Result res = await HttpManager.post('userInfo/update', data: {"id": userInfo.id, key: value});
     Toast.hide();
     if (res.success) {
       Toast.show(context, '修改成功', 1500, 'success');
@@ -330,52 +171,204 @@ class SettingState extends State<Setting> {
   void getUserInfo() async {
     Result res = await HttpManager.get("userInfo/getUserInfo");
     if (res.success) {
-      StoreProvider.of<AppState>(context)
-          .dispatch({"action": Actions.updateUser, "user": res.data});
+      StoreProvider.of<AppState>(context).dispatch({"action": Actions.updateUser, "user": res.data});
     } else {}
   }
 
-  showPicker(userInfo, 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(
-              userInfo, picker.getSelectedValues()[0].toString().trim(), 'sex');
-        }).showModal(context);
+  _chooseSex(BuildContext context) async {
+    String sex = await showCupertinoModalPopup(
+        context: context,
+        builder: (BuildContext context) {
+          return CupertinoActionSheet(
+            title: Text('选择性别'),
+            actions: <Widget>[
+              CupertinoActionSheetAction(
+                child: Text('男'),
+                onPressed: () {
+                  Navigator.pop(context, '男');
+                },
+              ),
+              CupertinoActionSheetAction(
+                child: Text('女'),
+                onPressed: () {
+                  Navigator.pop(context, '女');
+                },
+              ),
+              CupertinoDialogAction(
+                child: const Text('取消'),
+                isDestructiveAction: true,
+                onPressed: () {
+                  Navigator.pop(context);
+                },
+              )
+            ],
+          );
+        });
+    if (sex != null) {
+      updateUserInfo(StoreProvider.of<AppState>(context).state.userInfo, sex, 'sex');
+    }
+  }
+
+  _chooseBirthday(BuildContext context) async {
+    UserInfo userInfo = StoreProvider.of<AppState>(context).state.userInfo;
+    DateTime date = userInfo.birthday > 0 ? DateTime.fromMillisecondsSinceEpoch(userInfo.birthday) : DateTime.now();
+    DateTime res = await showCupertinoModalPopup<DateTime>(
+      context: context,
+      builder: (BuildContext context) {
+        return Container(
+          height: 216,
+          color: CupertinoColors.white,
+          child: Column(
+            children: <Widget>[
+              SizedBox(
+                height: 44,
+                child: Stack(
+                  children: <Widget>[
+                    Positioned(
+                      left: 0,
+                      top: 0,
+                      bottom: 0,
+                      child: CupertinoButton(
+                        child: Text(
+                          '取消',
+                          style: TextStyle(color: PRIMARY_COLOR),
+                        ),
+                        onPressed: () {
+                          Navigator.of(context).pop();
+                        },
+                      ),
+                    ),
+                    Positioned(
+                      right: 0,
+                      top: 0,
+                      bottom: 0,
+                      child: CupertinoButton(
+                        child: Text(
+                          '确定',
+                          style: TextStyle(color: PRIMARY_COLOR),
+                        ),
+                        onPressed: () {
+                          Navigator.of(context).pop(date);
+                        },
+                      ),
+                    )
+                  ],
+                ),
+              ),
+              Expanded(
+                flex: 1,
+                child: DefaultTextStyle(
+                  style: const TextStyle(
+                    color: CupertinoColors.black,
+                    fontSize: 22.0,
+                  ),
+                  child: GestureDetector(
+                    // Blocks taps from propagating to the modal sheet and popping.
+                    onTap: () {},
+                    child: SafeArea(
+                      top: false,
+                      child: CupertinoDatePicker(
+                        mode: CupertinoDatePickerMode.date,
+                        initialDateTime: date,
+                        onDateTimeChanged: (DateTime newDateTime) {
+                          date = newDateTime;
+                        },
+                      ),
+                    ),
+                  ),
+                ),
+              )
+            ],
+          ),
+        );
+      },
+    );
+    if (res != null) {
+      print(res);
+      updateUserInfo(userInfo, res.millisecondsSinceEpoch, 'birthday');
+    }
+  }
+
+  _chooseImage(BuildContext context) async {
+    UserInfo userInfo = StoreProvider.of<AppState>(context).state.userInfo;
+    var image = await FilePicker.getFilePath(type: FileType.IMAGE);
+    Toast.show(context, '加载中', -1, 'loading');
+    File _image = File(image);
+    _image.readAsBytes().then((bytes) async {
+      String encoded1 = 'data:image/jpeg;base64,' + base64Encode(bytes);
+      FormData formData = new FormData.from({"base64": encoded1});
+      final response = await Dio().post(domain + 'assets/uploadImg', data: formData);
+      final res = json.decode(response.toString());
+      if (res['success']) {
+        updateUserInfo(userInfo, res['data'], 'icon');
+      }
+    });
+  }
+
+  Widget _sectionDivier() {
+    return SizedBox(height: 10);
+  }
+
+  Widget _section(List<Widget> children) {
+    return Container(
+      color: CELL_COLOR,
+      child: Column(
+        children: children,
+      ),
+    );
   }
 
-  showPickerDate(userInfo, 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(
-              userInfo,
-              DateTime.parse(picker.adapter.toString()).millisecondsSinceEpoch,
-              'birthday');
-        }).showDialog(context);
+  Widget _cell(String title, dynamic child, {String placeholder, void Function() onTap, bool showBorder = true}) {
+    Widget secondChild;
+    if (child == null || (child is String && child.length == 0)) {
+      secondChild = Text(
+        placeholder ?? '',
+        style: TextStyle(color: PLACEHOLDER_COLOR, fontSize: 13),
+      );
+    } else if (child is String) {
+      secondChild = Text(
+        child ?? '',
+        style: TextStyle(color: Colors.white, fontSize: 15),
+      );
+    } else {
+      secondChild = child;
+    }
+    return Container(
+      height: 60,
+      padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
+      child: GestureDetector(
+        onTap: onTap,
+        child: Container(
+          decoration: BoxDecoration(
+            border: Border(
+              bottom: BorderSide(
+                color: Color(0x2E000000),
+                width: showBorder ? 1 : 0,
+              ),
+            ),
+          ),
+          child: Row(
+            mainAxisAlignment: MainAxisAlignment.center,
+            children: <Widget>[
+              Expanded(
+                child: Text(
+                  title ?? '',
+                  style: TextStyle(color: Colors.white, fontSize: 14),
+                ),
+              ),
+              secondChild,
+              Padding(
+                padding: EdgeInsets.only(left: 2),
+                child: Image.asset(
+                  "images/icon_inter.png",
+                  width: 24,
+                  height: 24,
+                ),
+              )
+            ],
+          ),
+        ),
+      ),
+    );
   }
 }

+ 9 - 0
lib/plugins/ScreenStramPlugin.dart

@@ -11,4 +11,13 @@ class ScreenStreamPlugin {
       return false;
     }
   }
+
+  static Future<bool> stop(String url) async {
+    try {
+      await _channel.invokeMethod("stop", []);
+      return true;
+    } catch (e) {
+      return false;
+    }
+  }
 }

+ 6 - 0
lib/styles/colors.dart

@@ -11,3 +11,9 @@ const BG_COLOR = const Color(0xFF2B2B42);
 
 //辅助背景色
 const BG_SUB_COLOR = const Color(0xFF222335);
+
+const PLACEHOLDER_COLOR = const Color(0xFF727785);
+
+const CELL_COLOR = const Color(0xFF3A3D5C);
+
+const PAGE_BACKGROUND_COLOR = const Color(0xFF1B1C2C);

+ 3 - 0
pubspec.yaml

@@ -10,6 +10,8 @@ environment:
 dependencies:
   flutter:
     sdk: flutter
+  flutter_localizations:
+    sdk: flutter
   cupertino_icons: ^0.1.2
   flutter_screenutil: ^0.4.2
   http: ^0.12.0
@@ -26,6 +28,7 @@ dependencies:
   file_picker: ^1.1.1
   json_serializable: ^2.0.2
   shared_preferences: ^0.5.1+1
+  package_info: ^0.4.0
 
 dev_dependencies:
   build_runner: ^1.1.1