loginFirst.dart 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 '../styles/api.dart';
  7. import 'loginSecond.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. appBar: AppBar(
  19. backgroundColor: BG_SUB_COLOR,
  20. centerTitle: true,
  21. elevation: 0,
  22. leading: Container(),
  23. ),
  24. body: Container(
  25. width: double.infinity,
  26. padding: EdgeInsets.symmetric(vertical: 20, horizontal: 15),
  27. color: BG_SUB_COLOR,
  28. child: Column(
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: <Widget>[
  31. Text(
  32. 'LOGO',
  33. style: TextStyle(
  34. color: Colors.white,
  35. fontSize: 64,
  36. ),
  37. ),
  38. Container(
  39. margin: EdgeInsets.only(top: 30),
  40. child: Text('手机快捷登录',
  41. style: TextStyle(
  42. color: Colors.white,
  43. fontSize: 28,
  44. fontWeight: FontWeight.w500)),
  45. ),
  46. Container(
  47. margin: EdgeInsets.only(top: 20),
  48. child: TextField(
  49. autofocus: true,
  50. keyboardType: TextInputType.phone,
  51. maxLength: 11,
  52. style: TextStyle(
  53. color: Colors.white,
  54. fontSize: 18,
  55. fontWeight: FontWeight.w500),
  56. decoration: InputDecoration(
  57. hintText: "输入手机号",
  58. hintStyle: TextStyle(
  59. fontSize: 16,
  60. color: Color(0xFF727785),
  61. ),
  62. prefixIcon: Container(
  63. padding: EdgeInsets.all(10),
  64. // color: PRIMARY_COLOR,
  65. child: Image.asset(
  66. 'images/list_icon_shouji.png',
  67. width: 20,
  68. ),
  69. ),
  70. // suffixIcon:Container(
  71. // padding: EdgeInsets.all(10),
  72. // // color: PRIMARY_COLOR,
  73. // child: Image.asset(
  74. // 'images/list_icon_shouji.png',
  75. // width: 20,
  76. // ),
  77. // ),
  78. counterStyle:
  79. TextStyle(color: BG_SUB_COLOR, fontSize: 0)),
  80. onChanged: (value) {
  81. inputVal = value;
  82. })),
  83. Text('未注册的手机号验证后自动创建账户',
  84. style: TextStyle(color: Color(0xFF727785), fontSize: 13)),
  85. Container(
  86. margin: EdgeInsets.symmetric(vertical: 22),
  87. width: double.infinity,
  88. height: 48,
  89. child: FlatButton(
  90. textColor: Colors.white,
  91. color: PRIMARY_COLOR,
  92. highlightColor: Color(0xFFC2524D),
  93. child: Text("下一步"),
  94. onPressed: () {
  95. print(inputVal);
  96. if (!checkPhone(inputVal)) {
  97. Toast.show(context, '手机号格式错误', 1500, 'info');
  98. } else {
  99. Navigator.push(
  100. context,
  101. new CupertinoPageRoute(
  102. builder: (context) =>
  103. new LoginSecond(phone: inputVal),
  104. ),
  105. );
  106. }
  107. },
  108. ),
  109. )
  110. ],
  111. ),
  112. ),
  113. ),
  114. onWillPop: () {
  115. Toast.hide();
  116. print("返回键点击了");
  117. // Navigator.pop(context);
  118. });
  119. }
  120. }