login_page.dart 6.0 KB

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