Code changes by azmat

This commit is contained in:
risnaman
2026-09-30 09:13:45 +05:30
parent c95a3f1581
commit 63ecc3e7e6
316 changed files with 28050 additions and 27216 deletions
+263 -263
View File
@@ -1,263 +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();
},
),
],
);
},
);
}
}
}
},
),
),
],
),
),
),
),
);
}
}
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();
},
),
],
);
},
);
}
}
}
},
),
),
],
),
),
),
),
);
}
}
+328 -328
View File
@@ -1,328 +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'),
),
],
);
}
}
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'),
),
],
);
}
}
@@ -1,387 +1,387 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.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_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>();
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
bool _isSubmitting = false;
late final FocusNode _firstNameNode;
late final FocusNode _lastNameNode;
late final FocusNode _mobileNode;
late final FocusNode _newPasswordNode;
late final FocusNode _confirmPasswordNode;
// 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) {
final valid = password.isNotEmpty;
if (valid != _isPasswordValid) {
setState(() {
_isPasswordValid = valid;
});
}
}
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();
_firstNameNode = FocusNode();
_lastNameNode = FocusNode();
_mobileNode = FocusNode();
_newPasswordNode = FocusNode();
_confirmPasswordNode = FocusNode();
}
@override
void dispose() {
_firstNameNode.dispose();
_lastNameNode.dispose();
_mobileNode.dispose();
_newPasswordNode.dispose();
_confirmPasswordNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext 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: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: getPadding(top: 19),
child: Text("First Name",
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style:
AppStyle.txtGilroyMedium16Bluegray900)),
CustomTextFormField(
focusNode: _firstNameNode,
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: _lastNameNode,
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: _mobileNode,
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: _newPasswordNode,
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) {
newPassword = value;
_validatePassword(value);
},
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: _confirmPasswordNode,
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(value);
},
onsaved: (value) => formData['confirm_password'] = value,
onChanged: (value) {
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)
const Padding(
padding: EdgeInsets.only(top: 8),
child: Text(
'Tap + to create an account first, then SUBMIT will be enabled.',
style: TextStyle(fontSize: 12, color: Colors.grey),
),
),
Container(
margin:
const EdgeInsets.symmetric(vertical: 5), // Add margin
child: CustomButton(
height: getVerticalSize(50),
width: getHorizontalSize(396),
text: _isSubmitting ? "PLEASE WAIT..." : "SUBMIT",
margin: getMargin(top: 25),
onTap: (account_id == null || _isSubmitting)
? null
: () async {
final isValid =
_formKey.currentState!.validate();
if (!isValid) {
showErrorMessage(
'Please fix the red errors (check passwords match).');
return;
}
_formKey.currentState!.save();
print('formdata is $formData');
formData['usrGrpId'] = 41;
formData['account_id'] = account_id;
formData['email'] = widget.email;
setState(() => _isSubmitting = true);
try {
print(formData);
await userService.createuser(formData);
if (!context.mounted) return;
showSuccessMessage(
'User created successfully');
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) =>
const LoginScreen()),
(route) => false);
} catch (e) {
if (!context.mounted) return;
showErrorMessage(
'Failed to create User: $e');
} finally {
if (mounted) {
setState(() => _isSubmitting = false);
}
}
},
),
),
],
),
),
),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter/services.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_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>();
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
bool _isSubmitting = false;
late final FocusNode _firstNameNode;
late final FocusNode _lastNameNode;
late final FocusNode _mobileNode;
late final FocusNode _newPasswordNode;
late final FocusNode _confirmPasswordNode;
// 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) {
final valid = password.isNotEmpty;
if (valid != _isPasswordValid) {
setState(() {
_isPasswordValid = valid;
});
}
}
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();
_firstNameNode = FocusNode();
_lastNameNode = FocusNode();
_mobileNode = FocusNode();
_newPasswordNode = FocusNode();
_confirmPasswordNode = FocusNode();
}
@override
void dispose() {
_firstNameNode.dispose();
_lastNameNode.dispose();
_mobileNode.dispose();
_newPasswordNode.dispose();
_confirmPasswordNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext 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: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: getPadding(top: 19),
child: Text("First Name",
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style:
AppStyle.txtGilroyMedium16Bluegray900)),
CustomTextFormField(
focusNode: _firstNameNode,
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: _lastNameNode,
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: _mobileNode,
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: _newPasswordNode,
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) {
newPassword = value;
_validatePassword(value);
},
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: _confirmPasswordNode,
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(value);
},
onsaved: (value) => formData['confirm_password'] = value,
onChanged: (value) {
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)
const Padding(
padding: EdgeInsets.only(top: 8),
child: Text(
'Tap + to create an account first, then SUBMIT will be enabled.',
style: TextStyle(fontSize: 12, color: Colors.grey),
),
),
Container(
margin:
const EdgeInsets.symmetric(vertical: 5), // Add margin
child: CustomButton(
height: getVerticalSize(50),
width: getHorizontalSize(396),
text: _isSubmitting ? "PLEASE WAIT..." : "SUBMIT",
margin: getMargin(top: 25),
onTap: (account_id == null || _isSubmitting)
? null
: () async {
final isValid =
_formKey.currentState!.validate();
if (!isValid) {
showErrorMessage(
'Please fix the red errors (check passwords match).');
return;
}
_formKey.currentState!.save();
print('formdata is $formData');
formData['usrGrpId'] = 41;
formData['account_id'] = account_id;
formData['email'] = widget.email;
setState(() => _isSubmitting = true);
try {
print(formData);
await userService.createuser(formData);
if (!context.mounted) return;
showSuccessMessage(
'User created successfully');
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) =>
const LoginScreen()),
(route) => false);
} catch (e) {
if (!context.mounted) return;
showErrorMessage(
'Failed to create User: $e');
} finally {
if (mounted) {
setState(() => _isSubmitting = false);
}
}
},
),
),
],
),
),
),
),
);
}
}
+111 -111
View File
@@ -1,111 +1,111 @@
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(Map<String, dynamic> entity) async {
try {
print("in post api...$entity");
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');
}
}
}
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(Map<String, dynamic> entity) async {
try {
print("in post api...$entity");
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');
}
}
}
+295 -295
View File
@@ -1,295 +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
// }
// },
// ),
// ),
// ),
// ),
// );
// },
// ),
// );
// }
// }
// 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
// }
// },
// ),
// ),
// ),
// ),
// );
// },
// ),
// );
// }
// }
@@ -1,138 +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;
// }
}
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;
// }
}
@@ -1,393 +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);
}
}
}
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);
}
}
}
+60 -60
View File
@@ -1,60 +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));
}
}
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));
}
}
+398 -398
View File
@@ -1,398 +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'] = 41;
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();
}
},
),
),
),
),
);
},
),
);
}
}
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'] = 41;
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();
}
},
),
),
),
),
);
},
),
);
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff