login_page.dart 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. import 'package:awesome_login_page/models/config.dart';
  2. import 'package:awesome_login_page/views/login_card.dart';
  3. import 'package:awesome_login_page/views/my_header.dart';
  4. import 'package:awesome_login_page/views/social_icon.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter_screenutil/flutter_screenutil.dart';
  7. class LoginPage extends StatefulWidget {
  8. const LoginPage({super.key});
  9. @override
  10. State<LoginPage> createState() => _LoginPageState();
  11. }
  12. class _LoginPageState extends State<LoginPage> {
  13. final ScrollController _scrollController = ScrollController();
  14. double offset = 0;
  15. bool _isSelected = false;
  16. @override
  17. Widget build(BuildContext context) {
  18. ScreenUtil.init(context,
  19. designSize: const Size(750, 1334), scaleByHeight: true);
  20. return Scaffold(
  21. body: SingleChildScrollView(
  22. controller: _scrollController,
  23. child: Column(
  24. crossAxisAlignment: CrossAxisAlignment.start,
  25. children: [
  26. MyHeader(
  27. image: "assets/icons/barbecue.svg",
  28. textTop: "Order and",
  29. textBottom: "Get to door steps",
  30. offset: offset,
  31. ),
  32. Padding(
  33. padding: const EdgeInsets.symmetric(horizontal: 20),
  34. child: Column(
  35. crossAxisAlignment: CrossAxisAlignment.start,
  36. children: [
  37. CardLogin(),
  38. SizedBox(
  39. height: 20.h,
  40. ),
  41. Row(
  42. children: [
  43. SizedBox(
  44. width: 12.w,
  45. ),
  46. GestureDetector(
  47. onTap: _radio,
  48. child: buildRadioButton(_isSelected),
  49. ),
  50. const SizedBox(
  51. width: 8,
  52. ),
  53. Text(
  54. "Remmeber me",
  55. style: TextStyle(fontSize: 12.sp),
  56. ),
  57. ],
  58. ),
  59. InkWell(
  60. child: Container(
  61. child: Material(
  62. color: Colors.transparent,
  63. child: InkWell(
  64. onTap: () {},
  65. child: const Center(
  66. child: Text(
  67. "SIGNIN",
  68. style: TextStyle(
  69. color: Colors.white,
  70. fontSize: 18,
  71. letterSpacing: 1),
  72. ),
  73. )),
  74. ),
  75. ),
  76. ),
  77. SizedBox(
  78. height: 40.h,
  79. ),
  80. Row(
  81. mainAxisAlignment: MainAxisAlignment.center,
  82. children: [
  83. buildHorizontalLine(),
  84. Text(
  85. "Social Login",
  86. style: TextStyle(fontSize: 16.sp),
  87. ),
  88. buildHorizontalLine(),
  89. ],
  90. ),
  91. const SizedBox(
  92. height: 40,
  93. ),
  94. Row(
  95. mainAxisAlignment: MainAxisAlignment.center,
  96. children: [
  97. SocialIcon(
  98. color: Config.kFaceBookColor,
  99. icon: CustomIcons.facebook,
  100. press: () {
  101. facebookLoign();
  102. },
  103. ),
  104. SocialIcon(
  105. color: Config.kGoogleColor,
  106. icon: CustomIcons.googlePlus,
  107. press: () {
  108. googleLogin();
  109. })
  110. ],
  111. ),
  112. SizedBox(
  113. height: 30.h,
  114. ),
  115. Row(
  116. mainAxisAlignment: MainAxisAlignment.center,
  117. children: [
  118. const Text(
  119. "New User? ",
  120. style: TextStyle(fontSize: 18),
  121. ),
  122. InkWell(
  123. onTap: () {
  124. signup();
  125. },
  126. child: const Text(
  127. "SignUp",
  128. style: TextStyle(color: Color(0xFF5d74e3)),
  129. ),
  130. )
  131. ],
  132. )
  133. ]),
  134. ),
  135. ],
  136. ),
  137. ),
  138. );
  139. }
  140. /// 选中和取消选中
  141. void _radio() {
  142. setState(() {
  143. _isSelected = !_isSelected;
  144. });
  145. }
  146. /// 自定义选中按钮
  147. /// isSelected 是否选中
  148. Widget buildRadioButton(bool isSelected) {
  149. return Container(
  150. height: 16,
  151. width: 16,
  152. padding: const EdgeInsets.all(2),
  153. decoration: BoxDecoration(
  154. shape: BoxShape.circle,
  155. border: Border.all(width: 2, color: Colors.blue)),
  156. child: isSelected
  157. ? Container(
  158. width: double.infinity,
  159. height: double.infinity,
  160. decoration:
  161. const BoxDecoration(shape: BoxShape.circle, color: Colors.blue))
  162. : Container());
  163. }
  164. /// 自定义横线
  165. Widget buildHorizontalLine() {
  166. return Padding(
  167. padding: EdgeInsets.symmetric(horizontal: 16.w),
  168. child: Container(
  169. width: 120.w,
  170. height: 1.0,
  171. color: Colors.black26.withOpacity(.2),
  172. ));
  173. }
  174. /// register
  175. void signup() {}
  176. /// facebook login
  177. void facebookLoign() {}
  178. /// google login
  179. void googleLogin() {}
  180. }