loginFirst.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import 'package:flutter/material.dart';
  2. import 'package:shared_preferences/shared_preferences.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import '../styles/colors.dart';
  5. import 'dart:ui';
  6. import '../styles/totast.dart';
  7. import '../styles/api.dart';
  8. import 'loginSecond.dart'; //登录第二页面
  9. class LoginFirst extends StatefulWidget {
  10. @override
  11. LoginFirstState createState() => LoginFirstState();
  12. }
  13. class LoginFirstState extends State<LoginFirst> {
  14. String inputVal;
  15. @override
  16. Widget build(BuildContext context) {
  17. return new WillPopScope(
  18. child: Scaffold(
  19. body: Container(
  20. color: BG_SUB_COLOR,
  21. child: CustomScrollView(
  22. slivers: <Widget>[
  23. SliverAppBar(
  24. backgroundColor: BG_SUB_COLOR,
  25. centerTitle: true,
  26. elevation: 0,
  27. leading: Container(),
  28. ),
  29. SliverToBoxAdapter(
  30. child: Container(
  31. width: double.infinity,
  32. padding: EdgeInsets.symmetric(vertical: 20, horizontal: 15),
  33. color: BG_SUB_COLOR,
  34. child: Column(
  35. crossAxisAlignment: CrossAxisAlignment.start,
  36. children: <Widget>[
  37. Text(
  38. 'LOGO',
  39. style: TextStyle(
  40. color: Colors.white,
  41. fontSize: 64,
  42. ),
  43. ),
  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. width: double.infinity,
  95. height: 48,
  96. child: FlatButton(
  97. textColor: Colors.white,
  98. color: PRIMARY_COLOR,
  99. highlightColor: Color(0xFF763434),
  100. child: Text("下一步"),
  101. onPressed: () {
  102. print(inputVal);
  103. if (!checkPhone(inputVal)) {
  104. Toast.show(context, '手机号格式错误', 1500, 'info');
  105. } else {
  106. Navigator.push(
  107. context,
  108. new CupertinoPageRoute(
  109. builder: (context) =>
  110. new LoginSecond(phone: inputVal),
  111. ),
  112. );
  113. }
  114. },
  115. ),
  116. )
  117. ],
  118. ),
  119. ),
  120. )
  121. ],
  122. ),
  123. )),
  124. onWillPop: () {
  125. Toast.hide();
  126. // Navigator.pop(context);
  127. return Future.value(false);
  128. });
  129. }
  130. }