view.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. import 'package:electronic_assistant/base/base_page.dart';
  2. import 'package:electronic_assistant/resource/assets.gen.dart';
  3. import 'package:electronic_assistant/resource/colors.gen.dart';
  4. import 'package:electronic_assistant/utils/expand.dart';
  5. import 'package:electronic_assistant/widget/login_code_btn.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter/services.dart';
  8. import 'package:flutter_screenutil/flutter_screenutil.dart';
  9. import 'package:get/get.dart';
  10. import 'controller.dart';
  11. class LoginPage extends BasePage<LoginController> {
  12. const LoginPage({super.key});
  13. @override
  14. bool immersive() {
  15. return true;
  16. }
  17. // 点击空白处收起键盘
  18. @override
  19. void backgroundOnTapEvent() {
  20. super.backgroundOnTapEvent();
  21. FocusScope.of(Get.context!).requestFocus(FocusNode());
  22. }
  23. @override
  24. Widget buildBody(BuildContext context) {
  25. return Stack(
  26. children: [
  27. buildBackgroundImage(),
  28. Scaffold(
  29. resizeToAvoidBottomInset: false,
  30. backgroundColor: Colors.transparent,
  31. appBar: AppBar(
  32. leading: IconButton(
  33. icon: const Icon(Icons.arrow_back_ios),
  34. onPressed: () {
  35. Navigator.pop(context);
  36. },
  37. ),
  38. backgroundColor: Colors.transparent,
  39. systemOverlayStyle: SystemUiOverlayStyle.dark,
  40. ),
  41. body: Column(
  42. crossAxisAlignment: CrossAxisAlignment.start,
  43. children: [
  44. Container(
  45. margin: EdgeInsets.only(left: 28.w, top: 64.h),
  46. width: 194.w,
  47. height: 71.h,
  48. child: Image(image: Assets.images.iconLoginLogo.provider()),
  49. ),
  50. Container(
  51. margin: EdgeInsets.only(top: 44.h, left: 28.w, right: 28.w),
  52. alignment: Alignment.center,
  53. height: 44.h,
  54. decoration: BoxDecoration(
  55. border: Border(
  56. bottom: BorderSide(
  57. width: 1.0,
  58. color: "#F0F0F0".toColor(),
  59. ),
  60. ),
  61. ),
  62. child: TextField(
  63. maxLines: 1,
  64. textAlignVertical: TextAlignVertical.center,
  65. textInputAction: TextInputAction.search,
  66. decoration: InputDecoration(
  67. hintText: '输入手机号码',
  68. hintStyle:
  69. TextStyle(fontSize: 16, color: "#AFAFAF".toColor()),
  70. labelStyle: const TextStyle(
  71. fontSize: 16,
  72. color: ColorName.primaryTextColor,
  73. ),
  74. contentPadding: const EdgeInsets.all(0),
  75. border:
  76. const OutlineInputBorder(borderSide: BorderSide.none),
  77. enabled: true,
  78. ),
  79. style: TextStyle(fontSize: 14.sp),
  80. onChanged: (value) {
  81. controller.setPhone(value);
  82. },
  83. ),
  84. ),
  85. Container(
  86. margin: EdgeInsets.only(top: 36.h, left: 28.w, right: 28.w),
  87. alignment: Alignment.center,
  88. height: 44.h,
  89. decoration: BoxDecoration(
  90. border: Border(
  91. bottom: BorderSide(
  92. width: 1.0,
  93. color: "#F0F0F0".toColor(),
  94. ),
  95. ),
  96. ),
  97. child: Row(
  98. children: [
  99. Expanded(
  100. child: TextField(
  101. maxLines: 1,
  102. textAlignVertical: TextAlignVertical.center,
  103. textInputAction: TextInputAction.search,
  104. decoration: InputDecoration(
  105. hintText: '输入验证码',
  106. hintStyle: TextStyle(
  107. fontSize: 16, color: "#AFAFAF".toColor()),
  108. labelStyle: const TextStyle(
  109. fontSize: 16,
  110. color: ColorName.primaryTextColor,
  111. ),
  112. contentPadding: const EdgeInsets.all(0),
  113. border: const OutlineInputBorder(
  114. borderSide: BorderSide.none),
  115. enabled: true,
  116. ),
  117. style: TextStyle(fontSize: 14.sp),
  118. onChanged: (value) {
  119. controller.setCode(value);
  120. },
  121. ),
  122. ),
  123. LoginCodeBtn(
  124. onTapCallback: () {
  125. controller.getUserCode();
  126. },
  127. available: true,
  128. ),
  129. ],
  130. ),
  131. ),
  132. GestureDetector(
  133. onTap: () {
  134. controller.login();
  135. },
  136. child: Container(
  137. margin: EdgeInsets.only(
  138. top: 54.h,
  139. left: 28.w,
  140. right: 28.w,
  141. ),
  142. height: 48.h,
  143. alignment: Alignment.center,
  144. decoration: BoxDecoration(
  145. gradient: LinearGradient(
  146. colors: ['#6177F2'.toColor(), '#8B9DFF'.toColor()],
  147. stops: const [0, 1.0],
  148. ),
  149. borderRadius: BorderRadius.circular(8),
  150. ),
  151. child: const Text(
  152. "登录",
  153. style: TextStyle(
  154. color: ColorName.white,
  155. fontSize: 16,
  156. fontWeight: FontWeight.w500,
  157. ),
  158. ),
  159. ),
  160. ),
  161. Container(
  162. margin: EdgeInsets.only(left: 28.w, top: 16.h),
  163. child: Row(
  164. children: [
  165. Obx(
  166. () {
  167. return GestureDetector(
  168. onTap: () {
  169. controller.isAgree.value =
  170. !controller.isAgree.value;
  171. },
  172. child: SizedBox(
  173. width: 20.w,
  174. height: 20.w,
  175. child: controller.isAgree.value
  176. ? Assets.images.iconSelectTrue.image()
  177. : Assets.images.iconSelectFalse.image()),
  178. );
  179. },
  180. ),
  181. Text(
  182. "我已阅读并同意",
  183. style: TextStyle(
  184. color: "#AFAFAF".toColor(),
  185. fontSize: 12,
  186. ),
  187. ),
  188. GestureDetector(
  189. onTap: () {},
  190. child: Text(
  191. "《隐私政策》",
  192. style: TextStyle(
  193. color: "#5E8BFF".toColor(),
  194. fontSize: 12,
  195. ),
  196. ),
  197. ),
  198. Text(
  199. "和",
  200. style: TextStyle(
  201. color: "#AFAFAF".toColor(),
  202. fontSize: 12,
  203. ),
  204. ),
  205. GestureDetector(
  206. onTap: () {},
  207. child: Text(
  208. "《用户使用协议》",
  209. style: TextStyle(
  210. color: "#5E8BFF".toColor(),
  211. fontSize: 12,
  212. ),
  213. ),
  214. ),
  215. ],
  216. ),
  217. ),
  218. ],
  219. ),
  220. ),
  221. ],
  222. );
  223. // return Scaffold(
  224. // body: Column(
  225. // children: <Widget>[
  226. // TextField(
  227. // onChanged: (text) {
  228. // controller.setPhone(text);
  229. // },
  230. // decoration: const InputDecoration(
  231. // labelText: "手机号",
  232. // hintText: "您的手机号",
  233. // prefixIcon: Icon(Icons.person)),
  234. // ),
  235. // TextField(
  236. // onChanged: (text) {
  237. // controller.setCode(text);
  238. // },
  239. // decoration: const InputDecoration(
  240. // labelText: "验证码",
  241. // hintText: "您的验证码",
  242. // prefixIcon: Icon(Icons.lock)),
  243. // ),
  244. // ElevatedButton(
  245. // child: const Text("获取验证码"),
  246. // onPressed: () {
  247. // controller.getUserCode();
  248. // },
  249. // ),
  250. // ElevatedButton(
  251. // child: const Text("登录"),
  252. // onPressed: () {
  253. // controller.login();
  254. // },
  255. // )
  256. // ],
  257. // ),
  258. // );
  259. }
  260. Widget buildBackgroundImage() {
  261. return Image(image: Assets.images.bgLogin.provider());
  262. }
  263. Widget buildBackgroundGradient() {
  264. return Stack(
  265. children: [
  266. Container(
  267. width: 1.sw,
  268. height: 1.sh,
  269. decoration: BoxDecoration(
  270. gradient: LinearGradient(
  271. colors: [
  272. '#FFC0CF'.toColor().withOpacity(0.62),
  273. '#F6F6F6'.toColor().withOpacity(0)
  274. ],
  275. begin: Alignment.topCenter,
  276. end: Alignment.bottomCenter,
  277. stops: const [0, 1.0],
  278. ),
  279. ),
  280. ),
  281. Container(
  282. width: 1.sw,
  283. height: 1.sh,
  284. decoration: BoxDecoration(
  285. gradient: LinearGradient(
  286. colors: [
  287. '#CADCFD'.toColor().withOpacity(0.72),
  288. '#F6F5F8'.toColor().withOpacity(0.72)
  289. ],
  290. begin: Alignment.topCenter,
  291. end: Alignment.bottomCenter,
  292. stops: const [0, 1.0],
  293. ),
  294. ),
  295. ),
  296. Container(
  297. width: 1.sw,
  298. height: 1.sh,
  299. decoration: BoxDecoration(
  300. gradient: LinearGradient(
  301. colors: [
  302. '#B0BCFF'.toColor(),
  303. '#FFFFFF'.toColor(),
  304. ],
  305. begin: Alignment.topCenter,
  306. end: Alignment.bottomCenter,
  307. stops: const [0, 1.0],
  308. ),
  309. ),
  310. ),
  311. Container(
  312. width: 1.sw,
  313. height: 1.sh,
  314. decoration: BoxDecoration(
  315. gradient: LinearGradient(
  316. colors: [
  317. '#7E92FF'.toColor(),
  318. '#B0BCFF'.toColor(),
  319. ],
  320. begin: Alignment.topCenter,
  321. end: Alignment.bottomCenter,
  322. stops: const [0, 1.0],
  323. ),
  324. ),
  325. ),
  326. ],
  327. );
  328. }
  329. }