parent
e4d998cf43
commit
e054f2eb92
@ -1,94 +1,223 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:supplier_new/common/settings.dart';
|
import 'package:supplier_new/common/settings.dart';
|
||||||
|
|
||||||
class SearchOrderAppBar extends StatelessWidget implements PreferredSizeWidget {
|
class SearchOrderAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||||
|
|
||||||
final TextEditingController controller;
|
final TextEditingController controller;
|
||||||
final VoidCallback onBack;
|
final VoidCallback onBack;
|
||||||
final VoidCallback onHelp;
|
final VoidCallback onHelp;
|
||||||
|
final Function(String)? onSearch;
|
||||||
|
|
||||||
const SearchOrderAppBar({
|
const SearchOrderAppBar({
|
||||||
super.key,
|
super.key,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
required this.onBack,
|
required this.onBack,
|
||||||
required this.onHelp,
|
required this.onHelp,
|
||||||
|
required this.onSearch,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SearchOrderAppBar> createState() => _SearchOrderAppBarState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchOrderAppBarState extends State<SearchOrderAppBar>{
|
||||||
|
|
||||||
|
late VoidCallback _listener;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState(){
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
_listener = (){
|
||||||
|
|
||||||
|
if(!mounted) return;
|
||||||
|
|
||||||
|
setState((){});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
widget.controller.addListener(_listener);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose(){
|
||||||
|
|
||||||
|
widget.controller.removeListener(_listener);
|
||||||
|
|
||||||
|
super.dispose();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return AppBar(
|
return AppBar(
|
||||||
|
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
|
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
|
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
|
|
||||||
leading: GestureDetector(
|
leading: GestureDetector(
|
||||||
onTap: onBack, // 👉 Controlled by parent
|
|
||||||
|
onTap: widget.onBack,
|
||||||
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
|
|
||||||
'images/backbutton_appbar.png',
|
'images/backbutton_appbar.png',
|
||||||
|
|
||||||
height: 24,
|
height: 24,
|
||||||
|
|
||||||
width: 24,
|
width: 24,
|
||||||
|
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
|
|
||||||
title: Container(
|
title: Container(
|
||||||
|
|
||||||
height: 40,
|
height: 40,
|
||||||
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
|
||||||
borderRadius: BorderRadius.circular(22),
|
borderRadius: BorderRadius.circular(22),
|
||||||
|
|
||||||
border: Border.all(color: const Color(0XFF939495)),
|
border: Border.all(color: const Color(0XFF939495)),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: controller,
|
|
||||||
|
controller: widget.controller,
|
||||||
|
|
||||||
|
onChanged: widget.onSearch,
|
||||||
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
|
||||||
hintText: "Search order",
|
hintText: "Search order",
|
||||||
|
|
||||||
hintStyle: fontTextStyle(
|
hintStyle: fontTextStyle(
|
||||||
|
|
||||||
16,
|
16,
|
||||||
|
|
||||||
const Color(0XFF646566),
|
const Color(0XFF646566),
|
||||||
|
|
||||||
FontWeight.w400,
|
FontWeight.w400,
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
prefixIcon: SizedBox(
|
prefixIcon: SizedBox(
|
||||||
|
|
||||||
height: 20,
|
height: 20,
|
||||||
|
|
||||||
width: 20,
|
width: 20,
|
||||||
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
|
|
||||||
'images/search.png',
|
'images/search.png',
|
||||||
|
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
|
/// ⭐ CLEAR BUTTON ADDED HERE
|
||||||
|
suffixIcon: widget.controller.text.isNotEmpty
|
||||||
|
|
||||||
|
? IconButton(
|
||||||
|
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.close,
|
||||||
|
size:18,
|
||||||
|
color: Color(0XFF646566)
|
||||||
|
),
|
||||||
|
|
||||||
|
onPressed: (){
|
||||||
|
|
||||||
|
widget.controller.clear();
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
: null,
|
||||||
|
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
|
|
||||||
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
style: fontTextStyle(
|
style: fontTextStyle(
|
||||||
|
|
||||||
16,
|
16,
|
||||||
|
|
||||||
const Color(0XFF2A2A2A),
|
const Color(0XFF2A2A2A),
|
||||||
|
|
||||||
FontWeight.w400,
|
FontWeight.w400,
|
||||||
|
|
||||||
),
|
),
|
||||||
onSubmitted: (value) {
|
|
||||||
debugPrint("Search Orders: $value");
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
actions: [
|
actions: [
|
||||||
|
|
||||||
Padding(
|
Padding(
|
||||||
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: onHelp, // 👉 Controlled by parent
|
|
||||||
|
onTap: widget.onHelp,
|
||||||
|
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
|
|
||||||
'images/help_appbar.png',
|
'images/help_appbar.png',
|
||||||
|
|
||||||
height: 24,
|
height: 24,
|
||||||
|
|
||||||
width: 24,
|
width: 24,
|
||||||
|
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
}
|
||||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
class DriverTripsModel {
|
||||||
|
|
||||||
|
String id = '';
|
||||||
|
String bookingId = '';
|
||||||
|
String tankerName = '';
|
||||||
|
String buildingName = '';
|
||||||
|
String address = '';
|
||||||
|
String date = '';
|
||||||
|
String time = '';
|
||||||
|
String waterType = '';
|
||||||
|
String capacity = '';
|
||||||
|
String price = '';
|
||||||
|
String status = '';
|
||||||
|
String customerName = '';
|
||||||
|
String amountPaid = '';
|
||||||
|
String amountDue = '';
|
||||||
|
String paymentStatus = '';
|
||||||
|
|
||||||
|
DriverTripsModel();
|
||||||
|
|
||||||
|
factory DriverTripsModel.fromJson(
|
||||||
|
Map<String,dynamic> json){
|
||||||
|
|
||||||
|
DriverTripsModel d =
|
||||||
|
DriverTripsModel();
|
||||||
|
|
||||||
|
d.id =
|
||||||
|
json['_id'] ?? '';
|
||||||
|
|
||||||
|
d.bookingId =
|
||||||
|
json['bookingid'] ?? '';
|
||||||
|
|
||||||
|
d.tankerName =
|
||||||
|
json['tankerName'] ?? '';
|
||||||
|
|
||||||
|
d.buildingName =
|
||||||
|
json['buildingName'] ?? '';
|
||||||
|
|
||||||
|
d.address =
|
||||||
|
json['address'] ?? '';
|
||||||
|
|
||||||
|
d.date =
|
||||||
|
json['dateOfOrder'] ?? '';
|
||||||
|
|
||||||
|
d.time =
|
||||||
|
json['time'] ?? '';
|
||||||
|
|
||||||
|
d.waterType =
|
||||||
|
json['typeofwater'] ?? '';
|
||||||
|
|
||||||
|
d.capacity =
|
||||||
|
json['capacity'] ?? '';
|
||||||
|
|
||||||
|
d.price =
|
||||||
|
json['price'] ?? '';
|
||||||
|
|
||||||
|
d.status =
|
||||||
|
json['orderStatus'] ?? '';
|
||||||
|
|
||||||
|
d.customerName =
|
||||||
|
json['customerName'] ?? '';
|
||||||
|
|
||||||
|
d.amountPaid =
|
||||||
|
json['amount_paid'] ?? '';
|
||||||
|
|
||||||
|
d.amountDue =
|
||||||
|
json['amount_due'] ?? '';
|
||||||
|
|
||||||
|
d.paymentStatus =
|
||||||
|
json['payment_status'] ?? '';
|
||||||
|
|
||||||
|
return d;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,29 +1,78 @@
|
|||||||
class TankerTripsModel {
|
class TankerTripsModel {
|
||||||
|
|
||||||
String tanker_name = '';
|
String tanker_name = '';
|
||||||
String address = '';
|
String address = '';
|
||||||
String dbId = '';
|
String dbId = '';
|
||||||
String driver_name = '';
|
String driver_name = '';
|
||||||
String status = '';
|
String status = '';
|
||||||
String building_name = '';
|
String building_name = '';
|
||||||
String water_source_location='';
|
String water_source_location = '';
|
||||||
String deliveredDate='';
|
String deliveredDate = '';
|
||||||
|
|
||||||
|
/// ADD THESE
|
||||||
|
String dateOfOrder = '';
|
||||||
|
String time = '';
|
||||||
|
String supplierName = '';
|
||||||
|
String amount_paid = '';
|
||||||
|
String amount_due = '';
|
||||||
|
|
||||||
TankerTripsModel();
|
TankerTripsModel();
|
||||||
|
|
||||||
factory TankerTripsModel.fromJson(Map<String, dynamic> json){
|
factory TankerTripsModel.fromJson(
|
||||||
TankerTripsModel rtvm = new TankerTripsModel();
|
Map<String, dynamic> json){
|
||||||
|
|
||||||
rtvm.tanker_name = json['tankerName']?? '';
|
TankerTripsModel rtvm =
|
||||||
rtvm.dbId = json['_id']?? '';
|
TankerTripsModel();
|
||||||
rtvm.address = json['supplier_address']?? '';
|
|
||||||
rtvm.driver_name = json['delivery_agent']?? '';
|
rtvm.tanker_name =
|
||||||
rtvm.status = json['orderStatus']?? '';
|
json['tankerName'] ?? '';
|
||||||
rtvm.building_name = json['buildingName']?? '';
|
|
||||||
rtvm.water_source_location = json['water_source_location']?? '';
|
rtvm.dbId =
|
||||||
rtvm.deliveredDate = json['deliveredDate']?? '';
|
json['_id'] ?? '';
|
||||||
|
|
||||||
|
/// FIX (you used wrong key)
|
||||||
|
rtvm.address =
|
||||||
|
json['address'] ?? '';
|
||||||
|
|
||||||
|
rtvm.driver_name =
|
||||||
|
json['delivery_agent'] ?? '';
|
||||||
|
|
||||||
|
rtvm.status =
|
||||||
|
json['orderStatus'] ?? '';
|
||||||
|
|
||||||
|
rtvm.building_name =
|
||||||
|
json['buildingName'] ?? '';
|
||||||
|
|
||||||
|
rtvm.water_source_location =
|
||||||
|
json['water_source_location'] ?? '';
|
||||||
|
|
||||||
|
rtvm.deliveredDate =
|
||||||
|
json['deliveredDate'] ?? '';
|
||||||
|
|
||||||
|
/// ADD THESE
|
||||||
|
rtvm.dateOfOrder =
|
||||||
|
json['dateOfOrder'] ?? '';
|
||||||
|
|
||||||
|
rtvm.time =
|
||||||
|
json['time'] ?? '';
|
||||||
|
|
||||||
|
rtvm.supplierName =
|
||||||
|
json['supplierName'] ?? '';
|
||||||
|
|
||||||
|
rtvm.amount_paid =
|
||||||
|
json['amount_paid'] ?? '';
|
||||||
|
|
||||||
|
rtvm.amount_due =
|
||||||
|
json['amount_due'] ?? '';
|
||||||
|
|
||||||
return rtvm;
|
return rtvm;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"boreName":this.tanker_name,
|
|
||||||
|
"tankerName": tanker_name,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,180 +1,372 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:sms_autofill/sms_autofill.dart';
|
||||||
import 'package:supplier_new/signup/password_textbox_screen.dart';
|
import 'package:supplier_new/signup/password_textbox_screen.dart';
|
||||||
|
|
||||||
import '../common/settings.dart';
|
import '../common/settings.dart';
|
||||||
|
|
||||||
class Otpscreen extends StatefulWidget {
|
class Otpscreen extends StatefulWidget {
|
||||||
var mobileNumber;
|
|
||||||
Otpscreen({
|
final String mobileNumber;
|
||||||
this.mobileNumber
|
|
||||||
|
const Otpscreen({
|
||||||
|
super.key,
|
||||||
|
required this.mobileNumber
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Otpscreen> createState() => _OtpscreenState();
|
State<Otpscreen> createState() => _OtpscreenState();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _OtpscreenState extends State<Otpscreen> {
|
class _OtpscreenState extends State<Otpscreen>
|
||||||
final List<TextEditingController> _controllers = List.generate(6, (index) => TextEditingController());
|
with CodeAutoFill {
|
||||||
final FocusNode _focusNode = FocusNode();
|
|
||||||
|
String otpCode = "";
|
||||||
|
|
||||||
|
bool isLoading = false;
|
||||||
|
|
||||||
|
int seconds = 30;
|
||||||
|
|
||||||
|
bool canResend = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void initState(){
|
||||||
_controllers.forEach((controller) => controller.dispose());
|
|
||||||
_focusNode.dispose();
|
super.initState();
|
||||||
super.dispose();
|
|
||||||
|
listenForCode();
|
||||||
|
|
||||||
|
startTimer();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void startTimer(){
|
||||||
|
|
||||||
|
Future.delayed(const Duration(seconds:1),(){
|
||||||
|
|
||||||
|
if(seconds>0){
|
||||||
|
|
||||||
|
setState(()=>seconds--);
|
||||||
|
|
||||||
|
startTimer();
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
setState(()=>canResend=true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void codeUpdated(){
|
||||||
|
|
||||||
|
setState((){
|
||||||
|
|
||||||
|
otpCode = code!;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
if(otpCode.length==6){
|
||||||
|
|
||||||
|
verifyOtp();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> verifyOtp() async{
|
||||||
|
|
||||||
|
if(isLoading) return;
|
||||||
|
|
||||||
|
if(otpCode.length!=6){
|
||||||
|
|
||||||
|
AppSettings.longFailedToast(
|
||||||
|
"Enter 6 digit OTP");
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(()=>isLoading=true);
|
||||||
|
|
||||||
|
AppSettings.preLoaderDialog(context);
|
||||||
|
|
||||||
|
bool isOnline =
|
||||||
|
await AppSettings.internetConnectivity();
|
||||||
|
|
||||||
|
if(isOnline){
|
||||||
|
|
||||||
|
var payload={
|
||||||
|
|
||||||
|
"phoneVerificationCode":otpCode,
|
||||||
|
|
||||||
|
"phone":widget.mobileNumber
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
bool status =
|
||||||
|
await AppSettings.verifyPhn(payload);
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
|
||||||
|
if(status){
|
||||||
|
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
|
||||||
|
context,
|
||||||
|
|
||||||
|
MaterialPageRoute(
|
||||||
|
|
||||||
|
builder:(_)=>
|
||||||
|
PasswordTextBoxesScreen(
|
||||||
|
mobileNumber:
|
||||||
|
widget.mobileNumber),
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
AppSettings.longFailedToast(
|
||||||
|
"Invalid OTP");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
|
||||||
|
AppSettings.longFailedToast(
|
||||||
|
"Check internet");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(()=>isLoading=false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _submitOtp() {
|
String maskNumber(String number){
|
||||||
final otp = _controllers.map((controller) => controller.text).join();
|
|
||||||
print("Entered OTP: $otp");
|
return "*******${number.substring(7)}";
|
||||||
// Add OTP validation or submission logic here
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> resendOtp() async{
|
||||||
|
|
||||||
|
if(!canResend) return;
|
||||||
|
|
||||||
|
var payload={
|
||||||
|
|
||||||
|
"mobileNumbers":
|
||||||
|
widget.mobileNumber
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
await AppSettings.getOtp(payload);
|
||||||
|
|
||||||
|
setState((){
|
||||||
|
|
||||||
|
seconds=30;
|
||||||
|
|
||||||
|
canResend=false;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
startTimer();
|
||||||
|
|
||||||
String maskMobileNumber(String number) {
|
|
||||||
if (number.length < 3) return number; // Handle invalid numbers
|
|
||||||
final stars = '*' * (number.length - 3);
|
|
||||||
final lastThree = number.substring(number.length - 3);
|
|
||||||
return '$stars$lastThree';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose(){
|
||||||
|
|
||||||
|
cancel();
|
||||||
|
|
||||||
|
super.dispose();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context){
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Stack(children: <Widget>[
|
|
||||||
/*Container(
|
backgroundColor:Colors.white,
|
||||||
decoration: const BoxDecoration(
|
|
||||||
image: DecorationImage(
|
body:SafeArea(
|
||||||
image: AssetImage("images/backgroundimage.png"),
|
|
||||||
fit: BoxFit.cover,
|
child:Padding(
|
||||||
|
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.all(24),
|
||||||
|
|
||||||
|
child:Column(
|
||||||
|
|
||||||
|
children:[
|
||||||
|
|
||||||
|
const Spacer(),
|
||||||
|
|
||||||
|
Text(
|
||||||
|
|
||||||
|
"Enter OTP",
|
||||||
|
|
||||||
|
style:fontTextStyle(
|
||||||
|
20,
|
||||||
|
Color(0XFF101214),
|
||||||
|
FontWeight.w700),
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height:10),
|
||||||
|
|
||||||
|
Text(
|
||||||
|
|
||||||
|
"Code sent to +91 ${maskNumber(widget.mobileNumber)}",
|
||||||
|
|
||||||
|
style:fontTextStyle(
|
||||||
|
12,
|
||||||
|
Color(0XFF7E7F80),
|
||||||
|
FontWeight.w400),
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height:40),
|
||||||
|
|
||||||
|
/// OTP BOX
|
||||||
|
PinFieldAutoFill(
|
||||||
|
|
||||||
|
codeLength:6,
|
||||||
|
|
||||||
|
currentCode:otpCode,
|
||||||
|
|
||||||
|
onCodeChanged:(code){
|
||||||
|
|
||||||
|
otpCode=code??"";
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
decoration:
|
||||||
|
|
||||||
|
BoxLooseDecoration(
|
||||||
|
|
||||||
|
radius:
|
||||||
|
const Radius.circular(8),
|
||||||
|
|
||||||
|
strokeColorBuilder:
|
||||||
|
|
||||||
|
FixedColorBuilder(
|
||||||
|
primaryColor),
|
||||||
|
|
||||||
|
textStyle:
|
||||||
|
|
||||||
|
fontTextStyle(
|
||||||
|
18,
|
||||||
|
Color(0XFF101214),
|
||||||
|
FontWeight.w600),
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height:30),
|
||||||
|
|
||||||
|
/// TIMER
|
||||||
|
canResend
|
||||||
|
|
||||||
|
? GestureDetector(
|
||||||
|
|
||||||
|
onTap:resendOtp,
|
||||||
|
|
||||||
|
child:Text(
|
||||||
|
|
||||||
|
"Resend OTP",
|
||||||
|
|
||||||
|
style:fontTextStyle(
|
||||||
|
14,
|
||||||
|
primaryColor,
|
||||||
|
FontWeight.w600),
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
: Text(
|
||||||
|
|
||||||
|
"Resend in 00:$seconds",
|
||||||
|
|
||||||
|
style:fontTextStyle(
|
||||||
|
12,
|
||||||
|
Color(0XFF7E7F80),
|
||||||
|
FontWeight.w500),
|
||||||
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),*/
|
const SizedBox(height:40),
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
/// BUTTON
|
||||||
FocusScope.of(context).requestFocus(new FocusNode());
|
SizedBox(
|
||||||
},
|
|
||||||
child: SafeArea(
|
width:double.infinity,
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Padding(
|
height:55,
|
||||||
padding: EdgeInsets.fromLTRB(24, 0, 24, 0),
|
|
||||||
child: Column(children: <Widget>[
|
child:ElevatedButton(
|
||||||
SizedBox(height:MediaQuery.of(context).size.height * .2,),
|
|
||||||
|
style:
|
||||||
Container(
|
ElevatedButton.styleFrom(
|
||||||
|
|
||||||
child: Text(
|
backgroundColor:
|
||||||
'Enter confirmation code',
|
primaryColor,
|
||||||
style: fontTextStyle(16,Color(0XFF101214),FontWeight.w800),
|
|
||||||
),
|
shape:
|
||||||
),
|
RoundedRectangleBorder(
|
||||||
SizedBox(height:MediaQuery.of(context).size.height * .02,),
|
|
||||||
Container(
|
borderRadius:
|
||||||
|
BorderRadius.circular(24),
|
||||||
child: Text(
|
|
||||||
'A 6-digit code was sent to +91${maskMobileNumber(widget.mobileNumber)}',
|
),
|
||||||
style: fontTextStyle(12,Color(0XFF7E7F80),FontWeight.w400),
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
SizedBox(height:MediaQuery.of(context).size.height * .040,),
|
onPressed:verifyOtp,
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
child:isLoading
|
||||||
children: List.generate(6, (index) {
|
|
||||||
return SizedBox(
|
? const CircularProgressIndicator(
|
||||||
width: 50,
|
color:Colors.white)
|
||||||
child: TextFormField(
|
|
||||||
cursorColor:primaryColor,
|
:Text(
|
||||||
controller: _controllers[index],
|
|
||||||
focusNode: index == 0 ? _focusNode : null,
|
"Verify",
|
||||||
maxLength: 1,
|
|
||||||
textAlign: TextAlign.center,
|
style:fontTextStyle(
|
||||||
style: fontTextStyle(14,Color(0XFF101214),FontWeight.w400),
|
16,
|
||||||
keyboardType: TextInputType.number,
|
Colors.white,
|
||||||
decoration: textFormFieldDecoration(Icons.ice_skating, ''),
|
FontWeight.w600),
|
||||||
onChanged: (value) {
|
|
||||||
if (value.isNotEmpty && index < 5) {
|
),
|
||||||
FocusScope.of(context).nextFocus();
|
|
||||||
} else if (value.isEmpty && index > 0) {
|
),
|
||||||
FocusScope.of(context).previousFocus();
|
|
||||||
}
|
),
|
||||||
},
|
|
||||||
),
|
const Spacer(),
|
||||||
);
|
|
||||||
}),
|
],
|
||||||
),
|
|
||||||
|
),
|
||||||
SizedBox(height:MediaQuery.of(context).size.height * .08,),
|
|
||||||
GestureDetector(
|
),
|
||||||
onTap: (){
|
|
||||||
|
),
|
||||||
},
|
|
||||||
child: Text('Resend code',style:fontTextStyle(12,Color(0XFF1D7AFC),FontWeight.w600),),
|
);
|
||||||
),
|
|
||||||
SizedBox(height:MediaQuery.of(context).size.height * .024,),
|
|
||||||
Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: MediaQuery.of(context).size.height * .06,
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
backgroundColor: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: () async{
|
|
||||||
AppSettings.preLoaderDialog(context);
|
|
||||||
|
|
||||||
bool isOnline = await AppSettings.internetConnectivity();
|
|
||||||
if(isOnline){
|
|
||||||
final otp = _controllers.map((controller) => controller.text).join();
|
|
||||||
|
|
||||||
if(otp.length==6){
|
|
||||||
var phoneVerifyPayload = new Map<String, dynamic>();
|
|
||||||
|
|
||||||
phoneVerifyPayload["phoneVerificationCode"] = otp.toString();
|
|
||||||
phoneVerifyPayload["phone"] = widget.mobileNumber.toString();
|
|
||||||
|
|
||||||
bool verifyPhnStatus = await AppSettings.verifyPhn(phoneVerifyPayload);
|
|
||||||
if (verifyPhnStatus) {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
//AppSettings.longSuccessToast("User SignUp Successfully");
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
new MaterialPageRoute(
|
|
||||||
builder: (__) => new PasswordTextBoxesScreen(mobileNumber: widget.mobileNumber,)));
|
|
||||||
/* await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const Login()),
|
|
||||||
);*/
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
AppSettings.longFailedToast("Phone verification failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
AppSettings.longFailedToast("Please enter 6 digit otp code");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Navigator.of(context,rootNavigator: true).pop();
|
|
||||||
AppSettings.longFailedToast("Please Check internet");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
child: Text('Continue',style:fontTextStyle(12,Color(0XFFFFFFFF),FontWeight.w600),),
|
|
||||||
)),
|
|
||||||
|
|
||||||
]),
|
|
||||||
)))),
|
|
||||||
]));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
Loading…
Reference in new issue