| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- import 'package:electronic_assistant/base/base_page.dart';
- import 'package:electronic_assistant/resource/assets.gen.dart';
- import 'package:electronic_assistant/resource/colors.gen.dart';
- import 'package:electronic_assistant/utils/expand.dart';
- import 'package:electronic_assistant/widget/login_code_btn.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import 'controller.dart';
- class LoginPage extends BasePage<LoginController> {
- const LoginPage({super.key});
- @override
- bool immersive() {
- return true;
- }
- // 点击空白处收起键盘
- @override
- void backgroundOnTapEvent() {
- super.backgroundOnTapEvent();
- FocusScope.of(Get.context!).requestFocus(FocusNode());
- }
- @override
- Widget buildBody(BuildContext context) {
- return Stack(
- children: [
- buildBackgroundImage(),
- Scaffold(
- resizeToAvoidBottomInset: false,
- backgroundColor: Colors.transparent,
- appBar: AppBar(
- leading: IconButton(
- icon: const Icon(Icons.arrow_back_ios),
- onPressed: () {
- Navigator.pop(context);
- },
- ),
- backgroundColor: Colors.transparent,
- systemOverlayStyle: SystemUiOverlayStyle.dark,
- ),
- body: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- margin: EdgeInsets.only(left: 28.w, top: 64.h),
- width: 194.w,
- height: 71.h,
- child: Image(image: Assets.images.iconLoginLogo.provider()),
- ),
- Container(
- margin: EdgeInsets.only(top: 44.h, left: 28.w, right: 28.w),
- alignment: Alignment.center,
- height: 44.h,
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 1.0,
- color: "#F0F0F0".toColor(),
- ),
- ),
- ),
- child: TextField(
- maxLines: 1,
- textAlignVertical: TextAlignVertical.center,
- textInputAction: TextInputAction.search,
- decoration: InputDecoration(
- hintText: '输入手机号码',
- hintStyle:
- TextStyle(fontSize: 16, color: "#AFAFAF".toColor()),
- labelStyle: const TextStyle(
- fontSize: 16,
- color: ColorName.primaryTextColor,
- ),
- contentPadding: const EdgeInsets.all(0),
- border:
- const OutlineInputBorder(borderSide: BorderSide.none),
- enabled: true,
- ),
- style: TextStyle(fontSize: 14.sp),
- onChanged: (value) {
- controller.setPhone(value);
- },
- ),
- ),
- Container(
- margin: EdgeInsets.only(top: 36.h, left: 28.w, right: 28.w),
- alignment: Alignment.center,
- height: 44.h,
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 1.0,
- color: "#F0F0F0".toColor(),
- ),
- ),
- ),
- child: Row(
- children: [
- Expanded(
- child: TextField(
- maxLines: 1,
- textAlignVertical: TextAlignVertical.center,
- textInputAction: TextInputAction.search,
- decoration: InputDecoration(
- hintText: '输入验证码',
- hintStyle: TextStyle(
- fontSize: 16, color: "#AFAFAF".toColor()),
- labelStyle: const TextStyle(
- fontSize: 16,
- color: ColorName.primaryTextColor,
- ),
- contentPadding: const EdgeInsets.all(0),
- border: const OutlineInputBorder(
- borderSide: BorderSide.none),
- enabled: true,
- ),
- style: TextStyle(fontSize: 14.sp),
- onChanged: (value) {
- controller.setCode(value);
- },
- ),
- ),
- LoginCodeBtn(
- onTapCallback: () {
- controller.getUserCode();
- },
- available: true,
- ),
- ],
- ),
- ),
- GestureDetector(
- onTap: () {
- controller.login();
- },
- child: Container(
- margin: EdgeInsets.only(
- top: 54.h,
- left: 28.w,
- right: 28.w,
- ),
- height: 48.h,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: ['#6177F2'.toColor(), '#8B9DFF'.toColor()],
- stops: const [0, 1.0],
- ),
- borderRadius: BorderRadius.circular(8),
- ),
- child: const Text(
- "登录",
- style: TextStyle(
- color: ColorName.white,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- ),
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 28.w, top: 16.h),
- child: Row(
- children: [
- Obx(
- () {
- return GestureDetector(
- onTap: () {
- controller.isAgree.value =
- !controller.isAgree.value;
- },
- child: SizedBox(
- width: 20.w,
- height: 20.w,
- child: controller.isAgree.value
- ? Assets.images.iconSelectTrue.image()
- : Assets.images.iconSelectFalse.image()),
- );
- },
- ),
- Text(
- "我已阅读并同意",
- style: TextStyle(
- color: "#AFAFAF".toColor(),
- fontSize: 12,
- ),
- ),
- GestureDetector(
- onTap: () {},
- child: Text(
- "《隐私政策》",
- style: TextStyle(
- color: "#5E8BFF".toColor(),
- fontSize: 12,
- ),
- ),
- ),
- Text(
- "和",
- style: TextStyle(
- color: "#AFAFAF".toColor(),
- fontSize: 12,
- ),
- ),
- GestureDetector(
- onTap: () {},
- child: Text(
- "《用户使用协议》",
- style: TextStyle(
- color: "#5E8BFF".toColor(),
- fontSize: 12,
- ),
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ],
- );
- // return Scaffold(
- // body: Column(
- // children: <Widget>[
- // TextField(
- // onChanged: (text) {
- // controller.setPhone(text);
- // },
- // decoration: const InputDecoration(
- // labelText: "手机号",
- // hintText: "您的手机号",
- // prefixIcon: Icon(Icons.person)),
- // ),
- // TextField(
- // onChanged: (text) {
- // controller.setCode(text);
- // },
- // decoration: const InputDecoration(
- // labelText: "验证码",
- // hintText: "您的验证码",
- // prefixIcon: Icon(Icons.lock)),
- // ),
- // ElevatedButton(
- // child: const Text("获取验证码"),
- // onPressed: () {
- // controller.getUserCode();
- // },
- // ),
- // ElevatedButton(
- // child: const Text("登录"),
- // onPressed: () {
- // controller.login();
- // },
- // )
- // ],
- // ),
- // );
- }
- Widget buildBackgroundImage() {
- return Image(image: Assets.images.bgLogin.provider());
- }
- Widget buildBackgroundGradient() {
- return Stack(
- children: [
- Container(
- width: 1.sw,
- height: 1.sh,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [
- '#FFC0CF'.toColor().withOpacity(0.62),
- '#F6F6F6'.toColor().withOpacity(0)
- ],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- stops: const [0, 1.0],
- ),
- ),
- ),
- Container(
- width: 1.sw,
- height: 1.sh,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [
- '#CADCFD'.toColor().withOpacity(0.72),
- '#F6F5F8'.toColor().withOpacity(0.72)
- ],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- stops: const [0, 1.0],
- ),
- ),
- ),
- Container(
- width: 1.sw,
- height: 1.sh,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [
- '#B0BCFF'.toColor(),
- '#FFFFFF'.toColor(),
- ],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- stops: const [0, 1.0],
- ),
- ),
- ),
- Container(
- width: 1.sw,
- height: 1.sh,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [
- '#7E92FF'.toColor(),
- '#B0BCFF'.toColor(),
- ],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- stops: const [0, 1.0],
- ),
- ),
- ),
- ],
- );
- }
- }
|