|
|
@@ -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,
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
}
|
|
|
}
|