import 'package:flutter/material.dart'; import '../widget/ITextInput.dart'; import '../widget/LinearButton.dart'; import '../net/HttpManager.dart'; import '../net/Result.dart'; import 'package:redux/redux.dart'; import 'package:flutter_redux/flutter_redux.dart'; import '../redux/AppState.dart'; import '../model/UserInfo.dart'; import '../styles/totast.dart'; class ChangePassword extends StatefulWidget { @override _ChangePasswordState createState() => _ChangePasswordState(); } class _ChangePasswordState extends State with WidgetsBindingObserver { String password_old = ''; String password_new = ''; String password_se = ''; @override Widget build(BuildContext context) { return StoreConnector( converter: (Store store) => store.state.userInfo, builder: (context, userInfo) { return Scaffold( appBar: AppBar( title: Text('修改密码'), ), backgroundColor: Color(0xFF23253C), body: Column( children: [ Container( height: 10, ), ITextField( keyboardType: ITextInputType.password, prefixIcon: Container( 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(() { password_old = content; }); }, counterStyle: TextStyle(color: Color(0xFF000000), fontSize: 0), ), Container( height: 10, ), ITextField( keyboardType: ITextInputType.password, prefixIcon: Container( 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(() { password_new = content; }); }, counterStyle: TextStyle(color: Color(0xFF000000), fontSize: 0), ), Container( height: 10, ), ITextField( keyboardType: ITextInputType.password, prefixIcon: Container( 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(() { password_se = content; }); }, counterStyle: TextStyle(color: Color(0xFF000000), fontSize: 0), ), Container( height: 52, ), Padding( padding: EdgeInsets.symmetric(horizontal: 15), child: LinearButton( btnHeight: 48.0, btntext: '确认修改', textColor: (password_new == password_se && password_se != '' && password_old != '') ? Colors.white : Color(0xFF15151D), colorList: (password_new == password_se && password_se != '' && password_old != '') ? [Color(0xFFD4504B), Color(0xFFD4504B)] : [Color(0xFF727785), Color(0xFF727785)], onTapHomeMenu: (password_new == password_se && password_se != '' && password_old != '') ? () async { Toast.show(context, '加载中', -1, 'loading'); Result res = await HttpManager.post('userInfo/changePassword', data: {"userId": userInfo.id, "oldPassword": password_old, "newPassword": password_new}); Toast.hide(); if (res.success) { Toast.show(context, '修改成功', 1500, 'success'); Navigator.of(context).pop(); } else { Toast.show(context, res.error, 1500, 'info'); } } : null, ), ) ], ), ); }); } }