| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter/src/widgets/framework.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:keyboard/base/base_page.dart';
- import 'package:keyboard/module/login/login_controller.dart';
- import 'package:get/get.dart';
- import 'package:keyboard/router/app_pages.dart';
- import 'package:keyboard/utils/common_expand.dart';
- import '../../data/consts/web_url.dart';
- import '../../resource/assets.gen.dart';
- import '../../resource/colors.gen.dart';
- import '../../resource/string.gen.dart';
- import '../../utils/styles.dart';
- import '../../widget/click_text_span.dart';
- class LoginPage extends BasePage<LoginController> {
- const LoginPage({super.key});
- static start() {
- Get.toNamed(RoutePath.login);
- }
- @override
- Color backgroundColor() {
- return const Color(0xFFF6F5FA);
- }
- @override
- immersive() {
- return true;
- }
- @override
- Widget buildBody(BuildContext context) {
- return Stack(
- children: [
- Assets.images.bgLogin.image(fit: BoxFit.contain, width: 360.w),
- _buildTitle(),
- SafeArea(
- child: Column(
- children: [
- SizedBox(height: 225.w),
- buildPhoneTextFiled(),
- SizedBox(height: 16.w),
- buildCodeTextFiled(),
- SizedBox(height: 46.w),
- buildLoginButton(),
- SizedBox(height: 25.w),
- _buildPrivacy(),
- SizedBox(height: 100.w),
- buildOtherLogin(),
- ],
- ),
- ),
- ],
- );
- }
- _buildTitle() {
- return SafeArea(
- child: Container(
- alignment: Alignment.topLeft,
- padding: EdgeInsets.only(top: 16.h, left: 16.w, right: 16.w),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- GestureDetector(
- onTap: controller.clickBack,
- child: Assets.images.iconStoreBack.image(
- width: 32.w,
- height: 32.w,
- ),
- ),
- ],
- ),
- ),
- );
- }
- Widget buildPhoneTextFiled() {
- return Container(
- height: 48.w,
- margin: EdgeInsets.symmetric(horizontal: 20.w),
- padding: EdgeInsets.symmetric(horizontal: 16.w),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(100.w),
- ),
- child: Row(
- children: [
- Expanded(
- child: TextField(
- cursorHeight: 20.w,
- style: TextStyle(
- fontSize: 14.sp,
- color: Colors.black.withAlpha( 204),
- fontWeight: FontWeight.w500,
- ),
- maxLines: 1,
- maxLength: 11,
- keyboardType: TextInputType.phone,
- inputFormatters: [FilteringTextInputFormatter.digitsOnly],
- textAlignVertical: TextAlignVertical.center,
- textInputAction: TextInputAction.next,
- decoration: InputDecoration(
- hintText: StringName.loginEtPhoneHint,
- counterText: '',
- hintStyle: TextStyle(
- fontSize: 14.sp,
- color: Colors.black.withAlpha(61),
- fontWeight: FontWeight.normal,
- ),
- labelStyle: TextStyle(
- fontSize: 14.sp,
- color: ColorName.primaryTextColor,
- ),
- contentPadding: const EdgeInsets.all(0),
- border: const OutlineInputBorder(borderSide: BorderSide.none),
- enabled: true,
- ),
- onChanged: controller.onPhoneChanged,
- ),
- ),
- ],
- ),
- );
- }
- Widget buildCodeTextFiled() {
- return Container(
- height: 48.w,
- margin: EdgeInsets.symmetric(horizontal: 20.w),
- padding: EdgeInsets.symmetric(horizontal: 16.w),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(100.w),
- ),
- child: Row(
- children: [
- Expanded(
- child: TextField(
- cursorHeight: 20.w,
- style: TextStyle(
- fontSize: 14.sp,
- color: Colors.black.withAlpha( 204),
- fontWeight: FontWeight.w500,
- ),
- maxLines: 1,
- maxLength: 4,
- keyboardType: TextInputType.phone,
- inputFormatters: [FilteringTextInputFormatter.digitsOnly],
- textAlignVertical: TextAlignVertical.center,
- textInputAction: TextInputAction.next,
- decoration: InputDecoration(
- hintText: StringName.loginPrintVerificationCode,
- counterText: '',
- hintStyle: TextStyle(
- fontSize: 14.sp,
- color: Colors.black.withAlpha(61),
- fontWeight: FontWeight.normal,
- ),
- labelStyle: TextStyle(
- fontSize: 14.sp,
- color: ColorName.primaryTextColor,
- ),
- contentPadding: const EdgeInsets.all(0),
- border: const OutlineInputBorder(borderSide: BorderSide.none),
- enabled: true,
- ),
- onChanged: controller.onCodeChanged,
- ),
- ),
- buildVerificationCodeSendBtn(),
- ],
- ),
- );
- }
- Widget buildVerificationCodeSendBtn() {
- return GestureDetector(
- onTap: controller.onSendVerificationCode,
- child: Container(
- margin: EdgeInsets.only(left: 12.w, right: 8.w),
- child: Obx(() {
- String txt = "";
- if (controller.countDown != null) {
- txt =
- '${controller.countDown}${StringName.loginRetransmissionCode}';
- } else {
- if (controller.isFirstSend) {
- txt = StringName.loginSendVerificationCode;
- } else {
- txt = StringName.loginResendCode;
- }
- }
- return Text(
- txt,
- style: TextStyle(
- fontSize: 14.sp,
- color: controller.isFirstSend
- ? Colors.black.withAlpha(204)
- : Color(0xCC7D46FC)
- ),
- );
- }),
- ),
- );
- }
- Widget buildLoginButton() {
- return GestureDetector(
- onTap: () {
- controller.onLoginClick();
- },
- child: Container(
- height: 48.w,
- margin: EdgeInsets.symmetric(horizontal: 24.w),
- child: Row(
- children: [
- Expanded(
- child: Obx(() {
- return Container(
- height: 48.w,
- decoration:
- controller.phone.length == 11 &&
- controller.code.isNotEmpty &&
- controller.isAgree
- ? Styles.getActivateButtonDecoration(50.r)
- : Styles.getInactiveButtonDecoration(50.r),
- child: Center(
- child: Text(
- StringName.login,
- style: TextStyle(color: Colors.white, fontSize: 16.sp),
- ),
- ),
- );
- }),
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildPrivacy() {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Obx(() {
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- controller.clickAgree();
- },
- child: Padding(
- padding: EdgeInsets.symmetric(vertical: 20.w,horizontal: 20.w),
- child:
- controller.isAgree
- ? Assets.images.iconLoginAgreePrivacy.image(
- width: 14.w,
- height: 14.w,
- )
- : Container(
- width: 14.w,
- height: 14.w,
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- border: Border.all(
- color: Colors.black.withAlpha(153),
- width: 1.w,
- ),
- ),
- ),
- ),
- ),
- );
- }),
- Transform.translate(offset: Offset(-17.w,0),child: Text.rich(
- TextSpan(
- children: [
- TextSpan(
- text: StringName.textSpanIHaveReadAndAgree,
- style: TextStyle(
- color: Colors.black.withAlpha(128),
- fontSize: 12.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ClickTextSpan(
- text: StringName.textSpanPrivacyPolicy,
- url: WebUrl.privacyPolicy,
- fontSize: 12.sp,
- color: Colors.black.withAlpha(204),
- ),
- TextSpan(
- text: StringName.textSpanAnd,
- style: TextStyle(
- color: Colors.black.withAlpha(128),
- fontSize: 12.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ClickTextSpan(
- text: StringName.textSpanServiceTerms,
- url: WebUrl.serviceAgreement,
- color: Colors.black.withAlpha(204),
- fontSize: 12.sp,
- ),
- ],
- ),
- ),),
- ],
- );
- }
- Widget buildOtherLogin() {
- return Container(
- child: Column(
- children: [
- Text(
- StringName.loginOtherlogin,
- style: TextStyle(
- color: Colors.black.withValues(alpha: 0.5),
- fontSize: 12.sp,
- height: 0,
- ),
- ),
- SizedBox(height: 18.h),
- Material(
- color: Colors.white,
- shape: const CircleBorder(),
- child: InkWell(
- customBorder: const CircleBorder(), // 保证点击区域是圆的
- onTap: () {
- controller.clickWxLogin();
- },
- child: SizedBox(
- width: 44.w,
- height: 44.w,
- child: Center(
- child: Assets.images.iconWechatLogoBlack.image(
- width: 22.w,
- height: 22.w,
- ),
- ),
- ),
- ),
- ),
- SizedBox(height: 6.w),
- Text(
- StringName.wechat,
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Colors.black.withValues(alpha: 0.5),
- fontSize: 12.sp,
- height: 0,
- ),
- ),
- ],
- ),
- );
- }
- }
|