Files
driver_tripz/lib/views/auth/captin/login_captin.dart
Hamza-Ayed e755cea0ae 5/19/1
2024-05-19 18:43:45 +03:00

400 lines
18 KiB
Dart

import 'package:SEFER/views/auth/captin/register_captin.dart';
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:get/get.dart';
import '../../../constant/box_name.dart';
import '../../../constant/colors.dart';
import '../../../constant/info.dart';
import '../../../constant/style.dart';
import '../../../controller/auth/captin/login_captin_controller.dart';
import '../../../controller/auth/google_sign.dart';
import '../../../main.dart';
import '../../widgets/elevated_btn.dart';
import '../../widgets/my_scafold.dart';
import '../country_widget.dart';
class LoginCaptin extends StatelessWidget {
// final controller = Get.put(LoginCaptinController());
LoginCaptin({super.key});
@override
Widget build(BuildContext context) {
Get.put(LoginCaptinController());
// Get.put(LocationBackgroundController());
return GetBuilder<LoginCaptinController>(
builder: (controller) => MyScafolld(
title: 'Login Driver'.tr,
isleading: false,
body: [
if (box.read(BoxName.agreeTerms).toString() != 'agreed')
agreedPage()
else if (box.read(BoxName.countryCode) == null)
CountryPicker()
else if (box.read(BoxName.locationPermission) != 'true')
locationPermissionDialog()
else
SingleChildScrollView(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(25),
child:
// Container(
// decoration: const BoxDecoration(
// boxShadow: [
// BoxShadow(
// offset: Offset(3, 3),
// color: AppColor.accentColor,
// blurRadius: 3)
// ],
// color: AppColor.secondaryColor,
// ),
// child: Form(
// key: controller.formKey,
// child: Padding(
// padding: const EdgeInsets.all(16.0),
// child: SingleChildScrollView(
// child: Column(
// children: [
// TextFormField(
// keyboardType: TextInputType.emailAddress,
// controller: controller.emailController,
// decoration: InputDecoration(
// focusedBorder: OutlineInputBorder(
// borderSide: const BorderSide(
// color: AppColor.primaryColor,
// width: 2.0,
// ),
// borderRadius: BorderRadius.circular(10),
// ),
// fillColor: AppColor.accentColor,
// hoverColor: AppColor.accentColor,
// focusColor: AppColor.accentColor,
// border: const OutlineInputBorder(
// borderRadius: BorderRadius.all(
// Radius.circular(12))),
// labelText: 'Email'.tr,
// hintText: 'Enter your email address'.tr,
// ),
// validator: (value) {
// if (value!.isEmpty ||
// (!value.contains('@') ||
// !value.contains('.'))) {
// return 'Please enter Your Email.'.tr;
// }
// return null;
// },
// ),
// const SizedBox(
// height: 30,
// ),
// TextFormField(
// keyboardType: TextInputType.phone,
// cursorColor: AppColor.accentColor,
// controller: controller.phoneController,
// decoration: InputDecoration(
// focusedBorder: OutlineInputBorder(
// borderSide: const BorderSide(
// color: AppColor.primaryColor,
// width: 2.0,
// ),
// borderRadius: BorderRadius.circular(10),
// ),
// focusColor: AppColor.accentColor,
// fillColor: AppColor.accentColor,
// border: const OutlineInputBorder(
// borderRadius: BorderRadius.all(
// Radius.circular(12))),
// labelText: 'Phone'.tr,
// hintText: 'Enter your phone number'.tr,
// ),
// validator: (value) {
// if (value!.isEmpty ||
// value.length != 10) {
// return 'Please enter your phone number.'
// .tr;
// }
// return null;
// },
// ),
// const SizedBox(
// height: 15,
// ),
// TextFormField(
// obscureText: true,
// keyboardType: TextInputType.emailAddress,
// controller: controller.passwordController,
// decoration: InputDecoration(
// focusedBorder: OutlineInputBorder(
// borderSide: const BorderSide(
// color: AppColor.primaryColor,
// width: 2.0,
// ),
// borderRadius: BorderRadius.circular(10),
// ),
// fillColor: AppColor.accentColor,
// hoverColor: AppColor.accentColor,
// focusColor: AppColor.accentColor,
// border: const OutlineInputBorder(
// borderRadius: BorderRadius.all(
// Radius.circular(12))),
// labelText: 'Password'.tr,
// hintText:
// 'Please enter your phone number.'.tr,
// ),
// validator: (value) {
// if (value!.isEmpty) {
// return 'Please enter Your Password.'.tr;
// }
// if (value.length < 6) {
// return 'Password must br at least 6 character.'
// .tr;
// }
// return null;
// },
// ),
// controller.isloading
// ? const MyCircularProgressIndicator()
// : MyElevatedButton(
// onPressed: () {
// if (controller.formKey.currentState!
// .validate()) {
// controller.login();
// }
// },
// title: 'Submit'.tr,
// ),
// ],
// ),
// ),
// ),
// ),
// )
Center(
child: Container(
decoration: AppStyle.boxDecoration1,
height: Get.height * .6,
width: Get.width * .9,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Image.asset(
'assets/images/logo.gif',
height: Get.width * .3,
width: Get.width * .3,
fit: BoxFit.fill,
),
Container(
decoration: AppStyle.boxDecoration1,
height: Get.height * .3,
width: Get.width * .8,
child: Center(
child: Text(
'Sign in with Google for easier email and name entry'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
),
),
MyElevatedButton(
title: 'Sign In by Google'.tr,
onPressed: () async {
await GoogleSignInHelper.signInFromLogin();
},
kolor: AppColor.blueColor,
),
],
),
))),
Text(
'if you don\'t have account'.tr,
style: AppStyle.subtitle,
),
AnimatedTextKit(
onTap: () => Get.to(() => const RegisterCaptin()),
animatedTexts: [
TypewriterAnimatedText(
'Register as Driver'.tr,
textStyle: AppStyle.headTitle2,
speed: const Duration(milliseconds: 200),
),
],
totalRepeatCount: 4,
pause: const Duration(milliseconds: 200),
displayFullTextOnTap: true,
stopPauseOnTap: true,
),
// IconButton(
// onPressed: () async {
// AC credentials = AC();
// String apiKey = AK.payMobApikey;
// String convertedStringN = credentials.c(
// credentials.c(credentials.c(apiKey, cs), cC), cn);
// print('Converted v: $convertedStringN');
//
// String retrievedStringS = credentials.r(
// credentials.r(
// credentials.r(convertedStringN, cn), cC),
// cs);
// print('Retrieved String: $retrievedStringS');
// //
// if (retrievedStringS == apiKey) {
// print('same');
// }
// },
// icon: const Icon(
// Icons.close,
// color: AppColor.blueColor,
// ),
// ),
],
),
)
],
),
);
}
Padding agreedPage() {
return Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset(
'assets/images/notepad.png',
width: Get.width * .2,
),
SizedBox(
width: Get.width * .7,
child: Text(
'Accept Ride\'s Terms & Review Privacy Notice'.tr,
style: AppStyle.headTitle2,
),
),
],
),
const SizedBox(
height: 30,
),
RichText(
text: TextSpan(
text:
'By selecting "I Agree" below, I have reviewed and agree to the Terms of Use and acknowledge the '
.tr,
style: AppStyle.title,
children: <TextSpan>[
TextSpan(
text: 'Privacy Notice'.tr,
style: const TextStyle(
decoration: TextDecoration.underline,
color: AppColor.blueColor),
recognizer: TapGestureRecognizer()
..onTap = () {
Get.defaultDialog(
title: ''.tr,
content: const SizedBox(
height: 400,
width: 400,
child: SingleChildScrollView(
child: HtmlWidget(AppInformation.privacyPolicy),
),
));
}),
const TextSpan(
text: '. I am at least 18 years of age.',
),
],
),
),
const SizedBox(
height: 100,
),
GetBuilder<LoginCaptinController>(
builder: (controller) => Column(
children: [
Row(
children: [
Checkbox.adaptive(
autofocus: true,
tristate: true,
splashRadius: 25,
activeColor: AppColor.primaryColor,
value: controller.isAgreeTerms,
onChanged: (value) => controller.changeAgreeTerm(),
),
Text(
'I Agree'.tr,
style: controller.isAgreeTerms
? AppStyle.title
: AppStyle.title
.copyWith(color: AppColor.accentColor),
),
],
),
MyElevatedButton(
title: 'Submit'.tr,
onPressed: () => controller.saveAgreementTerms()),
],
),
)
],
),
);
}
locationPermissionDialog() {
return GetBuilder<LoginCaptinController>(builder: (controller) {
return box.read(BoxName.locationPermission) != 'true'
? Padding(
padding: const EdgeInsets.all(16),
child: Container(
height: Get.height * .4,
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'We use location to get accurate and nearest passengers for you'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
Text(
'You will choose allow all the time to be ready receive orders'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title
.copyWith(color: AppColor.greenColor),
),
MyElevatedButton(
title: 'Grant Location'.tr,
onPressed: () async {
await controller.getLocationPermission();
},
kolor: AppColor.greenColor,
)
],
),
),
),
),
)
: const SizedBox();
});
}
}