123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- import 'dart:async';
-
- import 'package:farmer_client/components/UI/DefaultButton.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
-
- import '../../widgets/Cell.dart';
-
- class MyRouteLogin extends StatefulWidget {
- @override
- State<MyRouteLogin> createState() => _RouteLogin();
- }
-
- class _RouteLogin extends State<MyRouteLogin> {
- bool isButtonEnable = true;
- String buttonText = '发送验证码';
- int count = 5;
- var timer;
- TextEditingController mController = TextEditingController();
- void _buttonClickListen() {
- print('获取验证码按钮');
- setState(() {
- if (isButtonEnable) {
-
- isButtonEnable = false;
- _initTimer();
- return null;
- } else {
-
-
- return null;
- }
- });
- }
-
- void _initTimer() {
- timer = new Timer.periodic(Duration(seconds: 1), (Timer timer) {
- count--;
- setState(() {
- if (count == 0) {
- timer.cancel();
- isButtonEnable = true;
- count = 5;
- buttonText = '发送验证码';
- } else {
- buttonText = '重新发送($count)';
- }
- });
- });
- }
-
- @override
- void dispose() {
- timer?.cancel();
- timer = null;
- mController.dispose();
- super.dispose();
- }
-
-
- var handlePhones = '';
- var handleCodes = '';
-
- void _handlePhone(e) => {
- setState(() => {handlePhones = e})
- };
-
- void _handleCode(e) => {
- setState(() => {handleCodes = e})
- };
-
- var userContent = {'phones': '', 'code': ''};
-
- void phoneUser() => {
- setState(() {
- userContent['phones'] = handlePhones;
- userContent['code'] = handleCodes;
- }),
- print('我输入的信息:${userContent},手机号:${userContent['phones']}')
- };
-
- @override
- Widget build(BuildContext context) {
- return Container(
- width: 12.w,
- decoration: const BoxDecoration(
- image: DecorationImage(
- image: AssetImage("images/icon_login.png"),
- fit: BoxFit.cover,
- ),
- ),
- child: Scaffold(
- backgroundColor: Colors.transparent,
- appBar: AppBar(
- backgroundColor: Colors.transparent,
-
- title: const Text('登陆'),
- ),
- body: Center(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- '您好!',
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 50,
- ),
- ),
- Text(
- '欢迎进入农户端应用!',
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 35,
- ),
- ),
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Cell(
- margin: EdgeInsets.symmetric(horizontal: 13.w),
- header: Text(
- "+86",
- style: TextStyle(fontSize: 19.sp),
- ),
- child: TextField(
- style: TextStyle(
- fontSize: 17.sp,
- ),
- decoration: const InputDecoration(
- isCollapsed: true,
- contentPadding:
- EdgeInsets.symmetric(vertical: 8, horizontal: 16),
- labelText: "请输入手机号码",
- border: InputBorder.none,
-
-
-
-
- floatingLabelBehavior: FloatingLabelBehavior.never,
- )),
- footer: ElevatedButton(
- onPressed: () => {
- setState(() {
- if (isButtonEnable) {
- _buttonClickListen();
- } else {
- return;
- }
- })
- },
- child: Text(
- '$buttonText',
- style: TextStyle(fontSize: 15.sp),
- ),
- style: ElevatedButton.styleFrom(
- primary: const Color(0xFFFF703B),
- elevation: 0,
- shape: const RoundedRectangleBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(10)))),
- ),
- ),
-
- TextField(
- keyboardType: TextInputType.number,
- cursorColor: Color(0xD4D4D4FF),
- decoration: const InputDecoration(
- hintText: "请输入验证码", prefixIcon: Icon(Icons.beenhere)),
- onChanged: (e) {
- _handleCode(e);
- },
- ),
-
-
- Container(
- child: DefaultButton(
- margin:
- EdgeInsets.fromLTRB(0, 30.0, 0, 0),
- text: "登陆",
- width: 200.0,
- height: 50.0,
- fontSize: 20.0,
- backColor: Color(0xffff703b),
- color: Colors.white,
- onPressed: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) {
- return MyRouteLogin();
- }),
- );
- },
- ),
- )
- ],
- ))));
- }
- }
|