Files
Regroup/lib/Login/View/verifygoogleapple.dart
2024-08-01 13:45:01 +05:30

250 lines
9.1 KiB
Dart
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:glassmorphism/glassmorphism.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/CommonTextFormField.dart';
import 'package:regroup/Global.dart';
import 'package:regroup/Login/ViewModel/LoginApi.dart';
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/CommonDropdown.dart';
import 'package:regroup/Utils/Common/CustomNextButton.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/dialogs.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Verifygoogleandapple extends StatefulWidget {
Verifygoogleandapple({
super.key,
});
@override
State<Verifygoogleandapple> createState() => _VerifygoogleandappleState();
}
class _VerifygoogleandappleState extends State<Verifygoogleandapple> {
TextEditingController emailidcontroller = TextEditingController();
String _selectedAccountType = '';
@override
void initState() {
emailidcontroller.text = Get.arguments['email'];
super.initState();
}
void _onItemSelected(String value) {
setState(() {
_selectedAccountType = value;
});
}
getIdFromAccountType() {
if (_selectedAccountType == 'Individual') {
return 1;
} else {
return 2;
}
}
final Map<String, int> _accountTypeMap = {
'Individual': 1,
'Business': 2,
};
_createAccountWithOAuth() async {
var updata = {
"principal_type_xid": getIdFromAccountType(),
"email_address": emailidcontroller.text,
};
final resp = await LoginAPI()
.storeUserDetailsWhenComingFromGoogleAppleSignin(updata);
SharedPreferences prefs = await SharedPreferences.getInstance();
if (resp.status == ResponseStatus.SUCCESS) {
int accountTypeValue = _accountTypeMap[_selectedAccountType] ?? 0;
await prefs.setString(
'accountTypefromLogin', accountTypeValue.toString());
await prefs.setString('accountTypeValue', accountTypeValue.toString());
if (_selectedAccountType == 'Individual') {
Get.toNamed(RouteName.tellusindividualscreen);
} else {
Get.toNamed(RouteName.tellusbusinessscreen);
}
} else {
Get.snackbar(
'Error',
'Google Sign-In canceled',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red,
colorText: Colors.white,
);
}
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Scaffold(
appBar: const CommonAppbar(
titleTxt: '',
),
backgroundColor: const Color.fromARGB(255, 18, 32, 47),
body: Stack(
children: [
// Positioned(
// top: 310, right: -30, child: CommonBlurRightSecond()),
// const Positioned(top: 510, left: -30, child: CommonBlurLeftBlue()),
// GlassmorphicContainer(
// width: MediaQuery.of(context).size.width,
// height:
// // 500.h,
// MediaQuery.of(context).size.height,
// borderRadius: 2,
// blur: 6,
// alignment: Alignment.bottomLeft,
// border: 2,
// linearGradient: LinearGradient(
// begin: Alignment.topCenter,
// end: Alignment.bottomCenter,
// colors: [
// const Color(0XFF222935).withOpacity(0.60),
// const Color(0XFF222935).withOpacity(0.60),
// const Color(0XFF222935).withOpacity(0.60),
// const Color(0XFF222935).withOpacity(0.60),
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
// ],
// ),
// borderGradient: LinearGradient(
// begin: Alignment.topCenter,
// end: Alignment.bottomCenter,
// colors: [
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
// const Color(0XFF222935).withOpacity(0.60),
// const Color(0XFF222935).withOpacity(0.60),
// ],
// ),
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sizedBoxHeight(20.h),
text22400white('One more step to verify'),
sizedBoxHeight(10.h),
Container(
width: 154,
decoration: const ShapeDecoration(
shape: RoundedRectangleBorder(
side: BorderSide(
width: 1,
strokeAlign: BorderSide.strokeAlignCenter,
color: Color(0xFF858585),
),
),
)),
sizedBoxHeight(20.h),
text14400white(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.'),
sizedBoxHeight(30.h),
text16400white('Full name'),
sizedBoxHeight(10.h),
CustomTextFormField(
textEditingController: emailidcontroller,
hintText: "Enter your email address",
leadingIcon:
// const Icon(Icons.mail_outline),
SizedBox(
width: 22.w,
height: 17.h,
child: Image.asset(
'assets/images/png/mail.png',
width: 22.w,
height: 17.h,
),
),
// validatorText: "Email Id",
validator: (value) {
if (value!.isEmpty) {
return 'Enter your e-mail address';
}
if (!RegExp(
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$')
.hasMatch(value)) {
return 'Enter a valid e-mail address';
}
return null;
},
inputFormatters: [
LengthLimitingTextInputFormatter(50),
RemoveEmojiInputFormatter()
],
),
sizedBoxHeight(10.h),
Row(
children: [
text16400white('Account type'),
sizedBoxWidth(5.w),
Image.asset('assets/images/png/informationicon.png')
],
),
sizedBoxHeight(10.h),
CustomDropDownRadio(
header: '',
title: '',
listData: const [
'Individual',
'Business',
],
onItemSelected: _onItemSelected,
leadingImage: Image.asset(
'assets/images/png/user.png',
),
),
const Spacer(
flex: 3,
),
CustomButton(
text: "Continue",
onPressed: () {
if (emailidcontroller.text.isEmpty &&
_selectedAccountType.isEmpty) {
utils.showToast('Please fill all fields');
} else {
_createAccountWithOAuth();
}
}),
const Spacer()
],
),
),
] )
));
}
}