login_page.dart 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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: Material(
  61. color: Colors.transparent,
  62. child: InkWell(
  63. onTap: () {},
  64. child: const Center(
  65. child: Text(
  66. "SIGNIN",
  67. style: TextStyle(
  68. color: Colors.white,
  69. fontSize: 18,
  70. letterSpacing: 1),
  71. ),
  72. )),
  73. ),
  74. ),
  75. SizedBox(
  76. height: 40.h,
  77. ),
  78. Row(
  79. mainAxisAlignment: MainAxisAlignment.center,
  80. children: [
  81. buildHorizontalLine(),
  82. Text(
  83. "Social Login",
  84. style: TextStyle(fontSize: 16.sp),
  85. ),
  86. buildHorizontalLine(),
  87. ],
  88. ),
  89. const SizedBox(
  90. height: 40,
  91. ),
  92. Row(
  93. mainAxisAlignment: MainAxisAlignment.center,
  94. children: [
  95. SocialIcon(
  96. color: Config.kFaceBookColor,
  97. icon: CustomIcons.facebook,
  98. press: () {
  99. facebookLoign();
  100. },
  101. ),
  102. SocialIcon(
  103. color: Config.kGoogleColor,
  104. icon: CustomIcons.googlePlus,
  105. press: () {
  106. googleLogin();
  107. })
  108. ],
  109. ),
  110. SizedBox(
  111. height: 30.h,
  112. ),
  113. Row(
  114. mainAxisAlignment: MainAxisAlignment.center,
  115. children: [
  116. const Text(
  117. "New User? ",
  118. style: TextStyle(fontSize: 18),
  119. ),
  120. InkWell(
  121. onTap: () {
  122. signup();
  123. },
  124. child: const Text(
  125. "SignUp",
  126. style: TextStyle(color: Color(0xFF5d74e3)),
  127. ),
  128. )
  129. ],
  130. )
  131. ]),
  132. ),
  133. ],
  134. ),
  135. ),
  136. );
  137. }
  138. /// 选中和取消选中
  139. void _radio() {
  140. setState(() {
  141. _isSelected = !_isSelected;
  142. });
  143. }
  144. /// 自定义选中按钮
  145. /// isSelected 是否选中
  146. Widget buildRadioButton(bool isSelected) {
  147. return Container(
  148. height: 16,
  149. width: 16,
  150. padding: const EdgeInsets.all(2),
  151. decoration: BoxDecoration(
  152. shape: BoxShape.circle,
  153. border: Border.all(width: 2, color: Colors.blue)),
  154. child: isSelected
  155. ? Container(
  156. width: double.infinity,
  157. height: double.infinity,
  158. decoration:
  159. const BoxDecoration(shape: BoxShape.circle, color: Colors.blue))
  160. : Container());
  161. }
  162. /// 自定义横线
  163. Widget buildHorizontalLine() {
  164. return Padding(
  165. padding: EdgeInsets.symmetric(horizontal: 16.w),
  166. child: Container(
  167. width: 120.w,
  168. height: 1.0,
  169. color: Colors.black26.withOpacity(.2),
  170. ));
  171. }
  172. /// register
  173. void signup() {}
  174. /// facebook login
  175. void facebookLoign() {}
  176. /// google login
  177. void googleLogin() {}
  178. }