2026-04-11
This commit is contained in:
commit
27e27fb70b
270 files changed
+30296
No files matched your search
@@ -0,0 +1,287 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:taxglide/consts/app_asstes.dart';
|
||||
import 'package:taxglide/consts/app_colors.dart';
|
||||
import 'package:taxglide/consts/comman_button.dart';
|
||||
import 'package:taxglide/consts/comman_container_auth.dart';
|
||||
import 'package:taxglide/consts/comman_textformfileds.dart';
|
||||
import 'package:taxglide/consts/responsive_helper.dart';
|
||||
import 'package:taxglide/consts/validation_popup.dart';
|
||||
import 'package:taxglide/controller/api_contoller.dart';
|
||||
import 'package:taxglide/router/consts_routers.dart';
|
||||
|
||||
class EmployeeLoginScreen extends ConsumerStatefulWidget {
|
||||
const EmployeeLoginScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<EmployeeLoginScreen> createState() =>
|
||||
_EmployeeLoginScreenState();
|
||||
}
|
||||
|
||||
class _EmployeeLoginScreenState extends ConsumerState<EmployeeLoginScreen> {
|
||||
final ValidationPopup _validationPopup = ValidationPopup();
|
||||
final TextEditingController _mobileController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final args = Get.arguments;
|
||||
if (args != null && args is Map<String, dynamic>) {
|
||||
final mobile = args['mobile'] ?? '';
|
||||
if (mobile.isNotEmpty) {
|
||||
_mobileController.text = mobile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_mobileController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _handleLogin() async {
|
||||
final mobile = _mobileController.text.trim();
|
||||
|
||||
if (!_validationPopup.validateMobileNumber(context, mobile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
await ref.read(employeeloginProvider.notifier).login(mobile);
|
||||
final state = ref.read(employeeloginProvider);
|
||||
|
||||
state.when(
|
||||
data: (data) {
|
||||
if (data['success'] == true) {
|
||||
Get.toNamed(ConstRouters.employeeotp, arguments: {'mobile': mobile});
|
||||
_validationPopup.showSuccessMessage(
|
||||
context,
|
||||
"OTP sent successfully!",
|
||||
);
|
||||
} else if (data['error'] != null) {
|
||||
_validationPopup.showErrorMessage(context, data['error'].toString());
|
||||
}
|
||||
},
|
||||
loading: () {},
|
||||
error: (err, _) {
|
||||
_validationPopup.showErrorMessage(context, "Error: $err");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loginState = ref.watch(employeeloginProvider);
|
||||
|
||||
// Initialize responsive utils
|
||||
final r = ResponsiveUtils(context);
|
||||
|
||||
// Responsive values
|
||||
final logoWidth = r.getValue<double>(
|
||||
mobile: 120,
|
||||
tablet: 141,
|
||||
desktop: 160,
|
||||
);
|
||||
final logoHeight = r.getValue<double>(
|
||||
mobile: 85,
|
||||
tablet: 100,
|
||||
desktop: 115,
|
||||
);
|
||||
final titleFontSize = r.fontSize(mobile: 26, tablet: 32, desktop: 36);
|
||||
final subtitleFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
|
||||
final termsFontSize = r.fontSize(mobile: 10.5, tablet: 11.34, desktop: 12);
|
||||
final linkFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
|
||||
final otherLoginFontSize = r.fontSize(mobile: 12, tablet: 13, desktop: 14);
|
||||
|
||||
final spacingXS = r.spacing(mobile: 10, tablet: 10, desktop: 12);
|
||||
final spacingSM = r.spacing(mobile: 15, tablet: 20, desktop: 24);
|
||||
final spacingMD = r.spacing(mobile: 20, tablet: 20, desktop: 24);
|
||||
final spacingLG = r.spacing(mobile: 20, tablet: 22, desktop: 28);
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Color(0xFFFFF8F0),
|
||||
Color(0xFFEBC894),
|
||||
Color(0xFFE8DAF2),
|
||||
Color(0xFFB49EF4),
|
||||
],
|
||||
stops: [0.0, 0.3, 0.6, 1.0],
|
||||
),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: r.screenHeight),
|
||||
child: IntrinsicHeight(
|
||||
child: Center(
|
||||
child: CommonContainerAuth(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Logo
|
||||
Image.asset(
|
||||
AppAssets.taxgildelogoauth,
|
||||
width: logoWidth,
|
||||
height: logoHeight,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
SizedBox(height: spacingMD),
|
||||
|
||||
// Login Title
|
||||
Text(
|
||||
"Login",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: titleFontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.3,
|
||||
letterSpacing: 0.01 * titleFontSize,
|
||||
color: AppColors.authheading,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingMD),
|
||||
|
||||
// Subtitle
|
||||
Text(
|
||||
"Enter your registered Mobile Number",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: subtitleFontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.03 * subtitleFontSize,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// Mobile Number Input
|
||||
CommanTextFormField(
|
||||
controller: _mobileController,
|
||||
hintText: 'Enter your Mobile Number',
|
||||
keyboardType: TextInputType.phone,
|
||||
prefixIcon: Icons.phone_android,
|
||||
),
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// Terms and Conditions
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: "By signing up, you agree to the ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: termsFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.01,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "Terms of Service ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: termsFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.01,
|
||||
color: AppColors.authtermsandcondition,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: "and ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: termsFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.01,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: "Data Processing Agreement",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: termsFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.01,
|
||||
color: AppColors.authtermsandcondition,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// Login Button or Loading
|
||||
loginState.isLoading
|
||||
? const CircularProgressIndicator()
|
||||
: CommanButton(
|
||||
text: "Login",
|
||||
onPressed: _handleLogin,
|
||||
),
|
||||
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
Text(
|
||||
"Other Login",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: otherLoginFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.13,
|
||||
color: const Color(0xFF6C7278),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: spacingXS),
|
||||
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: "User Login? ",
|
||||
style: TextStyle(fontSize: linkFontSize),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "Click Here",
|
||||
style: TextStyle(
|
||||
fontSize: linkFontSize,
|
||||
color: AppColors.authsignup,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Get.offNamed(ConstRouters.login);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:taxglide/consts/app_asstes.dart';
|
||||
import 'package:taxglide/consts/app_colors.dart';
|
||||
import 'package:taxglide/consts/comman_button.dart';
|
||||
import 'package:taxglide/consts/comman_container_auth.dart';
|
||||
import 'package:taxglide/consts/responsive_helper.dart';
|
||||
import 'package:taxglide/consts/validation_popup.dart';
|
||||
import 'package:taxglide/controller/api_contoller.dart';
|
||||
|
||||
import 'package:taxglide/view/Main_controller/main_controller.dart';
|
||||
import '../router/consts_routers.dart';
|
||||
|
||||
class EmployeeOtpScreen extends ConsumerStatefulWidget {
|
||||
const EmployeeOtpScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<EmployeeOtpScreen> createState() => _EmployeeOtpScreenState();
|
||||
}
|
||||
|
||||
class _EmployeeOtpScreenState extends ConsumerState<EmployeeOtpScreen> {
|
||||
final ValidationPopup _validationPopup = ValidationPopup();
|
||||
final int otpLength = 4;
|
||||
final List<TextEditingController> _controllers = [];
|
||||
final List<FocusNode> _focusNodes = [];
|
||||
String otpValue = '';
|
||||
|
||||
Timer? _timer;
|
||||
int _remainingSeconds = 600;
|
||||
bool _canResend = false;
|
||||
|
||||
late String mobile;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final args = Get.arguments as Map<String, dynamic>?;
|
||||
mobile = args?['mobile'] ?? '';
|
||||
|
||||
for (int i = 0; i < otpLength; i++) {
|
||||
_controllers.add(TextEditingController());
|
||||
_focusNodes.add(FocusNode());
|
||||
}
|
||||
_startTimer();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
for (var c in _controllers) c.dispose();
|
||||
for (var f in _focusNodes) f.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _startTimer() {
|
||||
_canResend = false;
|
||||
_remainingSeconds = 30;
|
||||
_timer?.cancel();
|
||||
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
if (_remainingSeconds > 0) {
|
||||
setState(() => _remainingSeconds--);
|
||||
} else {
|
||||
setState(() => _canResend = true);
|
||||
timer.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String _formatTime(int seconds) {
|
||||
int minutes = seconds ~/ 60;
|
||||
int remainingSeconds = seconds % 60;
|
||||
return '${minutes.toString().padLeft(2, '0')}:${remainingSeconds.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
Future<void> _resendOtp() async {
|
||||
if (!_canResend) return;
|
||||
|
||||
for (var controller in _controllers) controller.clear();
|
||||
setState(() => otpValue = '');
|
||||
_focusNodes[0].requestFocus();
|
||||
|
||||
try {
|
||||
await ref.read(employeeloginProvider.notifier).login(mobile);
|
||||
final loginState = ref.read(employeeloginProvider);
|
||||
loginState.when(
|
||||
data: (result) {
|
||||
if (result['success'] == true) {
|
||||
_validationPopup.showSuccessMessage(
|
||||
context,
|
||||
"OTP has been resent successfully!",
|
||||
);
|
||||
_startTimer();
|
||||
} else {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
result['error'] ?? "Failed to resend OTP",
|
||||
);
|
||||
}
|
||||
},
|
||||
loading: () {},
|
||||
error: (error, _) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Failed to resend OTP. Please try again.",
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"An error occurred. Please try again.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _verifyOtp() async {
|
||||
if (otpValue.length != otpLength) {
|
||||
_validationPopup.showErrorMessage(context, "Please enter all OTP digits");
|
||||
return;
|
||||
}
|
||||
|
||||
await ref.read(employeeloginProvider.notifier).verifyOtp(mobile, otpValue);
|
||||
final loginState = ref.read(employeeloginProvider);
|
||||
|
||||
loginState.when(
|
||||
data: (result) {
|
||||
if (result['success'] == true) {
|
||||
_validationPopup.showSuccessMessage(
|
||||
context,
|
||||
"OTP Verified Successfully!",
|
||||
);
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
Get.offAll(() => const MainController());
|
||||
});
|
||||
} else {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
result['error'] ?? "Invalid OTP. Please try again.",
|
||||
);
|
||||
}
|
||||
},
|
||||
loading: () {},
|
||||
error: (error, _) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Failed to verify OTP. Please try again.",
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _onOtpChange(int index, String value) {
|
||||
if (value.isNotEmpty && index < otpLength - 1) {
|
||||
_focusNodes[index + 1].requestFocus();
|
||||
} else if (value.isEmpty && index > 0) {
|
||||
_focusNodes[index - 1].requestFocus();
|
||||
}
|
||||
setState(() {
|
||||
otpValue = _controllers.map((c) => c.text).join();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loginState = ref.watch(employeeloginProvider);
|
||||
final isLoading = loginState.isLoading;
|
||||
|
||||
// Initialize responsive utils
|
||||
final r = ResponsiveUtils(context);
|
||||
|
||||
// Responsive values
|
||||
final logoWidth = r.getValue<double>(
|
||||
mobile: 120,
|
||||
tablet: 141,
|
||||
desktop: 160,
|
||||
);
|
||||
final logoHeight = r.getValue<double>(
|
||||
mobile: 85,
|
||||
tablet: 100,
|
||||
desktop: 115,
|
||||
);
|
||||
final titleFontSize = r.fontSize(mobile: 26, tablet: 32, desktop: 36);
|
||||
final subtitleFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
|
||||
final mobileFontSize = r.fontSize(mobile: 12, tablet: 13, desktop: 14);
|
||||
final resendFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
|
||||
final timerFontSize = r.fontSize(mobile: 14, tablet: 16, desktop: 18);
|
||||
|
||||
final otpBoxWidth = r.getValue<double>(mobile: 52, tablet: 60, desktop: 68);
|
||||
final otpBoxHeight = r.getValue<double>(
|
||||
mobile: 48,
|
||||
tablet: 56,
|
||||
desktop: 64,
|
||||
);
|
||||
final otpFontSize = r.fontSize(mobile: 22, tablet: 28, desktop: 32);
|
||||
final otpBoxMargin = r.getValue<double>(mobile: 5, tablet: 6, desktop: 8);
|
||||
final otpBoxRadius = r.getValue<double>(mobile: 5, tablet: 6, desktop: 8);
|
||||
|
||||
final spacingXS = r.spacing(mobile: 10, tablet: 10, desktop: 12);
|
||||
final spacingSM = r.spacing(mobile: 20, tablet: 20, desktop: 24);
|
||||
final spacingMD = r.spacing(mobile: 22, tablet: 22, desktop: 26);
|
||||
final spacingLG = r.spacing(mobile: 30, tablet: 30, desktop: 36);
|
||||
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
// Gradient background
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Color(0xFFFFF8F0),
|
||||
Color(0xFFEBC894),
|
||||
Color(0xFFE8DAF2),
|
||||
Color(0xFFB49EF4),
|
||||
],
|
||||
stops: [0.0, 0.3, 0.6, 1.0],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Scrollable content
|
||||
SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
height: r.screenHeight,
|
||||
child: Center(
|
||||
child: CommonContainerAuth(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Logo
|
||||
Image.asset(
|
||||
AppAssets.taxgildelogoauth,
|
||||
width: logoWidth,
|
||||
height: logoHeight,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
// Title
|
||||
Text(
|
||||
"Enter OTP",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: titleFontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.3,
|
||||
letterSpacing: 0.01 * titleFontSize,
|
||||
color: AppColors.authheading,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
// Subtitle
|
||||
Text(
|
||||
"OTP has been sent to your registered mobile number",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: subtitleFontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.03 * subtitleFontSize,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingMD),
|
||||
|
||||
// Mobile + Change Number
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: mobile,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: mobileFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.01,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: " ( Change Number )",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-ExtraBold',
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: mobileFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.04,
|
||||
color: AppColors.authchange,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Get.offNamed(
|
||||
ConstRouters.employeelogin,
|
||||
arguments: {'mobile': mobile},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// OTP Input Fields
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(otpLength, (index) {
|
||||
bool isFilled = _controllers[index].text.isNotEmpty;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
horizontal: otpBoxMargin,
|
||||
),
|
||||
width: otpBoxWidth,
|
||||
height: otpBoxHeight,
|
||||
decoration: BoxDecoration(
|
||||
color: isFilled
|
||||
? AppColors.commanbutton
|
||||
: Colors.white,
|
||||
borderRadius: BorderRadius.circular(otpBoxRadius),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFDFDFDF),
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(
|
||||
0xFFBDBDBD,
|
||||
).withOpacity(0.25),
|
||||
blurRadius: 7,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: TextField(
|
||||
controller: _controllers[index],
|
||||
focusNode: _focusNodes[index],
|
||||
textAlign: TextAlign.center,
|
||||
keyboardType: TextInputType.number,
|
||||
maxLength: 1,
|
||||
enabled: !isLoading,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: otpFontSize,
|
||||
letterSpacing: 0.03 * otpFontSize,
|
||||
color: isFilled ? Colors.white : Colors.black,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
counterText: '',
|
||||
border: InputBorder.none,
|
||||
),
|
||||
onChanged: (value) =>
|
||||
_onOtpChange(index, value),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
SizedBox(height: spacingXS),
|
||||
|
||||
// Resend OTP
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
onTap: _canResend && !isLoading ? _resendOtp : null,
|
||||
child: Text(
|
||||
"Resend",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: resendFontSize,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.02 * resendFontSize,
|
||||
color: _canResend && !isLoading
|
||||
? AppColors.authchange
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
// Timer
|
||||
Text(
|
||||
_formatTime(_remainingSeconds),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: timerFontSize,
|
||||
color: _remainingSeconds > 0
|
||||
? AppColors.authheading
|
||||
: Colors.red,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// Verify Button
|
||||
isLoading
|
||||
? const CircularProgressIndicator()
|
||||
: CommanButton(text: "Verify", onPressed: _verifyOtp),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:taxglide/consts/app_asstes.dart';
|
||||
import 'package:taxglide/consts/app_colors.dart';
|
||||
import 'package:taxglide/consts/comman_button.dart';
|
||||
import 'package:taxglide/consts/comman_container_auth.dart';
|
||||
import 'package:taxglide/consts/comman_textformfileds.dart';
|
||||
import 'package:taxglide/consts/comman_popup.dart';
|
||||
import 'package:taxglide/consts/responsive_helper.dart';
|
||||
import 'package:taxglide/consts/validation_popup.dart';
|
||||
import 'package:taxglide/controller/api_contoller.dart';
|
||||
import 'package:taxglide/router/consts_routers.dart';
|
||||
|
||||
class LoginScreen extends ConsumerStatefulWidget {
|
||||
const LoginScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<LoginScreen> createState() => _LoginScreenState();
|
||||
}
|
||||
|
||||
class _LoginScreenState extends ConsumerState<LoginScreen> {
|
||||
final TextEditingController _mobileController = TextEditingController();
|
||||
final ValidationPopup _validationPopup = ValidationPopup();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final args = Get.arguments;
|
||||
if (args != null && args is Map<String, dynamic>) {
|
||||
final mobile = args['mobile'] ?? '';
|
||||
if (mobile.isNotEmpty) {
|
||||
_mobileController.text = mobile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_mobileController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _handleLogin() async {
|
||||
final mobile = _mobileController.text.trim();
|
||||
|
||||
if (!_validationPopup.validateMobileNumber(context, mobile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
await ref.read(loginProvider.notifier).login(mobile);
|
||||
final state = ref.read(loginProvider);
|
||||
|
||||
state.when(
|
||||
data: (data) {
|
||||
if (data['success'] == true) {
|
||||
Get.toNamed(ConstRouters.otp, arguments: {'mobile': mobile});
|
||||
_validationPopup.showSuccessMessage(
|
||||
context,
|
||||
"OTP sent successfully!",
|
||||
);
|
||||
} else if (data['error'] != null) {
|
||||
_validationPopup.showErrorMessage(context, data['error'].toString());
|
||||
}
|
||||
},
|
||||
loading: () {},
|
||||
error: (err, _) {
|
||||
_validationPopup.showErrorMessage(context, "Error: $err");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loginState = ref.watch(loginProvider);
|
||||
final policyAsync = ref.watch(policyProvider);
|
||||
final termsAsync = ref.watch(termsProvider);
|
||||
|
||||
// Initialize responsive utils
|
||||
final r = ResponsiveUtils(context);
|
||||
|
||||
// Responsive values
|
||||
final logoWidth = r.getValue<double>(
|
||||
mobile: 120,
|
||||
tablet: 141,
|
||||
desktop: 160,
|
||||
);
|
||||
final logoHeight = r.getValue<double>(
|
||||
mobile: 85,
|
||||
tablet: 100,
|
||||
desktop: 115,
|
||||
);
|
||||
final titleFontSize = r.fontSize(mobile: 26, tablet: 32, desktop: 36);
|
||||
final subtitleFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
|
||||
final termsFontSize = r.fontSize(mobile: 10.5, tablet: 11.34, desktop: 12);
|
||||
final signupFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
|
||||
final otherLoginFontSize = r.fontSize(mobile: 12, tablet: 13, desktop: 14);
|
||||
|
||||
final spacingXS = r.spacing(mobile: 10, tablet: 15, desktop: 18);
|
||||
final spacingSM = r.spacing(mobile: 15, tablet: 20, desktop: 24);
|
||||
final spacingMD = r.spacing(mobile: 20, tablet: 22, desktop: 26);
|
||||
final spacingLG = r.spacing(mobile: 20, tablet: 22, desktop: 28);
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Color(0xFFFFF8F0),
|
||||
Color(0xFFEBC894),
|
||||
Color(0xFFE8DAF2),
|
||||
Color(0xFFB49EF4),
|
||||
],
|
||||
stops: [0.0, 0.3, 0.6, 1.0],
|
||||
),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: r.screenHeight),
|
||||
child: IntrinsicHeight(
|
||||
child: Center(
|
||||
child: CommonContainerAuth(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Logo
|
||||
Image.asset(
|
||||
AppAssets.taxgildelogoauth,
|
||||
width: logoWidth,
|
||||
height: logoHeight,
|
||||
),
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
// Title
|
||||
Text(
|
||||
"Login",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: titleFontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.authheading,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
// Subtitle
|
||||
Text(
|
||||
"Enter your Mobile Number",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: subtitleFontSize,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// Mobile TextField
|
||||
CommanTextFormField(
|
||||
controller: _mobileController,
|
||||
hintText: 'Enter your Mobile Number',
|
||||
keyboardType: TextInputType.phone,
|
||||
prefixIcon: Icons.mobile_screen_share,
|
||||
),
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// Terms and Policy
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: "By signing up, you agree to the ",
|
||||
style: TextStyle(
|
||||
fontSize: termsFontSize,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "Terms of Service ",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: termsFontSize,
|
||||
color: AppColors.authtermsandcondition,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
termsAsync.when(
|
||||
data: (terms) {
|
||||
CommonInfoPopup.show(
|
||||
context: context,
|
||||
title:
|
||||
terms.data?.title ??
|
||||
"Terms of Service",
|
||||
content:
|
||||
terms.data?.content ??
|
||||
"No terms found.",
|
||||
);
|
||||
},
|
||||
loading: () {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Loading Terms...",
|
||||
);
|
||||
},
|
||||
error: (err, _) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Failed to load Terms",
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
const TextSpan(text: "and "),
|
||||
TextSpan(
|
||||
text: "Data Processing Agreement",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: termsFontSize,
|
||||
color: AppColors.authtermsandcondition,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
policyAsync.when(
|
||||
data: (policy) {
|
||||
CommonInfoPopup.show(
|
||||
context: context,
|
||||
title:
|
||||
policy.data?.title ??
|
||||
"Data Processing Agreement",
|
||||
content:
|
||||
policy.data?.content ??
|
||||
"No policy found.",
|
||||
);
|
||||
},
|
||||
loading: () {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Loading Policy...",
|
||||
);
|
||||
},
|
||||
error: (err, _) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Failed to load Policy",
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
SizedBox(height: spacingSM),
|
||||
const Text("Or"),
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
// Sign up
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: "Didn't Have account? ",
|
||||
style: TextStyle(fontSize: signupFontSize),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "Sign Up",
|
||||
style: TextStyle(
|
||||
fontSize: signupFontSize,
|
||||
color: AppColors.authsignup,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Get.offNamed(ConstRouters.signup);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// Login Button
|
||||
loginState.isLoading
|
||||
? const CircularProgressIndicator()
|
||||
: CommanButton(
|
||||
text: "Login",
|
||||
onPressed: _handleLogin,
|
||||
),
|
||||
|
||||
SizedBox(height: spacingMD),
|
||||
|
||||
Text(
|
||||
"Other Login",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: otherLoginFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.13,
|
||||
color: const Color(0xFF6C7278),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: spacingXS),
|
||||
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: "Staff Login? ",
|
||||
style: TextStyle(fontSize: signupFontSize),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "Click Here",
|
||||
style: TextStyle(
|
||||
fontSize: signupFontSize,
|
||||
color: AppColors.authsignup,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Get.offNamed(ConstRouters.employeelogin);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,422 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:taxglide/consts/app_asstes.dart';
|
||||
import 'package:taxglide/consts/app_colors.dart';
|
||||
import 'package:taxglide/consts/comman_button.dart';
|
||||
import 'package:taxglide/consts/comman_container_auth.dart';
|
||||
import 'package:taxglide/consts/responsive_helper.dart';
|
||||
import 'package:taxglide/consts/validation_popup.dart';
|
||||
import 'package:taxglide/controller/api_contoller.dart';
|
||||
import 'package:taxglide/router/consts_routers.dart';
|
||||
|
||||
import 'package:taxglide/view/Main_controller/main_controller.dart';
|
||||
|
||||
class OtpScreen extends ConsumerStatefulWidget {
|
||||
const OtpScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<OtpScreen> createState() => _OtpScreenState();
|
||||
}
|
||||
|
||||
class _OtpScreenState extends ConsumerState<OtpScreen> {
|
||||
final ValidationPopup _validationPopup = ValidationPopup();
|
||||
final int otpLength = 4;
|
||||
final List<TextEditingController> _controllers = [];
|
||||
final List<FocusNode> _focusNodes = [];
|
||||
String otpValue = '';
|
||||
|
||||
Timer? _timer;
|
||||
int _remainingSeconds = 600;
|
||||
bool _canResend = false;
|
||||
|
||||
late String mobile;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final args = Get.arguments as Map<String, dynamic>;
|
||||
mobile = args['mobile'] ?? '';
|
||||
|
||||
for (int i = 0; i < otpLength; i++) {
|
||||
_controllers.add(TextEditingController());
|
||||
_focusNodes.add(FocusNode());
|
||||
}
|
||||
_startTimer();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
for (var c in _controllers) c.dispose();
|
||||
for (var f in _focusNodes) f.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _startTimer() {
|
||||
_canResend = false;
|
||||
_remainingSeconds = 30;
|
||||
_timer?.cancel();
|
||||
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
if (_remainingSeconds > 0) {
|
||||
setState(() => _remainingSeconds--);
|
||||
} else {
|
||||
setState(() => _canResend = true);
|
||||
timer.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String _formatTime(int seconds) {
|
||||
int minutes = seconds ~/ 60;
|
||||
int remainingSeconds = seconds % 60;
|
||||
return '${minutes.toString().padLeft(2, '0')}:${remainingSeconds.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
void _resendOtp() async {
|
||||
if (!_canResend) return;
|
||||
for (var controller in _controllers) controller.clear();
|
||||
setState(() => otpValue = '');
|
||||
_focusNodes[0].requestFocus();
|
||||
|
||||
try {
|
||||
await ref.read(loginProvider.notifier).login(mobile);
|
||||
final loginState = ref.read(loginProvider);
|
||||
loginState.when(
|
||||
data: (result) {
|
||||
if (result['success'] == true) {
|
||||
_validationPopup.showSuccessMessage(
|
||||
context,
|
||||
"OTP has been resent successfully!",
|
||||
);
|
||||
_startTimer();
|
||||
for (var controller in _controllers) controller.clear();
|
||||
setState(() => otpValue = '');
|
||||
} else {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
result['error'] ?? "Failed to resend OTP",
|
||||
);
|
||||
}
|
||||
},
|
||||
loading: () {},
|
||||
error: (error, stack) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Failed to resend OTP. Please try again.",
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"An error occurred. Please try again.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _verifyOtp() async {
|
||||
if (otpValue.length != otpLength) {
|
||||
_validationPopup.showErrorMessage(context, "Please enter all OTP digits");
|
||||
return;
|
||||
}
|
||||
|
||||
await ref.read(loginProvider.notifier).verifyOtp(mobile, otpValue);
|
||||
final loginState = ref.read(loginProvider);
|
||||
|
||||
loginState.when(
|
||||
data: (result) {
|
||||
if (result['success'] == true) {
|
||||
_validationPopup.showSuccessMessage(
|
||||
context,
|
||||
"OTP Verified Successfully!",
|
||||
);
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
Get.offAll(() => MainController());
|
||||
});
|
||||
} else {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
result['error'] ?? "Invalid OTP. Please try again.",
|
||||
);
|
||||
}
|
||||
},
|
||||
loading: () {},
|
||||
error: (error, stack) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Failed to verify OTP. Please try again.",
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _onOtpChange(int index, String value) {
|
||||
if (value.isNotEmpty && index < otpLength - 1) {
|
||||
_focusNodes[index + 1].requestFocus();
|
||||
}
|
||||
if (value.isEmpty && index > 0) {
|
||||
_focusNodes[index - 1].requestFocus();
|
||||
}
|
||||
setState(() {
|
||||
otpValue = _controllers.map((c) => c.text).join();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loginState = ref.watch(loginProvider);
|
||||
final isLoading = loginState is AsyncLoading;
|
||||
|
||||
// Initialize responsive utils
|
||||
final r = ResponsiveUtils(context);
|
||||
|
||||
// Responsive values
|
||||
final logoWidth = r.getValue<double>(
|
||||
mobile: 120,
|
||||
tablet: 141,
|
||||
desktop: 160,
|
||||
);
|
||||
final logoHeight = r.getValue<double>(
|
||||
mobile: 85,
|
||||
tablet: 100,
|
||||
desktop: 115,
|
||||
);
|
||||
final titleFontSize = r.fontSize(mobile: 26, tablet: 32, desktop: 36);
|
||||
final subtitleFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
|
||||
final mobileFontSize = r.fontSize(mobile: 12, tablet: 13, desktop: 14);
|
||||
final resendFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
|
||||
final timerFontSize = r.fontSize(mobile: 14, tablet: 16, desktop: 18);
|
||||
|
||||
final otpBoxWidth = r.getValue<double>(mobile: 52, tablet: 60, desktop: 68);
|
||||
final otpBoxHeight = r.getValue<double>(
|
||||
mobile: 48,
|
||||
tablet: 56,
|
||||
desktop: 64,
|
||||
);
|
||||
final otpFontSize = r.fontSize(mobile: 22, tablet: 28, desktop: 32);
|
||||
final otpBoxMargin = r.getValue<double>(mobile: 5, tablet: 6, desktop: 8);
|
||||
final otpBoxRadius = r.getValue<double>(mobile: 5, tablet: 6, desktop: 8);
|
||||
|
||||
final spacingXS = r.spacing(mobile: 10, tablet: 10, desktop: 12);
|
||||
final spacingSM = r.spacing(mobile: 20, tablet: 20, desktop: 24);
|
||||
final spacingMD = r.spacing(mobile: 22, tablet: 22, desktop: 26);
|
||||
final spacingLG = r.spacing(mobile: 30, tablet: 30, desktop: 36);
|
||||
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
// Background gradient
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Color(0xFFFFF8F0),
|
||||
Color(0xFFEBC894),
|
||||
Color(0xFFE8DAF2),
|
||||
Color(0xFFB49EF4),
|
||||
],
|
||||
stops: [0.0, 0.3, 0.6, 1.0],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Scrollable content
|
||||
SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
height: r.screenHeight,
|
||||
child: Center(
|
||||
child: CommonContainerAuth(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Logo
|
||||
Image.asset(
|
||||
AppAssets.taxgildelogoauth,
|
||||
width: logoWidth,
|
||||
height: logoHeight,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
// Title
|
||||
Text(
|
||||
"Enter OTP",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: titleFontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.3,
|
||||
letterSpacing: 0.01 * titleFontSize,
|
||||
color: AppColors.authheading,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
// Subtitle
|
||||
Text(
|
||||
"OTP has been sent to your registered mobile number",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: subtitleFontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.03 * subtitleFontSize,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingMD),
|
||||
|
||||
// Mobile number + Change
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: mobile,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: mobileFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.01,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: " ( Change Number )",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-ExtraBold',
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: mobileFontSize,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.04,
|
||||
color: AppColors.authchange,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Get.offNamed(
|
||||
ConstRouters.login,
|
||||
arguments: {'mobile': mobile},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// OTP Boxes
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(otpLength, (index) {
|
||||
bool isFilled = _controllers[index].text.isNotEmpty;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
horizontal: otpBoxMargin,
|
||||
),
|
||||
width: otpBoxWidth,
|
||||
height: otpBoxHeight,
|
||||
decoration: BoxDecoration(
|
||||
color: isFilled
|
||||
? AppColors.commanbutton
|
||||
: Colors.white,
|
||||
borderRadius: BorderRadius.circular(otpBoxRadius),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFDFDFDF),
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(
|
||||
0xFFBDBDBD,
|
||||
).withOpacity(0.25),
|
||||
blurRadius: 7,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: TextField(
|
||||
controller: _controllers[index],
|
||||
focusNode: _focusNodes[index],
|
||||
textAlign: TextAlign.center,
|
||||
keyboardType: TextInputType.number,
|
||||
maxLength: 1,
|
||||
enabled: !isLoading,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: otpFontSize,
|
||||
letterSpacing: 0.03 * otpFontSize,
|
||||
color: isFilled ? Colors.white : Colors.black,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
counterText: '',
|
||||
border: InputBorder.none,
|
||||
),
|
||||
onChanged: (value) =>
|
||||
_onOtpChange(index, value),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
SizedBox(height: spacingXS),
|
||||
|
||||
// Resend
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
onTap: _canResend && !isLoading ? _resendOtp : null,
|
||||
child: Text(
|
||||
"Resend",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: resendFontSize,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.02 * resendFontSize,
|
||||
color: _canResend && !isLoading
|
||||
? AppColors.authchange
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingSM),
|
||||
|
||||
// Timer
|
||||
Text(
|
||||
_formatTime(_remainingSeconds),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: timerFontSize,
|
||||
color: _remainingSeconds > 0
|
||||
? AppColors.authheading
|
||||
: Colors.red,
|
||||
),
|
||||
),
|
||||
SizedBox(height: spacingLG),
|
||||
|
||||
// Verify Button
|
||||
isLoading
|
||||
? const CircularProgressIndicator()
|
||||
: CommanButton(text: "Verify", onPressed: _verifyOtp),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,419 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:taxglide/consts/app_asstes.dart';
|
||||
import 'package:taxglide/consts/app_colors.dart';
|
||||
import 'package:taxglide/consts/comman_button.dart';
|
||||
import 'package:taxglide/consts/comman_container_auth.dart';
|
||||
import 'package:taxglide/consts/validation_popup.dart';
|
||||
import 'package:taxglide/controller/api_contoller.dart';
|
||||
import 'package:taxglide/router/consts_routers.dart';
|
||||
import 'package:taxglide/view/Main_controller/main_controller.dart';
|
||||
|
||||
class RegisterOtpScreen extends ConsumerStatefulWidget {
|
||||
const RegisterOtpScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<RegisterOtpScreen> createState() => _RegisterOtpScreenState();
|
||||
}
|
||||
|
||||
class _RegisterOtpScreenState extends ConsumerState<RegisterOtpScreen> {
|
||||
final ValidationPopup _validationPopup = ValidationPopup();
|
||||
final int otpLength = 4;
|
||||
final List<TextEditingController> _controllers = [];
|
||||
final List<FocusNode> _focusNodes = [];
|
||||
String otpValue = '';
|
||||
|
||||
// Timer variables
|
||||
Timer? _timer;
|
||||
int _remainingSeconds = 600; // 10 minutes = 600 seconds
|
||||
bool _canResend = false;
|
||||
|
||||
// Get arguments passed from signup
|
||||
late String name;
|
||||
late String email;
|
||||
late String mobile;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Get arguments from navigation
|
||||
final args = Get.arguments as Map<String, dynamic>;
|
||||
name = args['name'] ?? '';
|
||||
email = args['email'] ?? '';
|
||||
mobile = args['mobile'] ?? '';
|
||||
|
||||
for (int i = 0; i < otpLength; i++) {
|
||||
_controllers.add(TextEditingController());
|
||||
_focusNodes.add(FocusNode());
|
||||
}
|
||||
_startTimer();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
for (var c in _controllers) {
|
||||
c.dispose();
|
||||
}
|
||||
for (var f in _focusNodes) {
|
||||
f.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _startTimer() {
|
||||
_canResend = false;
|
||||
_remainingSeconds = 30; // Reset to 30 seconds
|
||||
|
||||
_timer?.cancel();
|
||||
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
if (_remainingSeconds > 0) {
|
||||
setState(() {
|
||||
_remainingSeconds--;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_canResend = true;
|
||||
});
|
||||
timer.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String _formatTime(int seconds) {
|
||||
int minutes = seconds ~/ 60;
|
||||
int remainingSeconds = seconds % 60;
|
||||
return '${minutes.toString().padLeft(2, '0')}:${remainingSeconds.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
void _resendOtp() async {
|
||||
if (!_canResend) return;
|
||||
for (var controller in _controllers) {
|
||||
controller.clear();
|
||||
}
|
||||
setState(() {
|
||||
otpValue = '';
|
||||
});
|
||||
|
||||
// Move focus to first field
|
||||
_focusNodes[0].requestFocus();
|
||||
try {
|
||||
// Call signup API again to resend OTP
|
||||
await ref.read(signupProvider.notifier).signup(name, mobile, email);
|
||||
|
||||
final signupState = ref.read(signupProvider);
|
||||
|
||||
signupState.when(
|
||||
data: (result) {
|
||||
if (result['success'] == true) {
|
||||
_validationPopup.showSuccessMessage(
|
||||
context,
|
||||
"OTP has been resent successfully!",
|
||||
);
|
||||
_startTimer();
|
||||
// Clear OTP fields
|
||||
for (var controller in _controllers) {
|
||||
controller.clear();
|
||||
}
|
||||
setState(() {
|
||||
otpValue = '';
|
||||
});
|
||||
} else {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
result['error'] ?? "Failed to resend OTP",
|
||||
);
|
||||
}
|
||||
},
|
||||
loading: () {
|
||||
// Show loading indicator
|
||||
},
|
||||
error: (error, stack) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Failed to resend OTP. Please try again.",
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"An error occurred. Please try again.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _verifyOtp() async {
|
||||
if (otpValue.length != otpLength) {
|
||||
_validationPopup.showErrorMessage(context, "Please enter all OTP digits");
|
||||
return;
|
||||
}
|
||||
|
||||
// Call verify OTP API for signup
|
||||
await ref.read(signupProvider.notifier).verifySignupOtp(mobile, otpValue);
|
||||
|
||||
final signupState = ref.read(signupProvider);
|
||||
|
||||
signupState.when(
|
||||
data: (result) {
|
||||
if (result['success'] == true) {
|
||||
_validationPopup.showSuccessMessage(
|
||||
context,
|
||||
"Registration Successful!",
|
||||
);
|
||||
|
||||
// Navigate to main screen after successful verification
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
Get.offAll(() => MainController());
|
||||
});
|
||||
} else {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
result['error'] ?? "Invalid OTP. Please try again.",
|
||||
);
|
||||
}
|
||||
},
|
||||
loading: () {
|
||||
// Loading is handled by the provider
|
||||
},
|
||||
error: (error, stack) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Failed to verify OTP. Please try again.",
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _onOtpChange(int index, String value) {
|
||||
if (value.isNotEmpty && index < otpLength - 1) {
|
||||
_focusNodes[index + 1].requestFocus();
|
||||
}
|
||||
if (value.isEmpty && index > 0) {
|
||||
_focusNodes[index - 1].requestFocus();
|
||||
}
|
||||
|
||||
setState(() {
|
||||
otpValue = _controllers.map((c) => c.text).join();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final signupState = ref.watch(signupProvider);
|
||||
final isLoading = signupState is AsyncLoading;
|
||||
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
// Background gradient
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Color(0xFFFFF8F0),
|
||||
Color(0xFFEBC894),
|
||||
Color(0xFFE8DAF2),
|
||||
Color(0xFFB49EF4),
|
||||
],
|
||||
stops: [0.0, 0.3, 0.6, 1.0],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Scrollable content
|
||||
SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Center(
|
||||
child: CommonContainerAuth(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
AppAssets.taxgildelogoauth,
|
||||
width: 141,
|
||||
height: 100,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
"Enter OTP",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.3,
|
||||
letterSpacing: 0.01 * 32,
|
||||
color: AppColors.authheading,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
"OTP has been sent to your registered mobile number",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.03 * 14,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 22),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
text: mobile,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 13,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.01,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: " ( Change Number )",
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-ExtraBold',
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 13,
|
||||
height: 1.8,
|
||||
letterSpacing: 0.04,
|
||||
color: AppColors.authchange,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Get.offNamed(
|
||||
ConstRouters.signup,
|
||||
arguments: {
|
||||
'name': name,
|
||||
'email': email,
|
||||
'mobile': mobile,
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// OTP Boxes
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(otpLength, (index) {
|
||||
bool isFilled = _controllers[index].text.isNotEmpty;
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 6),
|
||||
width: 60,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
color: isFilled
|
||||
? AppColors.commanbutton
|
||||
: Colors.white,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFDFDFDF),
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(
|
||||
0xFFBDBDBD,
|
||||
).withOpacity(0.25),
|
||||
blurRadius: 7,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: TextField(
|
||||
controller: _controllers[index],
|
||||
focusNode: _focusNodes[index],
|
||||
textAlign: TextAlign.center,
|
||||
keyboardType: TextInputType.number,
|
||||
maxLength: 1,
|
||||
enabled: !isLoading,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 28,
|
||||
letterSpacing: 0.03 * 28,
|
||||
color: isFilled ? Colors.white : Colors.black,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
counterText: '',
|
||||
border: InputBorder.none,
|
||||
),
|
||||
onChanged: (value) =>
|
||||
_onOtpChange(index, value),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// Resend OTP Button
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
onTap: _canResend && !isLoading ? _resendOtp : null,
|
||||
child: Text(
|
||||
"Resend",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.02 * 14,
|
||||
color: _canResend && !isLoading
|
||||
? AppColors.authchange
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Timer Display
|
||||
Text(
|
||||
_formatTime(_remainingSeconds),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
color: _remainingSeconds > 0
|
||||
? AppColors.authheading
|
||||
: Colors.red,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Verify Button
|
||||
isLoading
|
||||
? const CircularProgressIndicator()
|
||||
: CommanButton(text: "Verify", onPressed: _verifyOtp),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:taxglide/consts/app_asstes.dart';
|
||||
import 'package:taxglide/consts/app_colors.dart';
|
||||
import 'package:taxglide/consts/comman_button.dart';
|
||||
import 'package:taxglide/consts/comman_container_auth.dart';
|
||||
import 'package:taxglide/consts/comman_textformfileds.dart';
|
||||
import 'package:taxglide/consts/validation_popup.dart';
|
||||
import 'package:taxglide/controller/api_contoller.dart';
|
||||
import 'package:taxglide/router/consts_routers.dart';
|
||||
|
||||
class SignupScreen extends ConsumerStatefulWidget {
|
||||
const SignupScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<SignupScreen> createState() => _SignupScreenState();
|
||||
}
|
||||
|
||||
class _SignupScreenState extends ConsumerState<SignupScreen> {
|
||||
final ValidationPopup _validationPopup = ValidationPopup();
|
||||
|
||||
final TextEditingController _nameController = TextEditingController();
|
||||
final TextEditingController _mobileController = TextEditingController();
|
||||
final TextEditingController _emailController = TextEditingController();
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Get arguments from navigation if available
|
||||
final args = Get.arguments;
|
||||
if (args != null && args is Map<String, dynamic>) {
|
||||
_nameController.text = args['name'] ?? '';
|
||||
_emailController.text = args['email'] ?? '';
|
||||
_mobileController.text = args['mobile'] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
// Error state tracking
|
||||
bool _nameError = false;
|
||||
bool _mobileError = false;
|
||||
bool _emailError = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Listen to signup state
|
||||
final signupState = ref.watch(signupProvider);
|
||||
|
||||
// Handle API response
|
||||
ref.listen<AsyncValue<Map<String, dynamic>>>(signupProvider, (
|
||||
previous,
|
||||
next,
|
||||
) {
|
||||
next.when(
|
||||
data: (response) {
|
||||
if (response.isNotEmpty) {
|
||||
if (response['success'] == true) {
|
||||
_validationPopup.showSuccessMessage(
|
||||
context,
|
||||
"Sign up successful! OTP sent to your mobile.",
|
||||
);
|
||||
|
||||
// Navigate to RegisterOtpScreen with all data
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
Get.toNamed(
|
||||
ConstRouters.registerOtp,
|
||||
arguments: {
|
||||
'name': _nameController.text,
|
||||
'email': _emailController.text,
|
||||
'mobile': _mobileController.text,
|
||||
},
|
||||
);
|
||||
});
|
||||
} else {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
response['error'] ?? 'Signup failed',
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: (error, stackTrace) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
'An error occurred: ${error.toString()}',
|
||||
);
|
||||
},
|
||||
loading: () {},
|
||||
);
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
// 🌈 Background gradient
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Color(0xFFFFF8F0),
|
||||
Color(0xFFEBC894),
|
||||
Color(0xFFE8DAF2),
|
||||
Color(0xFFB49EF4),
|
||||
],
|
||||
stops: [0.0, 0.3, 0.6, 1.0],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 📜 Scrollable content
|
||||
SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Center(
|
||||
child: CommonContainerAuth(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
AppAssets.taxgildelogoauth,
|
||||
width: 141,
|
||||
height: 100,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// 🟣 Title
|
||||
Text(
|
||||
"Sign Up",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.3,
|
||||
letterSpacing: 0.01 * 32,
|
||||
color: AppColors.authheading,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 25),
|
||||
|
||||
// 👤 Name Field
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Name*",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontSize: 14,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
CommanTextFormField(
|
||||
hintText: 'Enter Company Name',
|
||||
controller: _nameController,
|
||||
hasError: _nameError,
|
||||
onChanged: (value) {
|
||||
if (_nameError && value.isNotEmpty) {
|
||||
setState(() {
|
||||
_nameError = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// 📱 Mobile Number Field
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Contact Number *",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontSize: 14,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
CommanTextFormField(
|
||||
hintText: 'Enter Contact Number',
|
||||
controller: _mobileController,
|
||||
hasError: _mobileError,
|
||||
keyboardType: TextInputType.phone,
|
||||
onChanged: (value) {
|
||||
if (_mobileError && value.isNotEmpty) {
|
||||
setState(() {
|
||||
_mobileError = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// 📧 Email Field
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Email *",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontSize: 14,
|
||||
color: AppColors.authleading,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
CommanTextFormField(
|
||||
hintText: 'Enter Email ID',
|
||||
controller: _emailController,
|
||||
hasError: _emailError,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
onChanged: (value) {
|
||||
if (_emailError && value.isNotEmpty) {
|
||||
setState(() {
|
||||
_emailError = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// ✅ Submit Button
|
||||
signupState.isLoading
|
||||
? const CircularProgressIndicator()
|
||||
: CommanButton(
|
||||
text: "Submit",
|
||||
onPressed: () {
|
||||
_handleSignup();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _handleSignup() {
|
||||
// Reset all errors first
|
||||
setState(() {
|
||||
_nameError = false;
|
||||
_mobileError = false;
|
||||
_emailError = false;
|
||||
});
|
||||
|
||||
bool hasError = false;
|
||||
|
||||
// Validate name
|
||||
if (_nameController.text.isEmpty) {
|
||||
setState(() {
|
||||
_nameError = true;
|
||||
});
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
// Validate mobile
|
||||
if (_mobileController.text.isEmpty) {
|
||||
setState(() {
|
||||
_mobileError = true;
|
||||
});
|
||||
hasError = true;
|
||||
} else if (!_validationPopup.validateMobileNumber(
|
||||
context,
|
||||
_mobileController.text,
|
||||
)) {
|
||||
setState(() {
|
||||
_mobileError = true;
|
||||
});
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
// Validate email - NOW WITH FORMAT CHECK
|
||||
if (_emailController.text.isEmpty) {
|
||||
setState(() {
|
||||
_emailError = true;
|
||||
});
|
||||
hasError = true;
|
||||
} else if (!_validationPopup.validateEmail(
|
||||
context,
|
||||
_emailController.text,
|
||||
)) {
|
||||
setState(() {
|
||||
_emailError = true;
|
||||
});
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
// Show error message if any field has error
|
||||
if (hasError) {
|
||||
_validationPopup.showErrorMessage(
|
||||
context,
|
||||
"Please fill all required fields correctly",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// All validations passed - call API
|
||||
ref
|
||||
.read(signupProvider.notifier)
|
||||
.signup(
|
||||
_nameController.text,
|
||||
_mobileController.text,
|
||||
_emailController.text,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
_mobileController.dispose();
|
||||
_emailController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user