You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
4.1 KiB
Dart
124 lines
4.1 KiB
Dart
|
|
|
|
|
|
|
|
import 'package:car_customer_app/api/user_api_client.dart';
|
|
import 'package:car_customer_app/classes/utils.dart';
|
|
import 'package:car_customer_app/config/routes.dart';
|
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
|
import 'package:car_customer_app/models/user/change_mobile.dart';
|
|
import 'package:car_customer_app/models/user/confirm_mobile.dart';
|
|
import 'package:car_customer_app/models/user/confirm_password.dart';
|
|
import 'package:car_customer_app/utils/navigator.dart';
|
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
|
import 'package:car_customer_app/widgets/dialog/dialogs.dart';
|
|
import 'package:car_customer_app/widgets/dialog/message_dialog.dart';
|
|
import 'package:car_customer_app/widgets/dialog/otp_dialog.dart';
|
|
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'dart:convert';
|
|
import 'package:http/http.dart';
|
|
|
|
class ChangeMobilePage extends StatefulWidget {
|
|
|
|
@override
|
|
State<ChangeMobilePage> createState() => _ChangeMobilePageState();
|
|
}
|
|
|
|
class _ChangeMobilePageState extends State<ChangeMobilePage> {
|
|
int countryID=1 ;
|
|
String mobileNo = '';
|
|
String password = '';
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: appBar(title: "Change Mobile Number"),
|
|
body: SingleChildScrollView(
|
|
child: Container(
|
|
// width: double.infinity,
|
|
// height: double.infinity,
|
|
padding: EdgeInsets.all(40),
|
|
child: Column(
|
|
children: [
|
|
"Enter New Phone Number".toText24(),
|
|
12.height,
|
|
TextFormField(
|
|
decoration: InputDecoration(
|
|
hintText: "Enter New Phone Number",
|
|
hintStyle: TextStyle(color: Colors.grey),
|
|
border: OutlineInputBorder(
|
|
borderRadius: const BorderRadius.all(
|
|
const Radius.circular(5.0),
|
|
),
|
|
),
|
|
),
|
|
obscureText: false,
|
|
onChanged: (v) => mobileNo = v,
|
|
),
|
|
12.height,
|
|
TextFormField(
|
|
decoration: InputDecoration(
|
|
hintText: "Enter Current Password",
|
|
hintStyle: TextStyle(color: Colors.grey),
|
|
border: OutlineInputBorder(
|
|
borderRadius: const BorderRadius.all(
|
|
const Radius.circular(5.0),
|
|
),
|
|
),
|
|
),
|
|
obscureText: true,
|
|
onChanged: (v) => password = v,
|
|
),
|
|
40.height,
|
|
ShowFillButton(
|
|
title: "Confirm",
|
|
width: double.infinity,
|
|
onPressed: () {
|
|
changeMobile(context);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> changeMobile(BuildContext context) async {
|
|
Utils.showLoading(context);
|
|
ChangeMobile otpRequest = await UserApiClent().ChangeMobileNoOTPRequest(countryID, mobileNo, password);
|
|
Utils.hideLoading(context);
|
|
if (otpRequest.messageStatus == 1) {
|
|
showMDialog(context, child: OtpDialog(
|
|
onClick: (String code) async {
|
|
pop(context);
|
|
Utils.showLoading(context);
|
|
ConfirmMobile otpCompare = await UserApiClent().ChangeMobileNo(otpRequest.data!.userToken ?? "", code);
|
|
Utils.hideLoading(context);
|
|
if (otpCompare.messageStatus == 1) {
|
|
showMDialog(
|
|
context,
|
|
child: MessageDialog(
|
|
title: "Phone Number Verified",
|
|
onClick: () {
|
|
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
|
|
},
|
|
),
|
|
);
|
|
} else {
|
|
Utils.showToast(otpCompare.message ?? "");
|
|
}
|
|
},
|
|
));
|
|
} else {
|
|
Utils.showToast(otpRequest.message ?? "");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|