| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import '../../util/session.dart';
- import '../../showAlert.dart';
- import '../../util/api.dart';
- class RevisePasswordPage extends StatefulWidget {
- final Widget child;
- RevisePasswordPage({
- Key key,
- this.child
- }): super(key: key);
- _RevisePasswordPageState createState() => _RevisePasswordPageState();
- }
- class _RevisePasswordPageState extends State < RevisePasswordPage > {
- String oldPassword = '';
- String newPassword = '';
- bool submitStatus = false;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- elevation: 0,
- title: Text('修改密码',
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(36)
- ), ),
- centerTitle: true,
- backgroundColor: Color.fromRGBO(64, 98, 254, 1),
- ),
- body: Container(
- color: Colors.white,
- child: Column(
- children: < Widget > [
- Container(
- padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(55), ScreenUtil.getInstance().setHeight(150), ScreenUtil.getInstance().setHeight(55), 0),
- child: Column(
- children: < Widget > [
- Padding(
- padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(60)),
- child: TextField(
- obscureText: true,
- decoration: InputDecoration(
- border: UnderlineInputBorder(),
- hintText: "请输入旧密码",
- hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Color.fromRGBO(155, 155, 155, 1)),
- ),
- onChanged: (value) {
- setState(() {
- oldPassword = value;
- });
- },
- ),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(125)),
- child: TextField(
- obscureText: true,
- cursorColor: Color.fromRGBO(153, 153, 153, 0.5),
- decoration: InputDecoration(
- hintText: "请输入新密码",
- hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Color.fromRGBO(155, 155, 155, 1)),
- ),
- onChanged: (value) {
- setState(() {
- newPassword = value;
- });
- },
- )
- ),
- InkWell(
- child: Container(
- height: ScreenUtil.getInstance().setHeight(100),
- decoration: BoxDecoration(
- color: (oldPassword != '' && newPassword != '') ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey,
- borderRadius: BorderRadius.circular(4),
- ),
- child: Center(
- child: Text('确认', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36), color: Colors.white)),
- ),
- ),
- onTap: () {
- if (oldPassword == '' || newPassword == '') {
- return;
- }
- getKey('password').then((value) {
- if (value != oldPassword) {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '旧密码错误,请重新输入', childCallback: (val) {},
- );
- });
- } else {
- updataPasswrod(oldPassword, newPassword).then((resp){
- if(resp.success && resp.code==1){
- setKey('password', newPassword);
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: '修改成功', childCallback: (val) {
- if(val){
- Navigator.pop(context);
- }
- },
- );
- });
- }else{
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return new LoadingDialog( //调用对话框
- text: resp.msg, childCallback: (val) {
- if(val){
- Navigator.pop(context);
- }
- },
- );
- });
- }
- });
- }
- });
- },
- )
- ],
- ),
- )
- ],
- ),
- ),
- );
- }
- }
|