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.
130 lines
4.2 KiB
Dart
130 lines
4.2 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/models/user/basic_otp.dart';
|
|
import 'package:car_customer_app/models/user/register_user.dart';
|
|
import 'package:car_customer_app/utils/navigator.dart';
|
|
import 'package:car_customer_app/utils/utils.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:car_customer_app/extensions/widget_extensions.dart';
|
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
|
import 'package:car_customer_app/widgets/txt_field.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class CompleteProfilePage extends StatefulWidget {
|
|
RegisterUser user;
|
|
|
|
CompleteProfilePage(this.user);
|
|
|
|
@override
|
|
State<CompleteProfilePage> createState() => _CompleteProfilePageState();
|
|
}
|
|
|
|
class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
String? firstName = "", lastName = "", email = "", password = "", confirmPassword = "";
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: appBar(title: "Sign Up"),
|
|
body: Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(40),
|
|
child: Column(
|
|
children: [
|
|
"Complete Profile".toText24(),
|
|
12.height,
|
|
|
|
TxtField(
|
|
hint: "First Name",
|
|
onChanged: (v) {
|
|
firstName = v;
|
|
},
|
|
),
|
|
12.height,
|
|
TxtField(
|
|
hint: "Surname",
|
|
onChanged: (v) {
|
|
lastName = v;
|
|
},
|
|
),
|
|
12.height,
|
|
TxtField(
|
|
hint: "Email",
|
|
onChanged: (v) {
|
|
email = v;
|
|
},
|
|
),
|
|
12.height,
|
|
TxtField(
|
|
hint: "Create Password",
|
|
isPasswordEnabled: true,
|
|
maxLines: 1,
|
|
onChanged: (v) {
|
|
password = v;
|
|
},
|
|
),
|
|
12.height,
|
|
TxtField(
|
|
hint: "Confirm Password",
|
|
isPasswordEnabled: true,
|
|
maxLines: 1,
|
|
onChanged: (v) {
|
|
confirmPassword = v;
|
|
},
|
|
),
|
|
// 12.height,
|
|
// TxtField(
|
|
// hint: "Phone Number",
|
|
// ),
|
|
50.height,
|
|
"By creating an account you agree to our Terms of Service and Privacy Policy".toText12(),
|
|
16.height,
|
|
ShowFillButton(
|
|
title: "Continue",
|
|
width: double.infinity,
|
|
onPressed: () {
|
|
performCompleteProfile();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> performCompleteProfile() async {
|
|
if (password == confirmPassword) {
|
|
print(widget.user.data!.userId??"userId");
|
|
Utils.showLoading(context);
|
|
RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!);
|
|
Utils.hideLoading(context);
|
|
if (user.messageStatus == 1) {
|
|
Utils.showToast( "Successfully Registered, Please login once");
|
|
pop(context);
|
|
// navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user);
|
|
} else {
|
|
Utils.showToast(user.message ?? "");
|
|
}
|
|
} else {
|
|
Utils.showToast("Please enter same password");
|
|
}
|
|
}
|
|
}
|