register_page.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_auth/models/config.dart';
  3. import 'package:flutter_auth/pages/background.dart';
  4. import 'package:flutter_auth/pages/login_page.dart';
  5. import 'package:flutter_auth/views/already_have_an_account_check.dart';
  6. import 'package:flutter_auth/views/responsive.dart';
  7. import 'package:flutter_svg/flutter_svg.dart';
  8. /// Description: register page
  9. /// Time : 08/24/2023 Thursday
  10. /// Author : liuyuqi.gov@msn.cn
  11. class RegisterPage extends StatefulWidget {
  12. const RegisterPage({super.key});
  13. @override
  14. State<RegisterPage> createState() => _RegisterPageState();
  15. }
  16. class _RegisterPageState extends State<RegisterPage> {
  17. @override
  18. Widget build(BuildContext context) {
  19. return Background(
  20. child: SingleChildScrollView(
  21. child: Responsive(
  22. desktop: buildRegisterDesktop(),
  23. mobile: buildRegisterMobile(),
  24. ),
  25. ));
  26. }
  27. Widget buildRegisterDesktop() {
  28. return Row(
  29. children: [
  30. Expanded(child: RegisterTop()),
  31. Expanded(
  32. child: Column(
  33. mainAxisAlignment: MainAxisAlignment.center,
  34. children: [
  35. SizedBox(
  36. width: 450,
  37. child: RegisterForm(),
  38. ),
  39. SizedBox(
  40. height: defaultPadding / 2,
  41. ),
  42. // SocalSigUp()
  43. ],
  44. ))
  45. ],
  46. );
  47. }
  48. Widget buildRegisterMobile() {
  49. return Column(
  50. mainAxisAlignment: MainAxisAlignment.center,
  51. children: [
  52. RegisterTop(),
  53. Row(
  54. children: [
  55. Spacer(),
  56. Expanded(
  57. child: RegisterForm(),
  58. flex: 8,
  59. ),
  60. Spacer()
  61. ],
  62. )
  63. ],
  64. );
  65. }
  66. }
  67. class RegisterTop extends StatelessWidget {
  68. const RegisterTop({super.key});
  69. @override
  70. Widget build(BuildContext context) {
  71. return Column(
  72. children: [
  73. Text(
  74. "Register",
  75. style: TextStyle(fontWeight: FontWeight.bold),
  76. ),
  77. SizedBox(
  78. height: defaultPadding,
  79. ),
  80. Row(
  81. children: [
  82. Spacer(),
  83. Expanded(
  84. flex: 8,
  85. child: SvgPicture.asset("assets/icons/signup.svg"),
  86. ),
  87. Spacer()
  88. ],
  89. ),
  90. // Text(
  91. // "Register with your email and password \nor continue with social media",
  92. // textAlign: TextAlign.center,
  93. // ),
  94. SizedBox(
  95. height: defaultPadding,
  96. ),
  97. // SocalSigUp()
  98. ],
  99. );
  100. }
  101. }
  102. class RegisterForm extends StatelessWidget {
  103. const RegisterForm({super.key});
  104. @override
  105. Widget build(BuildContext context) {
  106. return Form(
  107. child: Column(
  108. children: [
  109. TextFormField(
  110. keyboardType: TextInputType.emailAddress,
  111. textInputAction: TextInputAction.next,
  112. cursorColor: kPrimaryColor,
  113. onSaved: (value) {},
  114. decoration: InputDecoration(
  115. hintText: "邮箱账户",
  116. prefixIcon: Padding(
  117. child: Icon(Icons.person),
  118. padding: EdgeInsets.all(defaultPadding),
  119. )),
  120. ),
  121. Padding(
  122. padding: EdgeInsets.symmetric(vertical: defaultPadding),
  123. child: TextFormField(
  124. textInputAction: TextInputAction.done,
  125. obscureText: true,
  126. cursorColor: kPrimaryColor,
  127. decoration: InputDecoration(
  128. hintText: "密码",
  129. prefixIcon: Padding(
  130. child: Icon(Icons.lock),
  131. padding: EdgeInsets.all(defaultPadding),
  132. )),
  133. ),
  134. ),
  135. SizedBox(
  136. height: defaultPadding / 2,
  137. ),
  138. ElevatedButton(onPressed: () {}, child: Text("注册")),
  139. SizedBox(
  140. height: defaultPadding,
  141. ),
  142. AlreadyHaveAnAccountCheck(
  143. press: () {
  144. Navigator.push(context, MaterialPageRoute(builder: (context) {
  145. return LoginPage();
  146. }));
  147. },
  148. login: false,
  149. )
  150. ],
  151. ));
  152. }
  153. }