509 lines
24 KiB
Dart
509 lines
24 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:regroup/Common/base_manager.dart';
|
|
import 'package:regroup/Utils/Common/CommonDropdown.dart';
|
|
import 'package:regroup/Utils/Common/CustomTextformfield.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/onboarding/Signup/view_model/postmethod.dart';
|
|
import 'package:regroup/resources/routes/route_name.dart';
|
|
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
|
|
|
|
class SignupScreen extends StatefulWidget {
|
|
const SignupScreen({super.key});
|
|
|
|
@override
|
|
State<SignupScreen> createState() => _SignupScreenState();
|
|
}
|
|
|
|
class _SignupScreenState extends State<SignupScreen> {
|
|
TextEditingController emailidcontroller = TextEditingController();
|
|
TextEditingController passwordController = TextEditingController();
|
|
TextEditingController confirmpasscontroller = TextEditingController();
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
List<String> _dropdownProductItems = [
|
|
'Individual',
|
|
'Business',
|
|
];
|
|
|
|
final Map<String, int> _accountTypeMap = {
|
|
'Individual': 1,
|
|
'Business': 2,
|
|
};
|
|
|
|
String _selectedAccountType = '';
|
|
|
|
void _onItemSelected(String value) {
|
|
setState(() {
|
|
_selectedAccountType = value;
|
|
});
|
|
}
|
|
|
|
// void _Signincheck() async {
|
|
// if (emailidcontroller.text.isBlank! ||
|
|
// passwordController.text.isBlank! ||
|
|
// confirmpasscontroller.text.isBlank!) {
|
|
// Get.snackbar(
|
|
// 'Error',
|
|
// 'Enter your credentials',
|
|
// snackPosition: SnackPosition.BOTTOM,
|
|
// backgroundColor: Colors.red,
|
|
// colorText: Colors.white,
|
|
// );
|
|
// } else if (!emailidcontroller.text.isEmail) {
|
|
// Get.snackbar(
|
|
// 'Error',
|
|
// 'Enter a valid e-mail address',
|
|
// snackPosition: SnackPosition.BOTTOM,
|
|
// backgroundColor: Colors.red,
|
|
// colorText: Colors.white,
|
|
// );
|
|
// } else if (_selectedAccountType == 'Individual') {
|
|
// print('individual selected');
|
|
// Get.toNamed(RouteName.verifyusercreen, arguments: _selectedAccountType);
|
|
// } else if (_selectedAccountType == 'Business') {
|
|
// print('business selected');
|
|
// Get.toNamed(RouteName.verifyusercreen, arguments: _selectedAccountType);
|
|
// } else {
|
|
// utils.showToast('Please select an account type');
|
|
// }
|
|
// }
|
|
|
|
Uploadata() async {
|
|
utils.loader();
|
|
int accountTypeValue = _accountTypeMap[_selectedAccountType] ?? 0;
|
|
Map<String, dynamic> updata = {
|
|
"email_address": emailidcontroller.text,
|
|
"password": passwordController.text,
|
|
"account_type": accountTypeValue,
|
|
};
|
|
final data = await Onboard().Postregisteration(updata);
|
|
if (data.status == ResponseStatus.SUCCESS) {
|
|
Get.back();
|
|
print("Sign up done");
|
|
|
|
String selectedCategory = _selectedAccountType;
|
|
|
|
Get.toNamed(RouteName.verifyusercreen,
|
|
arguments:
|
|
{
|
|
"emailid" : emailidcontroller.text,
|
|
"password" : passwordController.text,
|
|
"accounttype" : selectedCategory,
|
|
'accountypenumber' : accountTypeValue
|
|
|
|
}
|
|
|
|
);
|
|
|
|
// if (selectedCategory == "Individual") {
|
|
// Get.toNamed(RouteName.verifyusercreen,
|
|
// arguments:
|
|
// {
|
|
// "emailid" : emailidcontroller.text,
|
|
// "password" : passwordController.text,
|
|
// "accounttype" : selectedCategory,
|
|
// 'accountypenumber' : accountTypeValue
|
|
|
|
// }
|
|
|
|
// );
|
|
// } else if (selectedCategory == "Individual") {
|
|
// Get.toNamed(RouteName.verifyusercreen,
|
|
// arguments:
|
|
// {
|
|
// "emailid" : emailidcontroller.text,
|
|
// "password" : passwordController.text,
|
|
// "accounttype" : selectedCategory,
|
|
// 'accountypenumber' : accountTypeValue
|
|
|
|
// }
|
|
// );
|
|
// }
|
|
|
|
return utils.showToast(data.message);
|
|
} else {
|
|
Get.back();
|
|
print("registration not done");
|
|
return utils.showToast(data.message);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
|
child: Scaffold(
|
|
resizeToAvoidBottomInset: false,
|
|
backgroundColor: const Color.fromARGB(255, 18, 32, 47),
|
|
body: Stack(
|
|
children: [
|
|
Container(
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image:
|
|
AssetImage("assets/images/png/Choice screen.png"),
|
|
fit: BoxFit.fill)),
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 150.h),
|
|
child: Center(child: text22400white('Create account')),
|
|
),
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 16.w, vertical: 30.h),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
text16400white('Email address'),
|
|
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),
|
|
text16400white('Password'),
|
|
sizedBoxHeight(10.h),
|
|
CustomTextFormField(
|
|
isInputPassword: true,
|
|
textEditingController: passwordController,
|
|
hintText: 'Enter your password',
|
|
leadingIcon: Image.asset(
|
|
'assets/images/png/lock.png',
|
|
width: 22.w,
|
|
height: 17.h,
|
|
),
|
|
// const Icon(Icons.lock_outline),
|
|
// validationMessage: "Enter your password",
|
|
validator: (val) {
|
|
if (val == null || val.isEmpty) {
|
|
return 'Please enter your password';
|
|
}
|
|
return null;
|
|
},
|
|
inputFormatters: [
|
|
LengthLimitingTextInputFormatter(50),
|
|
RemoveEmojiInputFormatter()
|
|
],
|
|
),
|
|
sizedBoxHeight(10.h),
|
|
text16400white('Confirm password'),
|
|
sizedBoxHeight(10.h),
|
|
CustomTextFormField(
|
|
isInputPassword: true,
|
|
textEditingController: confirmpasscontroller,
|
|
hintText: "Enter your password",
|
|
leadingIcon: Image.asset(
|
|
'assets/images/png/lock.png',
|
|
width: 22.w,
|
|
height: 17.h,
|
|
),
|
|
// const Icon(Icons.lock_outline),
|
|
// validatorText: "Enter your password",
|
|
validator: (val) {
|
|
if (val == null || val.isEmpty) {
|
|
return 'Please enter your password';
|
|
}
|
|
if (val != passwordController.text) {
|
|
return 'Password does not match';
|
|
}
|
|
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: 'Select account type',
|
|
title: '',
|
|
listData: [
|
|
'Individual',
|
|
'Business',
|
|
],
|
|
onItemSelected: _onItemSelected,
|
|
leadingImage: Image.asset(
|
|
'assets/images/png/user.png',
|
|
),
|
|
),
|
|
sizedBoxHeight(30.h),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
SizedBox(
|
|
width: 320.w,
|
|
height: 42.h,
|
|
child: Text.rich(
|
|
TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text:
|
|
'By signing up to ReGroup you agree to our ',
|
|
style: TextStyle(
|
|
color: const Color(0xCCFCFCFC),
|
|
fontSize: 14.sp,
|
|
fontFamily: 'Helvetica',
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: 'Terms and Conditions',
|
|
style: TextStyle(
|
|
color: const Color(0xCCFCFCFC),
|
|
fontSize: 14.sp,
|
|
fontFamily: 'Helvetica',
|
|
fontWeight: FontWeight.w700,
|
|
decoration:
|
|
TextDecoration.underline,
|
|
decorationColor:
|
|
const Color(0xffFCFCFC)
|
|
.withOpacity(0.80),
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: ' and ',
|
|
style: TextStyle(
|
|
color: const Color(0xCCFCFCFC),
|
|
fontSize: 14.sp,
|
|
fontFamily: 'Helvetica',
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: 'Privacy Policy',
|
|
style: TextStyle(
|
|
color: const Color(0xCCFCFCFC),
|
|
fontSize: 14.sp,
|
|
fontFamily: 'Helvetica',
|
|
fontWeight: FontWeight.w700,
|
|
decoration:
|
|
TextDecoration.underline,
|
|
decorationColor:
|
|
const Color(0xffFCFCFC)
|
|
.withOpacity(0.80),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
sizedBoxHeight(20.h),
|
|
CustomButton(
|
|
text: "Continue",
|
|
onPressed: () {
|
|
// _Signincheck();
|
|
final isValid =
|
|
_formKey.currentState?.validate();
|
|
if (
|
|
// isValid!
|
|
emailidcontroller.text.isBlank! &&
|
|
passwordController.text.isBlank! &&
|
|
confirmpasscontroller
|
|
.text.isBlank! &&
|
|
_selectedAccountType.isEmpty) {
|
|
print(emailidcontroller.text);
|
|
print(passwordController.text);
|
|
print(_selectedAccountType.toString());
|
|
utils.showToast('Please fill all fields');
|
|
} else {
|
|
Uploadata();
|
|
}
|
|
}),
|
|
sizedBoxHeight(20.h),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
width: 160,
|
|
decoration: const ShapeDecoration(
|
|
shape: RoundedRectangleBorder(
|
|
side: BorderSide(
|
|
width: 0.50,
|
|
strokeAlign:
|
|
BorderSide.strokeAlignCenter,
|
|
color: Color(0xFF434A53),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
sizedBoxWidth(6.w),
|
|
text14400white('Or'),
|
|
sizedBoxWidth(6.w),
|
|
Container(
|
|
width: 160,
|
|
decoration: const ShapeDecoration(
|
|
shape: RoundedRectangleBorder(
|
|
side: BorderSide(
|
|
width: 0.50,
|
|
strokeAlign:
|
|
BorderSide.strokeAlignCenter,
|
|
color: Color(0xFF434A53),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
sizedBoxHeight(20.h),
|
|
Center(
|
|
child: SizedBox(
|
|
width: 220.w,
|
|
child: Row(
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
Get.toNamed(RouteName.verifygoogleapplepage);
|
|
},
|
|
child: Container(
|
|
width: 55,
|
|
height: 55,
|
|
decoration: ShapeDecoration(
|
|
gradient: LinearGradient(
|
|
begin:
|
|
const Alignment(0.71, -0.70),
|
|
end: const Alignment(-0.71, 0.7),
|
|
colors: [
|
|
Colors.white.withOpacity(
|
|
0.07999999821186066),
|
|
Colors.white.withOpacity(
|
|
0.12999999523162842)
|
|
],
|
|
),
|
|
shape: const OvalBorder(
|
|
side: BorderSide(
|
|
width: 0.50,
|
|
color: Color(0xFF434A53)),
|
|
),
|
|
image: const DecorationImage(
|
|
image: AssetImage(
|
|
'assets/images/png/login2.png'))),
|
|
),
|
|
),
|
|
const Spacer(),
|
|
GestureDetector(
|
|
onTap: () {
|
|
Get.toNamed(RouteName.verifygoogleapplepage);
|
|
|
|
},
|
|
child: Container(
|
|
width: 55,
|
|
height: 55,
|
|
decoration: ShapeDecoration(
|
|
gradient: LinearGradient(
|
|
begin:
|
|
const Alignment(0.71, -0.70),
|
|
end: const Alignment(-0.71, 0.7),
|
|
colors: [
|
|
Colors.white.withOpacity(
|
|
0.07999999821186066),
|
|
Colors.white.withOpacity(
|
|
0.12999999523162842)
|
|
],
|
|
),
|
|
shape: const OvalBorder(
|
|
side: BorderSide(
|
|
width: 0.50,
|
|
color: Color(0xFF434A53)),
|
|
),
|
|
image: const DecorationImage(
|
|
image: AssetImage(
|
|
'assets/images/png/login3.png'))),
|
|
),
|
|
),
|
|
const Spacer(),
|
|
Container(
|
|
width: 55,
|
|
height: 55,
|
|
decoration: ShapeDecoration(
|
|
gradient: LinearGradient(
|
|
begin:
|
|
const Alignment(0.71, -0.70),
|
|
end: const Alignment(-0.71, 0.7),
|
|
colors: [
|
|
Colors.white.withOpacity(
|
|
0.07999999821186066),
|
|
Colors.white.withOpacity(
|
|
0.12999999523162842)
|
|
],
|
|
),
|
|
shape: const OvalBorder(
|
|
side: BorderSide(
|
|
width: 0.50,
|
|
color: Color(0xFF434A53)),
|
|
),
|
|
image: const DecorationImage(
|
|
image: AssetImage(
|
|
'assets/images/png/login4.png'))),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
sizedBoxHeight(20.h),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
],
|
|
)),
|
|
);
|
|
}
|
|
}
|