loginFirst.dart 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 new 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. Container(
  44. margin: EdgeInsets.only(top: 30),
  45. child: Text('手机快捷登录',
  46. style: TextStyle(
  47. color: Colors.white,
  48. fontSize: 28,
  49. fontWeight: FontWeight.w500)),
  50. ),
  51. Container(
  52. margin: EdgeInsets.only(top: 20),
  53. child: TextField(
  54. autofocus: true,
  55. keyboardType: TextInputType.phone,
  56. maxLength: 11,
  57. style: TextStyle(
  58. color: Colors.white,
  59. fontSize: 18,
  60. fontWeight: FontWeight.w500),
  61. decoration: InputDecoration(
  62. hintText: "输入手机号",
  63. hintStyle: TextStyle(
  64. fontSize: 16,
  65. color: Color(0xFF727785),
  66. ),
  67. prefixIcon: Container(
  68. padding: EdgeInsets.all(10),
  69. // color: PRIMARY_COLOR,
  70. child: Image.asset(
  71. 'images/list_icon_shouji.png',
  72. width: 20,
  73. ),
  74. ),
  75. // suffixIcon:Container(
  76. // padding: EdgeInsets.all(10),
  77. // // color: PRIMARY_COLOR,
  78. // child: Image.asset(
  79. // 'images/list_icon_shouji.png',
  80. // width: 20,
  81. // ),
  82. // ),
  83. counterStyle: TextStyle(
  84. color: BG_SUB_COLOR, fontSize: 0)),
  85. onChanged: (value) {
  86. inputVal = value;
  87. })),
  88. Text('未注册的手机号验证后自动创建账户',
  89. style: TextStyle(
  90. color: Color(0xFF727785), fontSize: 13)),
  91. Container(
  92. margin: EdgeInsets.symmetric(vertical: 22),
  93. width: double.infinity,
  94. height: 48,
  95. child: FlatButton(
  96. textColor: Colors.white,
  97. color: PRIMARY_COLOR,
  98. highlightColor: Color(0xFF763434),
  99. child: Text("下一步"),
  100. onPressed: () {
  101. print(inputVal);
  102. if (!checkPhone(inputVal)) {
  103. Toast.show(context, '手机号格式错误', 1500, 'info');
  104. } else {
  105. Navigator.push(
  106. context,
  107. new CupertinoPageRoute(
  108. builder: (context) =>
  109. new LoginSecond(phone: inputVal),
  110. ),
  111. );
  112. }
  113. },
  114. ),
  115. )
  116. ],
  117. ),
  118. ),
  119. )
  120. ],
  121. ),
  122. )),
  123. onWillPop: () {
  124. Toast.hide();
  125. // Navigator.pop(context);
  126. return Future.value(false);
  127. });
  128. }
  129. }