LoginFirst.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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('手机快捷登录',
  47. style: TextStyle(
  48. color: Colors.white,
  49. fontSize: 28,
  50. fontWeight: FontWeight.w500)),
  51. ),
  52. Container(
  53. margin: EdgeInsets.only(top: 20),
  54. child: TextField(
  55. autofocus: true,
  56. keyboardType: TextInputType.phone,
  57. maxLength: 11,
  58. style: TextStyle(
  59. color: Colors.white,
  60. fontSize: 18,
  61. fontWeight: FontWeight.w500),
  62. decoration: InputDecoration(
  63. hintText: '输入手机号',
  64. hintStyle: TextStyle(
  65. fontSize: 16,
  66. color: Color(0xFF727785),
  67. ),
  68. prefixIcon: Container(
  69. padding: EdgeInsets.all(10),
  70. // color: PRIMARY_COLOR,
  71. child: Image.asset(
  72. 'images/list_icon_shouji.png',
  73. width: 20,
  74. ),
  75. ),
  76. // suffixIcon:Container(
  77. // padding: EdgeInsets.all(10),
  78. // // color: PRIMARY_COLOR,
  79. // child: Image.asset(
  80. // 'images/list_icon_shouji.png',
  81. // width: 20,
  82. // ),
  83. // ),
  84. counterStyle: TextStyle(
  85. color: BG_SUB_COLOR, fontSize: 0)),
  86. onChanged: (value) {
  87. inputVal = value;
  88. })),
  89. Text('未注册的手机号验证后自动创建账户',
  90. style: TextStyle(
  91. color: Color(0xFF727785), fontSize: 13)),
  92. Container(
  93. margin: EdgeInsets.symmetric(vertical: 22),
  94. decoration: BoxDecoration(
  95. gradient: LinearGradient(
  96. begin: Alignment.topCenter,
  97. end: Alignment.bottomCenter,
  98. colors: [
  99. Color(0xFFFFC30F),
  100. Color(0xFFFFA54C)
  101. ])),
  102. width: double.infinity,
  103. height: 48,
  104. child: Material(
  105. color: Colors.transparent,
  106. child: InkWell(
  107. onTap: () {
  108. if (!checkPhone(inputVal)) {
  109. Toast.show(context, '手机号格式错误', 1500, 'info');
  110. } else {
  111. Navigator.push(
  112. context,
  113. CupertinoPageRoute(
  114. builder: (context) =>
  115. LoginSecond(phone: inputVal),
  116. ),
  117. );
  118. }
  119. },
  120. child: Center(
  121. child: Text(
  122. '下一步',
  123. style: TextStyle(
  124. fontSize: 16,
  125. fontWeight: FontWeight.w500,
  126. color: Colors.white),
  127. )),
  128. ),
  129. ),
  130. // FlatButton(
  131. // textColor: Colors.white,
  132. // color: PRIMARY_COLOR,
  133. // highlightColor: Color(0xFF763434),
  134. // child: Text('下一步'),
  135. // onPressed: () {
  136. // if (!checkPhone(inputVal)) {
  137. // Toast.show(context, '手机号格式错误', 1500, 'info');
  138. // } else {
  139. // Navigator.push(
  140. // context,
  141. // CupertinoPageRoute(
  142. // builder: (context) => LoginSecond(phone: inputVal),
  143. // ),
  144. // );
  145. // }
  146. // },
  147. // ),
  148. )
  149. ],
  150. ),
  151. ),
  152. )
  153. ],
  154. ),
  155. )),
  156. onWillPop: () {
  157. Toast.hide();
  158. // Navigator.pop(context);
  159. return Future.value(false);
  160. });
  161. }
  162. }