Adding base project of flutter-hybrid
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,263 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../Utils/size_utils.dart';
|
||||
import '../../theme/app_style.dart';
|
||||
import '../../widgets/custom_button.dart';
|
||||
import '../../widgets/custom_text_form_field.dart';
|
||||
import 'SignUpService.dart';
|
||||
|
||||
class CreateAccountScreen extends StatefulWidget {
|
||||
CreateAccountScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CreateAccountScreenState createState() => _CreateAccountScreenState();
|
||||
}
|
||||
|
||||
class _CreateAccountScreenState extends State<CreateAccountScreen> {
|
||||
final SignUpApiService userService = SignUpApiService();
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
late BuildContext _context; // Store the current context
|
||||
late var account_id; // Store the account_id
|
||||
|
||||
bool _isEmailValid = true;
|
||||
void _validateEmail(String email) {
|
||||
setState(() {
|
||||
_isEmailValid =
|
||||
RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$').hasMatch(email);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_context = context; // Store the context
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Create Account')),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("Company Name",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
onsaved: (value) => formData['companyName'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Company Name';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter Company Name",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputType: TextInputType.text
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("Email",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
onsaved: (value) => formData['email'] = value,
|
||||
onChanged: _validateEmail,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Email';
|
||||
}else if(!_isEmailValid){
|
||||
return 'Please enter a valid email';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter Email",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputType: TextInputType.text
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("Mobile Number",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
textInputType: TextInputType.phone,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'[0-9]'))
|
||||
],
|
||||
onsaved: (value) => formData['mobile'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Mob No';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter Mobile Number",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("Workspace",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
onsaved: (value) => formData['workspace'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Workspace';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter Workspace",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputType: TextInputType.text
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("Gst Number",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
onsaved: (value) => formData['gstNumber'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Gst Number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter Gst Number",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputType: TextInputType.text
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("pancard",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
onsaved: (value) => formData['pancard'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Pancard';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter pancard",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputType: TextInputType.text
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("Working",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
onsaved: (value) => formData['working'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Working';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter Working",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputType: TextInputType.text
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 5), // Add margin
|
||||
child: CustomButton(
|
||||
height: getVerticalSize(50),
|
||||
width: getHorizontalSize(396),
|
||||
text: "SUBMIT",
|
||||
margin: getMargin(top: 25),
|
||||
onTap: () async {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
{
|
||||
try {
|
||||
print('form data is $formData');
|
||||
|
||||
final response =
|
||||
await userService.createAccount(formData);
|
||||
|
||||
account_id = response['account_id'].toString();
|
||||
print(
|
||||
'after create account account id is $account_id');
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.pop(
|
||||
_context, account_id); // Pop with account_id
|
||||
|
||||
// Navigator.pop(context);
|
||||
} catch (e) {
|
||||
// ignore: use_build_context_synchronously
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error'),
|
||||
content: Text('Account Creation Failed: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'SignUpService.dart';
|
||||
|
||||
class CreateUserScreen extends StatefulWidget {
|
||||
CreateUserScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CreateUserScreenState createState() => _CreateUserScreenState();
|
||||
}
|
||||
|
||||
class _CreateUserScreenState extends State<CreateUserScreen> {
|
||||
int _currentStep = 0;
|
||||
|
||||
// Create a global key for each step
|
||||
final GlobalKey<StepCreateAccountState> createAccountKey =
|
||||
GlobalKey<StepCreateAccountState>();
|
||||
|
||||
final GlobalKey<StepGetEmailVerificationState> emailVerificationKey =
|
||||
GlobalKey<StepGetEmailVerificationState>();
|
||||
|
||||
final GlobalKey<StepGetRegistrationState> registrationKey =
|
||||
GlobalKey<StepGetRegistrationState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Sign Up - Step ${_currentStep + 1}'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
// Display the current step
|
||||
Expanded(
|
||||
child: _buildStep(_currentStep),
|
||||
),
|
||||
|
||||
// Navigation buttons
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (_currentStep > 0)
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentStep--;
|
||||
});
|
||||
},
|
||||
child: const Text('Previous'),
|
||||
),
|
||||
if (_currentStep < 2)
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
_proceedToNextStep();
|
||||
},
|
||||
child: const Text('Next'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Function to build the appropriate step based on the current step index
|
||||
Widget _buildStep(int stepIndex) {
|
||||
switch (stepIndex) {
|
||||
case 0:
|
||||
return StepCreateAccount(
|
||||
key: createAccountKey,
|
||||
onNext: () {
|
||||
_proceedToNextStep();
|
||||
},
|
||||
);
|
||||
case 1:
|
||||
return StepGetEmailVerification(
|
||||
key: emailVerificationKey,
|
||||
onNext: () {
|
||||
_proceedToNextStep();
|
||||
},
|
||||
);
|
||||
case 2:
|
||||
return StepGetRegistration(
|
||||
key: registrationKey,
|
||||
onNext: () {
|
||||
_proceedToNextStep();
|
||||
},
|
||||
);
|
||||
default:
|
||||
return Container(); // Return an empty container by default
|
||||
}
|
||||
}
|
||||
|
||||
// Function to proceed to the next step
|
||||
void _proceedToNextStep() {
|
||||
if (_currentStep < 2) {
|
||||
setState(() {
|
||||
_currentStep++;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Define your individual step widgets here
|
||||
|
||||
class StepCreateAccount extends StatefulWidget {
|
||||
final Function onNext;
|
||||
|
||||
const StepCreateAccount({Key? key, required this.onNext}) : super(key: key);
|
||||
|
||||
@override
|
||||
StepCreateAccountState createState() => StepCreateAccountState();
|
||||
}
|
||||
|
||||
class StepCreateAccountState extends State<StepCreateAccount> {
|
||||
// Add your state variables for this step here
|
||||
String? accountId;
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final SignUpApiService userService = SignUpApiService();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
children: [
|
||||
const Text('Step 1: Create Account'),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Company Name'),
|
||||
onSaved: (value) => formData['companyName'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Company Name';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Email'),
|
||||
onSaved: (value) => formData['email'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Email';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Mobile No'),
|
||||
onSaved: (value) => formData['mobile'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Mob No';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Workspace'),
|
||||
onSaved: (value) => formData['workspace'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Workspace';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Gst Number'),
|
||||
onSaved: (value) => formData['gstNumber'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Gst Number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'pancard'),
|
||||
onSaved: (value) => formData['pancard'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Pancard';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Working'),
|
||||
onSaved: (value) => formData['working'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Working';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 5), // Add margin
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
{
|
||||
try {
|
||||
print('form data is $formData');
|
||||
|
||||
final response =
|
||||
await userService.createAccount(formData);
|
||||
|
||||
accountId = response['account_id'].toString();
|
||||
print('after create account account id is $accountId');
|
||||
// ignore: use_build_context_synchronously
|
||||
// Navigator.pop(
|
||||
// _context, accountId); // Pop with account_id
|
||||
|
||||
// Navigator.pop(context);
|
||||
} catch (e) {
|
||||
// ignore: use_build_context_synchronously
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error'),
|
||||
content: Text('Account Creation Failed: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
child: const SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'SUBMIT',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (accountId != null) Text('Selected Account ID: $accountId'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StepGetEmailVerification extends StatefulWidget {
|
||||
final Function onNext;
|
||||
|
||||
const StepGetEmailVerification({Key? key, required this.onNext})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
StepGetEmailVerificationState createState() =>
|
||||
StepGetEmailVerificationState();
|
||||
}
|
||||
|
||||
class StepGetEmailVerificationState extends State<StepGetEmailVerification> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
child: Text('Step 2: Get Email Verification'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StepGetRegistration extends StatefulWidget {
|
||||
final Function onNext;
|
||||
|
||||
const StepGetRegistration({Key? key, required this.onNext}) : super(key: key);
|
||||
|
||||
@override
|
||||
StepGetRegistrationState createState() => StepGetRegistrationState();
|
||||
}
|
||||
|
||||
class StepGetRegistrationState extends State<StepGetRegistration> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
child: Text('Step 3: Get Registration'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Example of a dialog to create an account
|
||||
class CreateAccountDialog extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('Create Account'),
|
||||
content: Text('Account created successfully!'),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop('12345'); // Pass the created account ID
|
||||
},
|
||||
child: Text('OK'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../Utils/image_constant.dart';
|
||||
import '../../Utils/size_utils.dart';
|
||||
import '../../providers/token_manager.dart';
|
||||
import '../../theme/app_style.dart';
|
||||
import '../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../widgets/custom_button.dart';
|
||||
import '../../widgets/custom_text_form_field.dart';
|
||||
import '../Login Screen/login_screen.dart';
|
||||
import 'CreateAccount.dart';
|
||||
import 'SignUpService.dart';
|
||||
|
||||
class RegistrationDetailsScreen extends StatefulWidget {
|
||||
var email;
|
||||
RegistrationDetailsScreen({required this.email});
|
||||
|
||||
@override
|
||||
_RegistrationDetailsScreenState createState() =>
|
||||
_RegistrationDetailsScreenState();
|
||||
}
|
||||
|
||||
class _RegistrationDetailsScreenState extends State<RegistrationDetailsScreen> {
|
||||
final SignUpApiService userService = SignUpApiService();
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
late BuildContext _context; // Store the current context
|
||||
var account_id = null; // Initialize with null
|
||||
var selectedAccount; // Use nullable type
|
||||
|
||||
var newPassword = ''; // Store the value of the confirm password field
|
||||
var confirmPassword = ''; // Store the value of the confirm password field
|
||||
// Validate that the passwords match
|
||||
String? _validatePasswordMatch(String value) {
|
||||
if (value != newPassword) {
|
||||
print('value is $value and new is $newPassword');
|
||||
return 'Passwords do not match';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
bool _newpasswordVisible = false;
|
||||
bool _confirmpasswordVisible = false;
|
||||
|
||||
bool _isPasswordValid = true;
|
||||
void _validatePassword(String password) {
|
||||
setState(() {
|
||||
_isPasswordValid = password.isNotEmpty;
|
||||
});
|
||||
}
|
||||
|
||||
bool _isEmailValid = true;
|
||||
void _validateEmail(String email) {
|
||||
setState(() {
|
||||
_isEmailValid =
|
||||
RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$').hasMatch(email);
|
||||
});
|
||||
}
|
||||
|
||||
void showSuccessMessage(String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
duration: const Duration(seconds: 2),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showErrorMessage(String error) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(error),
|
||||
duration: const Duration(seconds: 2),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_context = context; // Store the context
|
||||
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
height: getVerticalSize(54),
|
||||
leadingWidth: 40,
|
||||
leading: AppbarImage(
|
||||
height: getSize(24),
|
||||
width: getSize(24),
|
||||
svgPath: ImageConstant.imgArrowleft,
|
||||
margin: getMargin(left: 16, top: 13, bottom: 17),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
centerTitle: true,
|
||||
title: AppbarTitle(text: "Registration")),
|
||||
//AppBar(title: const Text('Registration')),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Container(
|
||||
height: 500,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("First Name",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
onsaved: (value) => formData['first_name'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter First Name';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter First Name",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputType: TextInputType.text
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("Last Name",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
onsaved: (value) => formData['last_name'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Last Name';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter Last Name",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputType: TextInputType.text
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("Mobile Number",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
textInputType: TextInputType.phone,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'[0-9]'))
|
||||
],
|
||||
onsaved: (value) => formData['mob_no'] = value,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Mobile Number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "enter Mobile Number",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("New Password",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
hintText: "New Password",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputAction: TextInputAction.done,
|
||||
textInputType:TextInputType.visiblePassword,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Password';
|
||||
}else if(!_isPasswordValid){
|
||||
return 'Please enter a valid password';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
suffix: IconButton(
|
||||
icon: Icon(
|
||||
_newpasswordVisible
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_newpasswordVisible = !_newpasswordVisible;
|
||||
});
|
||||
},
|
||||
),
|
||||
onsaved: (value) => formData['new_password'] = value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
newPassword = value!;
|
||||
});
|
||||
_validatePassword;
|
||||
},
|
||||
suffixConstraints: BoxConstraints(
|
||||
maxHeight: getVerticalSize(44)),
|
||||
isObscureText: !_newpasswordVisible),
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Text("Confirm Password",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium16Bluegray900)),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
hintText: "Confirm Password",
|
||||
margin: getMargin(top: 6),
|
||||
padding: TextFormFieldPadding.PaddingT12,
|
||||
textInputAction: TextInputAction.done,
|
||||
textInputType:TextInputType.visiblePassword,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Password';
|
||||
}
|
||||
return _validatePasswordMatch(confirmPassword);
|
||||
},
|
||||
onsaved: (value) => formData['confirm_password'] = value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
confirmPassword = value!; // Update confirmPassword
|
||||
});
|
||||
},
|
||||
suffix: IconButton(
|
||||
icon: Icon(
|
||||
_confirmpasswordVisible
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_confirmpasswordVisible = !_confirmpasswordVisible;
|
||||
});
|
||||
},
|
||||
),
|
||||
suffixConstraints: BoxConstraints(
|
||||
maxHeight: getVerticalSize(44)),
|
||||
isObscureText: !_confirmpasswordVisible,),
|
||||
|
||||
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text('Add Account'),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
final accountId = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CreateAccountScreen(),
|
||||
),
|
||||
);
|
||||
|
||||
if (accountId != null) {
|
||||
setState(() {
|
||||
selectedAccount = accountId;
|
||||
formData['account_id'] = accountId;
|
||||
account_id =
|
||||
accountId; // Update the account_id here
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
if (account_id != null)
|
||||
Container(
|
||||
margin:
|
||||
const EdgeInsets.symmetric(vertical: 5), // Add margin
|
||||
child: CustomButton(
|
||||
height: getVerticalSize(50),
|
||||
width: getHorizontalSize(396),
|
||||
text: "SUBMIT",
|
||||
margin: getMargin(top: 25),
|
||||
onTap: () async {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
|
||||
print('formdata is $formData');
|
||||
|
||||
formData['usrGrpId'] = 46;
|
||||
formData['account_id'] = account_id;
|
||||
formData['email'] = widget.email;
|
||||
|
||||
{
|
||||
final token = await TokenManager.getToken();
|
||||
try {
|
||||
print(formData);
|
||||
|
||||
await userService
|
||||
.createuser(token!, formData)
|
||||
.then((_) => {
|
||||
const LoginScreen(),
|
||||
});
|
||||
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 5));
|
||||
|
||||
showSuccessMessage('User created successfully');
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const LoginScreen()));
|
||||
// moveToNextStep();
|
||||
} catch (e) {
|
||||
showErrorMessage('Failed to create User: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../resources/api_constants.dart';
|
||||
|
||||
class SignUpApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final Dio dio = Dio();
|
||||
|
||||
// get all account
|
||||
Future<List<Map<String, dynamic>>> getallAccount(String token) async {
|
||||
try {
|
||||
dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
final response = await dio.get('$baseUrl/users/sysaccount/sysaccount');
|
||||
|
||||
final responseData = response.data;
|
||||
|
||||
print('response data is ... $responseData');
|
||||
|
||||
if (responseData is List) {
|
||||
// If the response is a list, cast it to the expected type
|
||||
final entities = responseData.cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} else if (responseData is Map<String, dynamic>) {
|
||||
// If the response is a single object, wrap it in a list
|
||||
return [responseData];
|
||||
} else {
|
||||
// Handle other unexpected response types here
|
||||
throw Exception('Unexpected response type');
|
||||
}
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Account: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Create account
|
||||
Future<Map<String, dynamic>> createAccount(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
// dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
final response = await dio
|
||||
.post('$baseUrl/token/users/sysaccount/savesysaccount', data: entity);
|
||||
|
||||
print(' created account is $response');
|
||||
return response.data;
|
||||
} catch (e) {
|
||||
throw Exception('Failed To Create Account: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// SEND EMAIL FOR OTP
|
||||
Future<void> sendEmail(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api...$entity");
|
||||
// dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
await dio.post('$baseUrl/token/user/send_email', data: entity);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Send Email: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// RESEND EMAIL FOR OTP
|
||||
Future<void> resendEmail(String email) async {
|
||||
try {
|
||||
// dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
await dio.post('$baseUrl/token/user/resend_otp?email=$email');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to ReSend Email: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// OTP VEFICATION
|
||||
Future<void> otpverification(String email, String otp) async {
|
||||
try {
|
||||
// dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
await dio
|
||||
.post('$baseUrl/token/user/otp_verification?email=$email&otp=$otp');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Verify Otp: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> createuser(String token, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api...$entity");
|
||||
dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
await dio.post('$baseUrl/token/addOneAppUser', data: entity);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create User: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateUser(
|
||||
String token, int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
await dio.put('$baseUrl/api/updateAppUserDto/$entityId', data: entity);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update Backend: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteUser(String token, int entityId) async {
|
||||
try {
|
||||
dio.options.headers['Authorization'] = 'Bearer $token';
|
||||
await dio.delete('$baseUrl/api/delete_usr/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete User: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
// import 'package:flutter/material.dart';
|
||||
//
|
||||
// import 'package:flutter/services.dart';
|
||||
//
|
||||
// import 'RegistrationDetails.dart';
|
||||
// import 'SignUpService.dart';
|
||||
//
|
||||
// enum RegistrationStep {
|
||||
// SendOTP,
|
||||
// VerifyOTP,
|
||||
// EnterUserInfo,
|
||||
// SelectAccount,
|
||||
// }
|
||||
//
|
||||
// class SignUpUserScreen extends StatefulWidget {
|
||||
// SignUpUserScreen({Key? key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _SignUpUserScreenState createState() => _SignUpUserScreenState();
|
||||
// }
|
||||
//
|
||||
// class _SignUpUserScreenState extends State<SignUpUserScreen> {
|
||||
// final SignUpApiService userService = SignUpApiService();
|
||||
//
|
||||
// final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
// final Map<String, dynamic> formData = {};
|
||||
// final _formKey = GlobalKey<FormState>();
|
||||
//
|
||||
// var selectedAccount;
|
||||
// var email;
|
||||
// var otp;
|
||||
// var confirmPassword;
|
||||
//
|
||||
// bool _passwordVisible = false;
|
||||
// bool _isPasswordValid = true;
|
||||
// void _validatePassword(String password) {
|
||||
// setState(() {
|
||||
// _isPasswordValid = password.isNotEmpty;
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// RegistrationStep currentStep = RegistrationStep.SendOTP;
|
||||
//
|
||||
// void moveToNextStep() {
|
||||
// setState(() {
|
||||
// if (currentStep == RegistrationStep.SendOTP) {
|
||||
// currentStep = RegistrationStep.VerifyOTP;
|
||||
// } else if (currentStep == RegistrationStep.VerifyOTP) {
|
||||
// currentStep = RegistrationStep.EnterUserInfo;
|
||||
// } else if (currentStep == RegistrationStep.EnterUserInfo) {
|
||||
// currentStep = RegistrationStep.SelectAccount;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// void showSuccessMessage(String message) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// content: Text(message),
|
||||
// duration: const Duration(seconds: 2),
|
||||
// backgroundColor: Colors.green,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// void showErrorMessage(String error) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// content: Text(error),
|
||||
// duration: const Duration(seconds: 2),
|
||||
// backgroundColor: Colors.red,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// key: _scaffoldKey,
|
||||
// appBar: AppBar(
|
||||
// title: const Text('Create User'),
|
||||
// ),
|
||||
// body: Builder(
|
||||
// builder: (BuildContext context) {
|
||||
// return SingleChildScrollView(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(16),
|
||||
// child: Form(
|
||||
// key: _formKey,
|
||||
// child: SizedBox(
|
||||
// height: MediaQuery.of(context).size.height *
|
||||
// 0.5, // Use 50% of the screen height
|
||||
// child: ListView.builder(
|
||||
// itemCount: 1,
|
||||
// itemBuilder: (BuildContext context, int index) {
|
||||
// if (currentStep == RegistrationStep.SendOTP) {
|
||||
// return Column(
|
||||
// children: [
|
||||
// const SizedBox(height: 16),
|
||||
// TextFormField(
|
||||
// decoration:
|
||||
// const InputDecoration(labelText: 'Email'),
|
||||
// keyboardType: TextInputType.emailAddress,
|
||||
// onSaved: (value) => email = value,
|
||||
// validator: (value) {
|
||||
// if (value == null || value.isEmpty) {
|
||||
// return 'Please enter Email';
|
||||
// }
|
||||
// return null;
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 16),
|
||||
// Container(
|
||||
// margin: const EdgeInsets.symmetric(vertical: 5),
|
||||
// child: ElevatedButton(
|
||||
// onPressed: () async {
|
||||
// if (_formKey.currentState!.validate()) {
|
||||
// _formKey.currentState!.save();
|
||||
//
|
||||
// formData['usrGrpId'] = 46;
|
||||
// formData['email'] = email;
|
||||
// try {
|
||||
// print('send email data is $formData');
|
||||
//
|
||||
// await userService.sendEmail(formData);
|
||||
//
|
||||
// await Future.delayed(
|
||||
// const Duration(seconds: 2));
|
||||
//
|
||||
// moveToNextStep();
|
||||
// } catch (e) {
|
||||
// showErrorMessage(
|
||||
// 'Failed to send OTP: $e');
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// child: const SizedBox(
|
||||
// width: double.infinity,
|
||||
// height: 50,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// 'Send OTP',
|
||||
// style: TextStyle(
|
||||
// fontSize: 16,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// } else if (currentStep == RegistrationStep.VerifyOTP) {
|
||||
// return Column(
|
||||
// children: [
|
||||
// const SizedBox(height: 16),
|
||||
// TextFormField(
|
||||
// decoration:
|
||||
// const InputDecoration(labelText: 'Email'),
|
||||
// initialValue: email,
|
||||
// readOnly: true,
|
||||
// ),
|
||||
// const SizedBox(height: 16),
|
||||
// Row(
|
||||
// children: [
|
||||
// Container(
|
||||
// height: 100,
|
||||
// width: 250,
|
||||
// padding: const EdgeInsets.symmetric(
|
||||
// horizontal: 16),
|
||||
// decoration: BoxDecoration(
|
||||
// borderRadius: BorderRadius.circular(10),
|
||||
// border: Border.all(color: Colors.grey),
|
||||
// ),
|
||||
// child: TextFormField(
|
||||
// decoration:
|
||||
// const InputDecoration(labelText: 'OTP'),
|
||||
// onChanged: (value) {
|
||||
// otp = value;
|
||||
// },
|
||||
// onSaved: (value) => otp = value,
|
||||
// validator: (value) {
|
||||
// if (value == null || value.isEmpty) {
|
||||
// return 'Please enter OTP';
|
||||
// }
|
||||
// return null;
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ElevatedButton(
|
||||
// onPressed: () async {
|
||||
// try {
|
||||
// await userService.resendEmail(email);
|
||||
//
|
||||
// await Future.delayed(
|
||||
// const Duration(seconds: 5));
|
||||
// showSuccessMessage('OTP RESEND');
|
||||
// } catch (e) {
|
||||
// showErrorMessage(
|
||||
// 'Failed to resend OTP: $e');
|
||||
// }
|
||||
// },
|
||||
// child: const SizedBox(
|
||||
// width: 100,
|
||||
// height: 50,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// 'Resend OTP',
|
||||
// style: TextStyle(
|
||||
// fontSize: 16,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// const SizedBox(height: 16),
|
||||
// ElevatedButton(
|
||||
// onPressed: () async {
|
||||
// try {
|
||||
// print('email is $email and otp is $otp');
|
||||
// await userService.otpverification(email, otp);
|
||||
//
|
||||
// moveToNextStep();
|
||||
// showSuccessMessage(
|
||||
// 'Email verified successfully');
|
||||
// } catch (e) {
|
||||
// showErrorMessage('Failed to verify OTP: $e');
|
||||
// }
|
||||
// },
|
||||
// child: const SizedBox(
|
||||
// width: double.infinity,
|
||||
// height: 50,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// 'VERIFY EMAIL',
|
||||
// style: TextStyle(
|
||||
// fontSize: 16,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// } else if (currentStep ==
|
||||
// RegistrationStep.EnterUserInfo) {
|
||||
// return Column(
|
||||
// children: [
|
||||
// // Other widgets for user information entry
|
||||
// ElevatedButton(
|
||||
// onPressed: () async {
|
||||
// // Navigate to the RegistrationDetailsScreen when the button is pressed
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// RegistrationDetailsScreen(email: email),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// child: const SizedBox(
|
||||
// width: double.infinity,
|
||||
// height: 50,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// 'Go to Registration Details',
|
||||
// style: TextStyle(
|
||||
// fontSize: 16,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// } else {
|
||||
// return Container(); // Return an empty container if none of the conditions match
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,138 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StepGetEmailVerification extends StatefulWidget {
|
||||
final LabeledGlobalKey<FormState> emailPasswordFormKey;
|
||||
// final Function updateSignUpDetails;
|
||||
|
||||
// final String email;
|
||||
final Function proceedToNextStep;
|
||||
const StepGetEmailVerification(
|
||||
{Key? key,
|
||||
// required this.updateSignUpDetails,
|
||||
// required this.email,
|
||||
required this.emailPasswordFormKey,
|
||||
required this.proceedToNextStep})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_StepGetEmailVerificationState createState() =>
|
||||
_StepGetEmailVerificationState();
|
||||
}
|
||||
|
||||
class _StepGetEmailVerificationState extends State<StepGetEmailVerification> {
|
||||
String email = "";
|
||||
String emailErrorMessage = "";
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// email = widget.email;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// widget.emailPasswordFormKey.currentState?.validate();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Form(
|
||||
key: widget.emailPasswordFormKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border:
|
||||
Border.all(width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
// initialValue: email,
|
||||
// validator: _validateNewPassword,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding:
|
||||
EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "email",
|
||||
hintStyle: TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style: const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
),
|
||||
if (emailErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"\t\t\t\t$emailErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
// Email CODE END HERE
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
// void errorMessageSetter(String fieldName, String message) {
|
||||
// setState(() {
|
||||
// switch (fieldName) {
|
||||
// case 'NEW-PASSWORD':
|
||||
// new_passwordErrorMessage = message;
|
||||
// break;
|
||||
|
||||
// case 'CONFIRM-PASSWORD':
|
||||
// confirm_passwordErrorMessage = message;
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// String? _validateNewPassword(String? value) {
|
||||
// if (value == null || value.isEmpty) {
|
||||
// errorMessageSetter('NEW-PASSWORD', 'password cannot be empty');
|
||||
// } else {
|
||||
// errorMessageSetter('NEW-PASSWORD', "");
|
||||
|
||||
// widget.updateSignUpDetails('new_password', value);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// String? _validateConfirmpassword(String? value) {
|
||||
// if (value == null || value.isEmpty) {
|
||||
// errorMessageSetter(
|
||||
// 'CONFIRM-PASSWORD', 'you must provide a valid confirm-password');
|
||||
// } else {
|
||||
// errorMessageSetter('CONFIRM-PASSWORD', "");
|
||||
// widget.updateSignUpDetails('confirm_password', value);
|
||||
// }
|
||||
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StepGetRegistration extends StatefulWidget {
|
||||
final LabeledGlobalKey<FormState> bankAccountFormKey;
|
||||
// final Function updateSignUpDetails;
|
||||
final Function showConfirmSignUpButton;
|
||||
final Function registrationDetails;
|
||||
final Function finalStepProccessing;
|
||||
const StepGetRegistration(
|
||||
{Key? key,
|
||||
// required this.updateSignUpDetails,
|
||||
required this.registrationDetails,
|
||||
required this.bankAccountFormKey,
|
||||
required this.showConfirmSignUpButton,
|
||||
required this.finalStepProccessing})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_StepGetRegistrationState createState() => _StepGetRegistrationState();
|
||||
}
|
||||
|
||||
class _StepGetRegistrationState extends State<StepGetRegistration> {
|
||||
String firstname = "";
|
||||
String firstnameErrorMessage = "";
|
||||
|
||||
String lastName = "";
|
||||
String lastNameErrorMessage = "";
|
||||
|
||||
String mobNo = "";
|
||||
String mobNoErrorMessage = "";
|
||||
|
||||
String password = "";
|
||||
String passwordErrorMessage = "";
|
||||
|
||||
String confirmPassword = "";
|
||||
String confirmPasswordErrorMessage = "";
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Map<String, String> signUpDetails = widget.registrationDetails();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
firstname = signUpDetails['first_name']!;
|
||||
lastName = signUpDetails['last_name']!;
|
||||
mobNo = signUpDetails['mob_no']!;
|
||||
password = signUpDetails['new_password']!;
|
||||
confirmPassword = signUpDetails['confirm_password']!;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// widget.bankAccountFormKey.currentState?.validate();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Form(
|
||||
key: widget.bankAccountFormKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border:
|
||||
Border.all(width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
initialValue: firstname,
|
||||
onChanged: _toggleSignUpButtonVisibility,
|
||||
// validator: _validateEmailId,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
onFieldSubmitted: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
widget.finalStepProccessing();
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding:
|
||||
EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "first name",
|
||||
hintStyle: TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style: const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
),
|
||||
if (firstnameErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Text(
|
||||
"\t\t\t\t$firstnameErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
|
||||
// first name code end here
|
||||
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border:
|
||||
Border.all(width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
initialValue: lastName,
|
||||
onChanged: _toggleSignUpButtonVisibility,
|
||||
// validator: _validateEmailId,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
onFieldSubmitted: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
widget.finalStepProccessing();
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding:
|
||||
EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "last name",
|
||||
hintStyle: TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style: const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
),
|
||||
if (lastNameErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Text(
|
||||
"\t\t\t\t$lastNameErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
|
||||
// last name code
|
||||
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border:
|
||||
Border.all(width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
initialValue: mobNo,
|
||||
onChanged: _toggleSignUpButtonVisibility,
|
||||
// validator: _validateEmailId,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
onFieldSubmitted: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
widget.finalStepProccessing();
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding:
|
||||
EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "mob no",
|
||||
hintStyle: TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style: const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
),
|
||||
if (mobNoErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Text(
|
||||
"\t\t\t\t$mobNoErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
|
||||
// mob no code end
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border:
|
||||
Border.all(width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
initialValue: password,
|
||||
onChanged: _toggleSignUpButtonVisibility,
|
||||
// validator: _validateEmailId,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
onFieldSubmitted: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
widget.finalStepProccessing();
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding:
|
||||
EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "password",
|
||||
hintStyle: TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style: const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
),
|
||||
if (passwordErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Text(
|
||||
"\t\t\t\t$passwordErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
|
||||
// new password code end
|
||||
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border:
|
||||
Border.all(width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
initialValue: confirmPassword,
|
||||
onChanged: _toggleSignUpButtonVisibility,
|
||||
// validator: _validateEmailId,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
onFieldSubmitted: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
widget.finalStepProccessing();
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding:
|
||||
EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "confirmPassword",
|
||||
hintStyle: TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style: const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
),
|
||||
if (confirmPasswordErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Text(
|
||||
"\t\t\t\t$confirmPasswordErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
|
||||
// confirm password code end here
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
// void errorMessageSetter(String fieldName, String message) {
|
||||
// setState(() {
|
||||
// switch (fieldName) {
|
||||
// case 'EMAIL-Id':
|
||||
// emailErrorMessage = message;
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// String? _validateEmailId(String? value) {
|
||||
// if (value == null || value.isEmpty) {
|
||||
// errorMessageSetter('EMAIL-ID', 'you must provide a valid email-id');
|
||||
// } else if (!validEmailFormat.hasMatch(value)) {
|
||||
// errorMessageSetter('EMAIL-ID', 'format of your email address is invalid');
|
||||
// } else {
|
||||
// errorMessageSetter('EMAIL-ID', "");
|
||||
// widget.updateSignUpDetails('email', value);
|
||||
// }
|
||||
|
||||
// return null;
|
||||
// }
|
||||
|
||||
void _toggleSignUpButtonVisibility(String value) {
|
||||
widget.registrationDetails('confirmPassword', value);
|
||||
if (value.isNotEmpty) {
|
||||
widget.showConfirmSignUpButton(true);
|
||||
} else {
|
||||
widget.showConfirmSignUpButton(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'sign_up_steps.dart';
|
||||
|
||||
class SignUpScreen extends StatefulWidget {
|
||||
const SignUpScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_SignUpScreenState createState() => _SignUpScreenState();
|
||||
}
|
||||
|
||||
class _SignUpScreenState extends State<SignUpScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
child: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(45),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
child: Image.asset('/images/hadwin_system/cldnsure.png'),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
const SignUpSteps(), // GO TO SIGN UP FORM
|
||||
const SizedBox(
|
||||
height: 27,
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 16,
|
||||
child: Center(
|
||||
child: InkWell(
|
||||
child: const Text(
|
||||
'Already have an account? Sign in',
|
||||
style:
|
||||
TextStyle(fontSize: 14, color: Color(0xFF929BAB)),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 3,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
onWillPop: () => Future.value(false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pinput/pinput.dart';
|
||||
|
||||
import '../../Utils/color_constants.dart';
|
||||
import '../../Utils/image_constant.dart';
|
||||
import '../../Utils/size_utils.dart';
|
||||
import '../../theme/app_style.dart';
|
||||
import '../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../widgets/custom_button.dart';
|
||||
import '../../widgets/custom_image_view.dart';
|
||||
import '../../widgets/custom_text_form_field.dart';
|
||||
import 'RegistrationDetails.dart';
|
||||
import 'SignUpService.dart';
|
||||
|
||||
enum RegistrationStep {
|
||||
SendOTP,
|
||||
VerifyOTP,
|
||||
EnterUserInfo,
|
||||
SelectAccount,
|
||||
}
|
||||
|
||||
class SignUpUserScreenNew extends StatefulWidget {
|
||||
SignUpUserScreenNew({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_SignUpUserScreenState createState() => _SignUpUserScreenState();
|
||||
}
|
||||
|
||||
class _SignUpUserScreenState extends State<SignUpUserScreenNew> {
|
||||
final SignUpApiService userService = SignUpApiService();
|
||||
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
var selectedAccount;
|
||||
TextEditingController emailcontroller = TextEditingController();
|
||||
var email;
|
||||
var otp;
|
||||
var confirmPassword;
|
||||
|
||||
bool _passwordVisible = false;
|
||||
bool _isPasswordValid = true;
|
||||
void _validatePassword(String password) {
|
||||
setState(() {
|
||||
_isPasswordValid = password.isNotEmpty;
|
||||
});
|
||||
}
|
||||
|
||||
RegistrationStep currentStep = RegistrationStep.SendOTP;
|
||||
|
||||
void moveToNextStep() {
|
||||
setState(() {
|
||||
if (currentStep == RegistrationStep.SendOTP) {
|
||||
currentStep = RegistrationStep.VerifyOTP;
|
||||
} else if (currentStep == RegistrationStep.VerifyOTP) {
|
||||
currentStep = RegistrationStep.EnterUserInfo;
|
||||
} else if (currentStep == RegistrationStep.EnterUserInfo) {
|
||||
currentStep = RegistrationStep.SelectAccount;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void showSuccessMessage(String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
duration: const Duration(seconds: 2),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showErrorMessage(String error) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(error),
|
||||
duration: const Duration(seconds: 2),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: CustomAppBar(
|
||||
height: getVerticalSize(54),
|
||||
leadingWidth: 40,
|
||||
leading: AppbarImage(
|
||||
height: getSize(24),
|
||||
width: getSize(24),
|
||||
svgPath: ImageConstant.imgArrowleft,
|
||||
margin: getMargin(left: 16, top: 13, bottom: 17),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
centerTitle: true,
|
||||
title: AppbarTitle(text: "Create User")),
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height *
|
||||
0.5, // Use 50% of the screen height
|
||||
child: ListView.builder(
|
||||
itemCount: 1,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if(currentStep == RegistrationStep.SendOTP) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Email",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
focusNode: FocusNode(),
|
||||
controller: emailcontroller,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Email';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
hintText: "Enter Your Email",
|
||||
margin: getMargin(top: 7),
|
||||
textInputType: TextInputType.emailAddress),
|
||||
CustomButton(
|
||||
height: getVerticalSize(50),
|
||||
width: getHorizontalSize(396),
|
||||
text: "Send OTP",
|
||||
margin: getMargin(top: 25),
|
||||
onTap: () async {
|
||||
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
|
||||
formData['usrGrpId'] = 46;
|
||||
formData['email'] = emailcontroller.text;
|
||||
try {
|
||||
print('send email data is $formData');
|
||||
|
||||
await userService.sendEmail(formData);
|
||||
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2));
|
||||
|
||||
moveToNextStep();
|
||||
} catch (e) {
|
||||
showErrorMessage(
|
||||
'Failed to send OTP: $e');
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Padding(
|
||||
padding: getPadding(top: 28, bottom: 5),
|
||||
child: RichText(
|
||||
text: TextSpan(children: [
|
||||
TextSpan(
|
||||
text: "",
|
||||
style: TextStyle(
|
||||
color: ColorConstant.fromHex(
|
||||
"#ff12282a"),
|
||||
fontSize: getFontSize(16),
|
||||
fontFamily: 'Gilroy',
|
||||
fontWeight: FontWeight.w400)),
|
||||
TextSpan(
|
||||
text: " ",
|
||||
style: TextStyle(
|
||||
color: ColorConstant.fromHex(
|
||||
"#ff12282a"),
|
||||
fontSize: getFontSize(16),
|
||||
fontFamily: 'Gilroy',
|
||||
fontWeight: FontWeight.w700)),
|
||||
TextSpan(
|
||||
text: "",
|
||||
style: TextStyle(
|
||||
color: ColorConstant.fromHex(
|
||||
"#ff0061ff"),
|
||||
fontSize: getFontSize(16),
|
||||
fontFamily: 'Gilroy',
|
||||
fontWeight: FontWeight.w700,
|
||||
decoration:
|
||||
TextDecoration.underline))
|
||||
]),
|
||||
textAlign: TextAlign.left)))
|
||||
]);
|
||||
}
|
||||
else if(currentStep == RegistrationStep.VerifyOTP) {
|
||||
return Container(
|
||||
width: double.maxFinite,
|
||||
padding: getPadding(
|
||||
left: 16,
|
||||
top: 76,
|
||||
right: 16,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
CustomImageView(
|
||||
svgPath: ImageConstant.imgMobile,
|
||||
height: getVerticalSize(
|
||||
82,
|
||||
),
|
||||
width: getHorizontalSize(
|
||||
51,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 29,
|
||||
),
|
||||
child: Text(
|
||||
"Email Verification",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroySemiBold24,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: getHorizontalSize(
|
||||
302,
|
||||
),
|
||||
margin: getMargin(
|
||||
left: 46,
|
||||
top: 19,
|
||||
right: 46,
|
||||
),
|
||||
child: Text(
|
||||
"A mail with a 6-digit verification code was just sent to ${emailcontroller.text}",
|
||||
maxLines: null,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
),
|
||||
Pinput(
|
||||
length: 6,
|
||||
showCursor: true,
|
||||
defaultPinTheme: PinTheme(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: ColorConstant.blue50,
|
||||
),
|
||||
),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
onCompleted: (value) {
|
||||
setState(() {
|
||||
otp = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
CustomButton(
|
||||
height: getVerticalSize(
|
||||
50,
|
||||
),
|
||||
text: "Next",
|
||||
margin: getMargin(
|
||||
top: 40,
|
||||
),
|
||||
onTap: () async {
|
||||
try {
|
||||
print('email is $email and otp is $otp');
|
||||
await userService.otpverification(emailcontroller.text, otp);
|
||||
|
||||
moveToNextStep();
|
||||
showSuccessMessage(
|
||||
'Email verified successfully');
|
||||
} catch (e) {
|
||||
showErrorMessage('Failed to verify OTP: $e');
|
||||
}
|
||||
},
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
try {
|
||||
await userService.resendEmail(email);
|
||||
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 5));
|
||||
showSuccessMessage('OTP RESEND');
|
||||
} catch (e) {
|
||||
showErrorMessage(
|
||||
'Failed to resend OTP: $e');
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: getPadding(top: 3),
|
||||
child: Text("Forgot Password?",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
AppStyle.txtGilroyMedium14BlueA700)),
|
||||
),
|
||||
|
||||
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: getPadding(
|
||||
top: 18,
|
||||
bottom: 5,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 2,
|
||||
),
|
||||
child: Text(
|
||||
"Didn’t get the code?",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
left: 12,
|
||||
bottom: 1,
|
||||
),
|
||||
child: Text(
|
||||
"Resend",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroySemiBold16BlueA700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
else if (currentStep ==
|
||||
RegistrationStep.EnterUserInfo) {
|
||||
return Column(
|
||||
children: [
|
||||
CustomButton(
|
||||
height: getVerticalSize(
|
||||
50,
|
||||
),
|
||||
text: "Go to Registration Details",
|
||||
margin: getMargin(
|
||||
top: 40,
|
||||
),
|
||||
onTap: () async {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
RegistrationDetailsScreen(email: emailcontroller.text),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
else{
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,545 @@
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../hadwin_components.dart';
|
||||
import '../../utilities/slide_right_route.dart';
|
||||
import '../Login Screen/login_screen.dart';
|
||||
import 'StepGetEmailVerification.dart';
|
||||
import 'StepGetRegistration.dart';
|
||||
import 'step_createAccount.dart';
|
||||
|
||||
class SignUpSteps extends StatefulWidget {
|
||||
const SignUpSteps({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_SignUpStepsState createState() => _SignUpStepsState();
|
||||
}
|
||||
|
||||
class _SignUpStepsState extends State<SignUpSteps> {
|
||||
late PageController _signUpStepController;
|
||||
final createAccountFormKey = LabeledGlobalKey<FormState>("reateAccountForm");
|
||||
final emailVerificationFormKey =
|
||||
LabeledGlobalKey<FormState>("emailVerificationForm");
|
||||
final signUpFormKey = LabeledGlobalKey<FormState>("signUpForm");
|
||||
Map<String, String> accountDetails = {
|
||||
'companyName': '',
|
||||
'email': '',
|
||||
'mobile': '',
|
||||
'workspace': '',
|
||||
'gstNumber': '',
|
||||
'pancard': '',
|
||||
};
|
||||
Map<String, String> registrationDetails = {
|
||||
'first_name': '',
|
||||
'last_name': '',
|
||||
'mob_no': '',
|
||||
'new_password': '',
|
||||
'confirm_password': '',
|
||||
};
|
||||
Map<String, String> accountsDetails() => accountDetails;
|
||||
Map<String, String> registraionDetails() => registrationDetails;
|
||||
String? email;
|
||||
|
||||
int _currentStep = 0;
|
||||
List<bool> stepHasError = [false, false, false];
|
||||
List<bool> stepCompletedSuccessfully = [false, false, false];
|
||||
late List<Widget> signUpStepContent;
|
||||
bool confirmSignUpButton = false;
|
||||
@override
|
||||
void initState() {
|
||||
_signUpStepController = PageController();
|
||||
signUpStepContent = [
|
||||
StepCreateAccount(
|
||||
registrationDetails: accountsDetails,
|
||||
// updateSignUpDetails: updateSignUpDetails,
|
||||
nameAddressFormKey: createAccountFormKey,
|
||||
proceedToNextStep: _proceedToNextStep,
|
||||
),
|
||||
StepGetEmailVerification(
|
||||
// updateSignUpDetails: updateSignUpDetails,
|
||||
emailPasswordFormKey: emailVerificationFormKey,
|
||||
// registrationDetails: registraionDetails,
|
||||
proceedToNextStep: _proceedToNextStep,
|
||||
),
|
||||
StepGetRegistration(
|
||||
// updateSignUpDetails: updateSignUpDetails,
|
||||
bankAccountFormKey: signUpFormKey,
|
||||
registrationDetails: registraionDetails,
|
||||
showConfirmSignUpButton: showConfirmSignUpButton,
|
||||
finalStepProccessing: _finalStepProccessing,
|
||||
)
|
||||
];
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_signUpStepController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [0, 1, 2]
|
||||
.map((e) => Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => changeStepOnTap(e),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: stepHasError[e]
|
||||
? Colors.red.shade600
|
||||
: !stepCompletedSuccessfully[e]
|
||||
? const Color(0xffF5F7FA)
|
||||
: Colors.green.shade600,
|
||||
foregroundColor: !stepCompletedSuccessfully[e]
|
||||
? const Color(0xFF0070BA)
|
||||
: Colors.white,
|
||||
radius: 18,
|
||||
child: stepHasError[e]
|
||||
? const Icon(
|
||||
FluentIcons.warning_16_filled,
|
||||
color: Colors.white,
|
||||
)
|
||||
: stepCompletedSuccessfully[e]
|
||||
? const Icon(
|
||||
FluentIcons.checkmark_16_regular)
|
||||
: _currentStep == e
|
||||
? const Icon(
|
||||
FluentIcons.edit_16_filled)
|
||||
: Text("${e + 1}")),
|
||||
),
|
||||
if (e < 2)
|
||||
Container(
|
||||
height: 10,
|
||||
width: 70,
|
||||
color: stepCompletedSuccessfully[e]
|
||||
? Colors.green.shade600
|
||||
: Colors.transparent,
|
||||
),
|
||||
],
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: _currentStep == 2 ? 230 : 300,
|
||||
child: PageView(
|
||||
clipBehavior: Clip.none,
|
||||
controller: _signUpStepController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: signUpStepContent,
|
||||
),
|
||||
),
|
||||
if (_currentStep == 2)
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 3.6, horizontal: 10),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: 'By signing up you are agreeing to the ',
|
||||
style: const TextStyle(
|
||||
fontSize: 14, color: Color(0xFF929BAB)),
|
||||
children: <InlineSpan>[
|
||||
TextSpan(
|
||||
text: 'Terms & Conditions',
|
||||
style: const TextStyle(
|
||||
fontSize: 14, color: Colors.blue),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 300),
|
||||
() => Navigator.push(
|
||||
context,
|
||||
SlideRightRoute(
|
||||
page: const HadWinMarkdownViewer(
|
||||
screenName: "Terms & Conditons",
|
||||
urlRequested:
|
||||
'https://raw.githubusercontent.com/brownboycodes/HADWIN/master/docs/TERMS_AND_CONDITIONS.md',
|
||||
))));
|
||||
}),
|
||||
const TextSpan(
|
||||
text: ' and our ',
|
||||
style:
|
||||
TextStyle(fontSize: 14, color: Color(0xFF929BAB)),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'End User License Agreement',
|
||||
style: const TextStyle(
|
||||
fontSize: 14, color: Colors.blue),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 300),
|
||||
() => Navigator.push(
|
||||
context,
|
||||
SlideRightRoute(
|
||||
page: const HadWinMarkdownViewer(
|
||||
screenName:
|
||||
"End User License Agreement",
|
||||
urlRequested:
|
||||
'https://raw.githubusercontent.com/brownboycodes/HADWIN/master/docs/END_USER_LICENSE_AGREEMENT.md',
|
||||
))));
|
||||
})
|
||||
]))),
|
||||
confirmSignUpButton
|
||||
? Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
width: double.infinity,
|
||||
height: 64,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.blueGrey.shade100,
|
||||
offset: const Offset(0, 4),
|
||||
blurRadius: 5.0)
|
||||
],
|
||||
gradient: const RadialGradient(
|
||||
colors: [Color(0xff0070BA), Color(0xff1546A0)],
|
||||
radius: 8.4,
|
||||
center: Alignment(-0.24, -0.36)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: ElevatedButton(
|
||||
onPressed: _finalStepProccessing,
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
),
|
||||
child: const Text(
|
||||
'Create Your Account',
|
||||
style: TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.w600),
|
||||
)),
|
||||
)
|
||||
: Row(
|
||||
children: [
|
||||
if (_currentStep > 0 && confirmSignUpButton == false)
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: _goBackToPreviousStep,
|
||||
style: TextButton.styleFrom(
|
||||
primary: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
),
|
||||
child: const Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 3.2,
|
||||
children: [
|
||||
Icon(
|
||||
FluentIcons.arrow_left_16_filled,
|
||||
color: Colors.blue,
|
||||
size: 18,
|
||||
),
|
||||
Text(
|
||||
'Back',
|
||||
style: TextStyle(
|
||||
color: Colors.blue, fontSize: 16),
|
||||
),
|
||||
])),
|
||||
),
|
||||
const Spacer(),
|
||||
if (_currentStep < signUpStepContent.length - 1)
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: _proceedToNextStep,
|
||||
style: TextButton.styleFrom(
|
||||
primary: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
),
|
||||
child: const Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 3.2,
|
||||
children: [
|
||||
Text(
|
||||
'Next',
|
||||
style: TextStyle(
|
||||
color: Colors.blue, fontSize: 16),
|
||||
),
|
||||
Icon(
|
||||
FluentIcons.arrow_right_16_filled,
|
||||
color: Colors.blue,
|
||||
size: 18,
|
||||
)
|
||||
])),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
void _finalStepProccessing() {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
_performErrorCheck(_currentStep + 1);
|
||||
|
||||
if (stepHasError[_currentStep] == false && mounted) {
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Processing'),
|
||||
backgroundColor: Colors.blue,
|
||||
// onVisible: _tryRegistering,
|
||||
),
|
||||
)
|
||||
.closed
|
||||
.then((value) => _tryRegistering());
|
||||
}
|
||||
}
|
||||
|
||||
//? FUNCTION TO GO BACK TO PREVIOUS STEP OF THE CURRENT STEP
|
||||
void _goBackToPreviousStep() {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
_performErrorCheck(_currentStep - 1);
|
||||
if (_currentStep > 0) {
|
||||
_signUpStepController.animateToPage(_currentStep - 1,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOutCubic);
|
||||
setState(() {
|
||||
_currentStep--;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//? FUNCTION TO MOVE TO THE NEXT STEP FROM THE CURRENT STEP
|
||||
void _proceedToNextStep() {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
_performErrorCheck(_currentStep + 1);
|
||||
|
||||
print(stepHasError[_currentStep]);
|
||||
print(_currentStep);
|
||||
|
||||
if (stepHasError[_currentStep] == false) {
|
||||
if (_currentStep < signUpStepContent.length - 1) {
|
||||
_signUpStepController.animateToPage(_currentStep + 1,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOutCubic);
|
||||
|
||||
setState(() {
|
||||
_currentStep++;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//? FUNCTION TO UPDATE SIGN UP DETAILS
|
||||
// void updateSignUpDetails(String key, String value) {
|
||||
// setState(() {
|
||||
// signUpDetails[key] = value;
|
||||
// });
|
||||
// }
|
||||
|
||||
//? FUNCTION TO TOGGLE VISIBILITY OF SIGN UP BUTTON
|
||||
void showConfirmSignUpButton(bool value) {
|
||||
if (value != confirmSignUpButton) {
|
||||
setState(() {
|
||||
confirmSignUpButton = value;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//? FUNCTION TO CHECK FOR ERRORS IN ANY STEPS PRIOR FROM THE ONE REQUESTED
|
||||
void _performErrorCheck(int requestedIndex) {
|
||||
if (_currentStep < requestedIndex) {
|
||||
for (var i = 0; i < requestedIndex; i++) {
|
||||
bool errorStatus = false;
|
||||
switch (i) {
|
||||
case 0:
|
||||
createAccountFormKey.currentState?.validate();
|
||||
if (accountDetails["companyName"]!.isEmpty ||
|
||||
accountDetails['email']!.isEmpty ||
|
||||
accountDetails['mobile']!.isEmpty ||
|
||||
accountDetails['workspace']!.isEmpty ||
|
||||
accountDetails['gstNumber']!.isEmpty ||
|
||||
accountDetails['pancard']!.isEmpty ||
|
||||
accountDetails['working']!.isEmpty) {
|
||||
errorStatus = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
emailVerificationFormKey.currentState?.validate();
|
||||
if (stepCompletedSuccessfully[1]) {
|
||||
errorStatus = false;
|
||||
} else if (stepCompletedSuccessfully[0] && _currentStep == 1) {
|
||||
// emailPasswordFormKey.currentState?.validate();
|
||||
if (email!.isEmpty) {
|
||||
errorStatus = true;
|
||||
}
|
||||
} else {
|
||||
errorStatus = true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
signUpFormKey.currentState?.validate();
|
||||
if (email!.isEmpty) {
|
||||
errorStatus = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
stepHasError[i] = errorStatus;
|
||||
stepCompletedSuccessfully[i] = !stepHasError[i];
|
||||
});
|
||||
if (errorStatus) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var i = _currentStep; i >= 0; i--) {
|
||||
bool errorStatus = false;
|
||||
switch (i) {
|
||||
case 0:
|
||||
createAccountFormKey.currentState?.validate();
|
||||
if (accountDetails["companyName"]!.isEmpty ||
|
||||
accountDetails['email']!.isEmpty ||
|
||||
accountDetails['mobile']!.isEmpty ||
|
||||
accountDetails['workspace']!.isEmpty ||
|
||||
accountDetails['gstNumber']!.isEmpty ||
|
||||
accountDetails['pancard']!.isEmpty ||
|
||||
accountDetails['working']!.isEmpty) {
|
||||
errorStatus = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
emailVerificationFormKey.currentState?.validate();
|
||||
if (stepCompletedSuccessfully[1]) {
|
||||
errorStatus = false;
|
||||
} else if (stepCompletedSuccessfully[0] && _currentStep == 1) {
|
||||
// emailPasswordFormKey.currentState?.validate();
|
||||
if (email!.isEmpty) {
|
||||
errorStatus = true;
|
||||
}
|
||||
} else {
|
||||
errorStatus = true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
signUpFormKey.currentState?.validate();
|
||||
if (registrationDetails["first_name"]!.isEmpty ||
|
||||
registrationDetails["last_name"]!.isEmpty ||
|
||||
registrationDetails["mob_no"]!.isEmpty ||
|
||||
registrationDetails["new_password"]!.isEmpty ||
|
||||
registrationDetails["confirm_password"]!.isEmpty) {
|
||||
errorStatus = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
stepHasError[i] = errorStatus;
|
||||
stepCompletedSuccessfully[i] = !stepHasError[i];
|
||||
});
|
||||
if (errorStatus) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _tryRegistering() {
|
||||
sendData(urlPath: '/token/addOneAppUser', data: registrationDetails)
|
||||
.then((response) {
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
|
||||
if (response.keys.join().toLowerCase().contains("error")) {
|
||||
showErrorAlert(context, response);
|
||||
} else {
|
||||
print('Account succesfully created');
|
||||
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(const SnackBar(
|
||||
content: Text("Account Created Successfully"),
|
||||
backgroundColor: Colors.green))
|
||||
.closed
|
||||
.then((value) => Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(builder: (context) => const LoginScreen()),
|
||||
(route) => false));
|
||||
// Navigator.of(context).pushAndRemoveUntil(
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => ChooseUsername(
|
||||
// userAuthKey: response['authorization_token'],
|
||||
// userData: response['user'],
|
||||
// )),
|
||||
// (route) => false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//? FUNCTION TO CHANGE STEP ON TAPPING THE OVERHEAD STEP NUMBERS
|
||||
void changeStepOnTap(int requestedIndex) {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
|
||||
if (requestedIndex < _currentStep) {
|
||||
_signUpStepController.animateToPage(requestedIndex,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOutCubic);
|
||||
|
||||
_performErrorCheck(requestedIndex);
|
||||
setState(() {
|
||||
_currentStep = requestedIndex;
|
||||
});
|
||||
} else if (requestedIndex > _currentStep &&
|
||||
requestedIndex != _currentStep) {
|
||||
_performErrorCheck(requestedIndex);
|
||||
|
||||
if (!stepHasError.sublist(0, requestedIndex).contains(true)) {
|
||||
if (_currentStep < signUpStepContent.length - 1) {
|
||||
_signUpStepController.animateToPage(requestedIndex,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOutCubic);
|
||||
|
||||
setState(() {
|
||||
_currentStep = requestedIndex;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
int stepWithError =
|
||||
stepHasError.sublist(0, requestedIndex).indexOf(true);
|
||||
_signUpStepController.animateToPage(stepWithError,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOutCubic);
|
||||
|
||||
setState(() {
|
||||
_currentStep = stepWithError;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StepCreateAccount extends StatefulWidget {
|
||||
final LabeledGlobalKey<FormState> nameAddressFormKey;
|
||||
// final Function updateSignUpDetails;
|
||||
|
||||
final Function registrationDetails;
|
||||
final Function proceedToNextStep;
|
||||
const StepCreateAccount(
|
||||
{Key? key,
|
||||
// required this.updateSignUpDetails,
|
||||
required this.nameAddressFormKey,
|
||||
required this.registrationDetails,
|
||||
required this.proceedToNextStep})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_StepCreateAccountState createState() => _StepCreateAccountState();
|
||||
}
|
||||
|
||||
class _StepCreateAccountState extends State<StepCreateAccount> {
|
||||
String companyName = "";
|
||||
String companyNameErrorMessage = "";
|
||||
String email = "";
|
||||
String emailErrorMessage = "";
|
||||
RegExp validEmailFormat = RegExp(
|
||||
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+");
|
||||
|
||||
String mobNo = "";
|
||||
String mobNoErrorMessage = "";
|
||||
|
||||
String workspace = "";
|
||||
String workspaceErrorMessage = "";
|
||||
|
||||
String gstNumber = "";
|
||||
String gstNumberErrorMessage = "";
|
||||
|
||||
String pancard = "";
|
||||
String pancardErrorMessage = "";
|
||||
|
||||
String working = "";
|
||||
String workingErrorMessage = "";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Map<String, String> signUpDetails = widget.registrationDetails();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
companyName = signUpDetails['companyName'].toString();
|
||||
email = signUpDetails['email'].toString();
|
||||
mobNo = signUpDetails['mobile'].toString();
|
||||
workspace = signUpDetails['workspace'].toString();
|
||||
gstNumber = signUpDetails['gstNumber'].toString();
|
||||
pancard = signUpDetails['pancard'].toString();
|
||||
working = signUpDetails['working'].toString();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// widget.nameAddressFormKey.currentState?.validate();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Form(
|
||||
key: widget.nameAddressFormKey,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
// initialValue: companyName,
|
||||
validator: _validatecompanyName,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "Company_Name",
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style:
|
||||
const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
),
|
||||
if (companyNameErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"\t\t\t\t$companyNameErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
// COMPANY NAME CODE END HERE
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
// initialValue: email,
|
||||
// validator: _validatelastName,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "email",
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style:
|
||||
const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
),
|
||||
if (emailErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"\t\t\t\t$emailErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
|
||||
// input field for email name ends here
|
||||
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
// initialValue: mobNo,
|
||||
// validator: _validatemobno,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "mob_no",
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style:
|
||||
const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) => widget.proceedToNextStep(),
|
||||
),
|
||||
),
|
||||
if (mobNoErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"\t\t\t\t$mobNoErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
// input field for Mob No ends here
|
||||
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
// initialValue: workspace,
|
||||
// validator: _validatelastName,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "workspace",
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style:
|
||||
const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
),
|
||||
if (workspaceErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"\t\t\t\t$workspaceErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
// workspace code end
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
// initialValue: gstNumber,
|
||||
// validator: _validatelastName,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "gst number",
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style:
|
||||
const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
),
|
||||
if (gstNumberErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"\t\t\t\t$gstNumberErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
// gst number code end here
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
// initialValue: pancard,
|
||||
// validator: _validatelastName,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "pancard",
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style:
|
||||
const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
),
|
||||
if (pancardErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"\t\t\t\t$pancardErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
// pancard end here
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
width: 1.0, color: const Color(0xFFF5F7FA)),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
const BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: Offset(-4, -4),
|
||||
color: Colors.white38),
|
||||
BoxShadow(
|
||||
blurRadius: 6.18,
|
||||
spreadRadius: 0.618,
|
||||
offset: const Offset(4, 4),
|
||||
color: Colors.blueGrey.shade100)
|
||||
]),
|
||||
child: TextFormField(
|
||||
// initialValue: working,
|
||||
// validator: _validatelastName,
|
||||
autofocus: mounted,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 15, bottom: 11, top: 11, right: 15),
|
||||
hintText: "working",
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
),
|
||||
style:
|
||||
const TextStyle(fontSize: 16, color: Color(0xFF929BAB)),
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
),
|
||||
if (workingErrorMessage != '')
|
||||
Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
padding: const EdgeInsets.all(2),
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
"\t\t\t\t$workingErrorMessage",
|
||||
style: const TextStyle(fontSize: 10, color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void errorMessageSetter(String fieldName, String message) {
|
||||
setState(() {
|
||||
switch (fieldName) {
|
||||
case 'COMPANY_NAME':
|
||||
companyNameErrorMessage = message;
|
||||
break;
|
||||
|
||||
// case 'LAST-NAME':
|
||||
// last_nameErrorMessage = message;
|
||||
// break;
|
||||
|
||||
// case 'MOB-NO':
|
||||
// mob_noErrorMessage = message;
|
||||
// break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String? _validatecompanyName(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
errorMessageSetter('COMPANY_NAME', 'you must provide your Company name');
|
||||
} else if (value.length > 100) {
|
||||
errorMessageSetter(
|
||||
'COMPANY_NAME', 'name cannot contain more than 100 characters');
|
||||
} else {
|
||||
errorMessageSetter('COMPANY_NAME', "");
|
||||
|
||||
// widget.updateSignUpDetails('first_name', value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// String? _validatelastName(String? value) {
|
||||
// if (value == null || value.isEmpty) {
|
||||
// errorMessageSetter('LAST-NAME', 'you must provide your last name');
|
||||
// } else if (value.length > 100) {
|
||||
// errorMessageSetter(
|
||||
// 'LAST-NAME', 'name cannot contain more than 100 characters');
|
||||
// } else {
|
||||
// errorMessageSetter('LAST-NAME', "");
|
||||
|
||||
// widget.updateSignUpDetails('last_name', value);
|
||||
// }
|
||||
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// String? _validatemobno(String? value) {
|
||||
// if (value == null || value.isEmpty) {
|
||||
// errorMessageSetter('MOB-NO', 'you must provide your MOB-NO');
|
||||
// } else if (value.length > 100) {
|
||||
// errorMessageSetter(
|
||||
// 'MOB-NO', 'name cannot contain more than 100 characters');
|
||||
// } else {
|
||||
// errorMessageSetter('MOB-NO', "");
|
||||
|
||||
// widget.updateSignUpDetails('mob_no', value);
|
||||
// }
|
||||
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// String? _validateAddress(String? value) {
|
||||
// if (value == null || value.isEmpty) {
|
||||
// errorMessageSetter(
|
||||
// 'RESIDENTIAL-ADDRESS', 'you must provide your residential address');
|
||||
// } else if (value.length > 300) {
|
||||
// errorMessageSetter('RESIDENTIAL-ADDRESS',
|
||||
// 'address cannot contain more than 300 characters');
|
||||
// } else {
|
||||
// errorMessageSetter('RESIDENTIAL-ADDRESS', "");
|
||||
|
||||
// widget.updateSignUpDetails('address', value);
|
||||
// }
|
||||
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user