提交 e5605df8 authored 作者: yueweilu's avatar yueweilu

忘记密码页面布局

上级 de62e122
part of forget_pwd;
class ForgetPwdController extends GetxController {
// 账号
final TextEditingController phoneInput = TextEditingController();
// 验证码
final TextEditingController codeInput = TextEditingController();
// 定时器
late Timer _timer;
// 按钮是否可用
bool _enable = false;
bool get enable => _enable;
// 倒计时60秒
int _countDown = 60;
int get countDown => _countDown;
bool _isCounting = false;
bool get isCounting => _isCounting;
// 开启定时器
void start() {
_isCounting = true;
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (_countDown > 1) {
_countDown--;
} else {
stop();
}
update();
});
}
// 停止计时器
void stop() {
if (_timer != null){
_timer.cancel();
_isCounting = false;
}
_countDown = 60;
}
void setCanClick(){
if (phoneInput.text.length == 11 && codeInput.text.length == 4){
_enable = true;
}
else{
_enable = false;
}
update();
}
@override
void onInit() {
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
// 定时器回调
});
/// 测试账号
if (kDebugMode) {
phoneInput.text = '13521054068';
codeInput.text = '123456';
}
super.onInit();
}
@override
void onClose() {
phoneInput.dispose();
codeInput.dispose();
_timer.cancel();
_isCounting = false;
super.onClose();
}
}
\ No newline at end of file
library forget_pwd;
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../theme.dart';
import '../../utils/index.dart';
import '../../widgets/index.dart';
part 'view.dart';
part 'controller.dart';
\ No newline at end of file
part of forget_pwd;
class ForgetPwdPage extends StatefulWidget {
const ForgetPwdPage({Key? key}) : super(key: key);
@override
State<ForgetPwdPage> createState() => _ForgetPwdPageState();
}
class _ForgetPwdPageState extends State<ForgetPwdPage> {
@override
Widget build(BuildContext context) {
return GetBuilder<ForgetPwdController>(
init: ForgetPwdController(),
builder: (controller) =>Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('忘记密码'),
),
body: Container(
margin: const EdgeInsets.only(left: 10, right: 10,top: 15),
child: Column(
children: [
CustomFormInput(
// label: 'Phone',
// required: true,
hintText: '请输入手机号',
keyboardType: TextInputType.number,
controller: controller.phoneInput,
onChanged: (text){
controller.setCanClick();
},
),
Gaps.vGaps10,
Stack(
alignment: Alignment.centerRight,
children: [
CustomFormInput(
// label: 'Phone',
// required: true,
hintText: '请输入验证码',
keyboardType: TextInputType.number,
controller: controller.codeInput,
onChanged: (text){
controller.setCanClick();
},
),
Positioned(
right: 10,
child: Row(
children: [
Container(height: 20,width: 1,color: const Color(0xFFEBEBEB),),
Gaps.hGaps10,
GestureDetector(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
color: Colors.yellow,
child: Text(controller.isCounting?'${controller.countDown}':'获取验证码',style: const TextStyle(fontSize: 11,color: AppTheme.primary,height: 1.4),)),
onTap: (){
controller.start();
},
),
],
)
),
],
),
Gaps.vGaps40,
CustomGradientButton(
text: '立即登录',
isEnabled: !controller.enable,
onPressed: () {
},
)
],
),
),
),
);
}
}
......@@ -134,7 +134,12 @@ class _LoginPageState extends State<LoginPage> {
controller.updateLoginType(0);
},
),
controller.loginType == 0? const Text('忘记密码',style: TextStyle(fontSize: 13,height: 1.3,color: Colours.cBlue),):const Text('*登录后将自动完成注册',style: TextStyle(fontSize: 13,height: 1.3,color: Colours.c6),),
controller.loginType == 0? GestureDetector(
child: const Text('忘记密码',style: TextStyle(fontSize: 13,height: 1.3,color: Colours.cBlue),),
onTap: (){
context.pushNamed(Routes.forgetPwd);
},
):const Text('*登录后将自动完成注册',style: TextStyle(fontSize: 13,height: 1.3,color: Colours.c6),),
],
)
),
......
......@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_book/pages/about/index.dart';
import 'package:flutter_book/pages/ad/index.dart';
import 'package:flutter_book/pages/book_pay/index.dart';
import 'package:flutter_book/pages/forget_pwd/index.dart';
import 'package:flutter_book/pages/login/index.dart';
import 'package:flutter_book/pages/main/index.dart';
import 'package:flutter_book/pages/splash/index.dart';
......
......@@ -7,18 +7,25 @@ abstract class Routes {
static const splash = 'splash';
static const main = 'main';
static const ad = 'ad';
static const login = 'login';
static const web = 'web';
static const about = 'about';
/// 支付界面
// 支付界面
static const bookPay = 'book_pay';
/// 用户协议 和 隐私政策
// 用户协议 和 隐私政策
static const terms = 'terms';
/// 消息
static const msgs = 'msgs';
/// 我的
/// 登录模块
// 登录
static const login = 'login';
// 忘记密码
static const forgetPwd = 'forget_pwd';
// 重置密码
static const resetPwd = 'reset_pwd';
/// 我的模块
// 个人信息
static const userInfo = 'user_info';
// 修改昵称
......@@ -35,6 +42,8 @@ abstract class Routes {
static const collect = 'collect';
// 紫金币
static const coin = 'coin';
// 消息
static const msgs = 'msgs';
static final GoRouter config = GoRouter(
......@@ -149,6 +158,15 @@ abstract class Routes {
key: state.pageKey,
child: const UserCoinPage()
)
),
GoRoute(
path: '/$forgetPwd',
name: forgetPwd,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: const ForgetPwdPage()
)
)
]
);
......
......@@ -35,6 +35,7 @@ class Gaps {
static const Widget vGaps10 = SizedBox(height: 10,);
static const Widget vGaps13 = SizedBox(height: 13,);
static const Widget vGaps15 = SizedBox(height: 15,);
static const Widget vGaps40 = SizedBox(height: 40,);
// static const Widget line = Padding(
// padding: EdgeInsets.symmetric(horizontal: 15.0),
// child: Divider(color: Colours.cLine,),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论