loginFirst.dart 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import '../styles/colors.dart';
  4. import 'dart:ui';
  5. import '../styles/totast.dart';
  6. import 'LoginSecond.dart';
  7. import '../utils/Utils.dart';
  8. class LoginFirst extends StatefulWidget {
  9. @override
  10. LoginFirstState createState() => LoginFirstState();
  11. }
  12. class LoginFirstState extends State<LoginFirst> {
  13. String inputVal;
  14. @override
  15. Widget build(BuildContext context) {
  16. return WillPopScope(
  17. child: Scaffold(
  18. body: Container(
  19. color: BG_SUB_COLOR,
  20. child: CustomScrollView(
  21. slivers: <Widget>[
  22. SliverAppBar(
  23. backgroundColor: BG_SUB_COLOR,
  24. centerTitle: true,
  25. elevation: 0,
  26. leading: Container(),
  27. ),
  28. SliverToBoxAdapter(
  29. child: Container(
  30. width: double.infinity,
  31. padding: EdgeInsets.symmetric(vertical: 20, horizontal: 15),
  32. color: BG_SUB_COLOR,
  33. child: Column(
  34. crossAxisAlignment: CrossAxisAlignment.start,
  35. children: <Widget>[
  36. // Text(
  37. // 'LOGO',
  38. // style: TextStyle(
  39. // color: Colors.white,
  40. // fontSize: 64,
  41. // ),
  42. // ),
  43. Image.asset('images/icon_logo.png'),
  44. Container(
  45. margin: EdgeInsets.only(top: 30),
  46. child: Text('手机快捷登录', style: TextStyle(color: Colors.white, fontSize: 28, fontWeight: FontWeight.w500)),
  47. ),
  48. Container(
  49. margin: EdgeInsets.only(top: 20),
  50. child: TextField(
  51. autofocus: true,
  52. keyboardType: TextInputType.phone,
  53. maxLength: 11,
  54. style: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500),
  55. decoration: InputDecoration(
  56. hintText: '输入手机号',
  57. hintStyle: TextStyle(
  58. fontSize: 16,
  59. color: Color(0xFF727785),
  60. ),
  61. prefixIcon: Container(
  62. padding: EdgeInsets.all(10),
  63. // color: PRIMARY_COLOR,
  64. child: Image.asset(
  65. 'images/list_icon_shouji.png',
  66. width: 20,
  67. ),
  68. ),
  69. // suffixIcon:Container(
  70. // padding: EdgeInsets.all(10),
  71. // // color: PRIMARY_COLOR,
  72. // child: Image.asset(
  73. // 'images/list_icon_shouji.png',
  74. // width: 20,
  75. // ),
  76. // ),
  77. counterStyle: TextStyle(color: BG_SUB_COLOR, fontSize: 0)),
  78. onChanged: (value) {
  79. inputVal = value;
  80. })),
  81. Text('未注册的手机号验证后自动创建账户', style: TextStyle(color: Color(0xFF727785), fontSize: 13)),
  82. Container(
  83. margin: EdgeInsets.symmetric(vertical: 22),
  84. width: double.infinity,
  85. height: 48,
  86. child: FlatButton(
  87. textColor: Colors.white,
  88. color: PRIMARY_COLOR,
  89. highlightColor: Color(0xFF763434),
  90. child: Text('下一步'),
  91. onPressed: () {
  92. if (!checkPhone(inputVal)) {
  93. Toast.show(context, '手机号格式错误', 1500, 'info');
  94. } else {
  95. Navigator.push(
  96. context,
  97. CupertinoPageRoute(
  98. builder: (context) => LoginSecond(phone: inputVal),
  99. ),
  100. );
  101. }
  102. },
  103. ),
  104. )
  105. ],
  106. ),
  107. ),
  108. )
  109. ],
  110. ),
  111. )),
  112. onWillPop: () {
  113. Toast.hide();
  114. // Navigator.pop(context);
  115. return Future.value(false);
  116. });
  117. }
  118. }