loginFirst.dart 4.9 KB

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