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.
192 lines
7.5 KiB
Dart
192 lines
7.5 KiB
Dart
import 'package:mc_common_app/classes/app_state.dart';
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
import 'package:mc_common_app/models/user_models/country.dart';
|
|
import 'package:mc_common_app/utils/utils.dart';
|
|
import 'package:mc_common_app/view_models/user_view_model.dart';
|
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
|
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../../theme/colors.dart';
|
|
|
|
class RegisterCustomerPage extends StatefulWidget {
|
|
const RegisterCustomerPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<RegisterCustomerPage> createState() => _RegisterPageState();
|
|
}
|
|
|
|
class _RegisterPageState extends State<RegisterCustomerPage> {
|
|
String phoneNum = "", countryCode = "";
|
|
|
|
int role = 4, countryId = -1;
|
|
|
|
TextEditingController emailController = TextEditingController();
|
|
|
|
DropValue? selectedDrop;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final UserVM userVM = context.read<UserVM>();
|
|
return Scaffold(
|
|
appBar: CustomAppBar(isRemoveBackButton: true, title: ""),
|
|
body: Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
padding: const EdgeInsets.all(20),
|
|
child: SingleChildScrollView(
|
|
child: SizedBox(
|
|
height: MediaQuery.of(context).size.height,
|
|
child: Column(
|
|
children: [
|
|
12.height,
|
|
LocaleKeys.signUp.tr().toText(
|
|
fontSize: 20,
|
|
letterSpacing: -1.44,
|
|
),
|
|
20.height,
|
|
LocaleKeys.enterPhoneNumber.tr().toText(
|
|
color: MyColors.lightTextColor,
|
|
textAlign: TextAlign.center,
|
|
fontSize: 14,
|
|
height: 23 / 24,
|
|
letterSpacing: -0.48,
|
|
),
|
|
30.height,
|
|
FutureBuilder<Country>(
|
|
future: userVM.getAllCountries(),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.hasData) {
|
|
List<DropValue> dropList = [];
|
|
snapshot.data?.data?.forEach((element) {
|
|
dropList.add(DropValue(element.id ?? 0,
|
|
EasyLocalization.of(context)?.currentLocale?.countryCode == "SA" ? "${element.countryNameN ?? ""} ${element.countryCode ?? ""}" : "${element.countryName ?? ""} ${element.countryCode ?? ""}", element.countryCode ?? ""));
|
|
});
|
|
return Column(
|
|
children: [
|
|
LocaleKeys.selectYourCountry.tr().toText(
|
|
color: MyColors.lightTextColor,
|
|
textAlign: TextAlign.center,
|
|
fontSize: 14,
|
|
height: 23 / 24,
|
|
letterSpacing: -0.48,
|
|
),
|
|
10.height,
|
|
DropdownField(
|
|
dropdownValue: selectedDrop,
|
|
(DropValue value) {
|
|
print("========");
|
|
selectedDrop = value;
|
|
AppState().setUserRegisterCountrySelection = value;
|
|
setState(() {
|
|
countryCode = value.subValue;
|
|
countryId = value.id;
|
|
});
|
|
},
|
|
list: dropList,
|
|
hint: LocaleKeys.chooseCountry.tr(),
|
|
),
|
|
],
|
|
);
|
|
} else {
|
|
return const CircularProgressIndicator();
|
|
}
|
|
},
|
|
),
|
|
18.height,
|
|
LocaleKeys.enterPhoneForVerfication.tr().toText(
|
|
color: MyColors.lightTextColor,
|
|
textAlign: TextAlign.center,
|
|
fontSize: 14,
|
|
height: 23 / 24,
|
|
letterSpacing: -0.48,
|
|
),
|
|
10.height,
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Utils.mExp(1),
|
|
Expanded(
|
|
flex: 3,
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
(countryCode.isEmpty ? "+00" : "+" + countryCode),
|
|
style: const TextStyle(
|
|
fontSize: 20,
|
|
color: MyColors.black,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const Text(
|
|
" | ",
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
color: MyColors.black,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Flexible(
|
|
child: TextField(
|
|
controller: emailController,
|
|
onChanged: (v) {
|
|
phoneNum = v;
|
|
},
|
|
style: const TextStyle(
|
|
fontSize: 20,
|
|
color: MyColors.black,
|
|
),
|
|
decoration: const InputDecoration(
|
|
hintStyle: TextStyle(color: MyColors.lightTextColor, fontSize: 20),
|
|
hintText: "546758594",
|
|
contentPadding: EdgeInsets.zero,
|
|
border: InputBorder.none,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Utils.mExp(1),
|
|
],
|
|
),
|
|
40.height,
|
|
ShowFillButton(
|
|
title: LocaleKeys.continu.tr(),
|
|
maxWidth: double.infinity,
|
|
onPressed: () {
|
|
if (validation()) userVM.performBasicOtpRegisterPage(context, countryCode: countryCode, phoneNum: phoneNum, role: role);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
bool validation() {
|
|
bool isValid = true;
|
|
if (role == -1) {
|
|
Utils.showToast(LocaleKeys.selectProviderRole.tr());
|
|
//("Please select Provider Role");
|
|
isValid = false;
|
|
} else if (countryCode.isEmpty) {
|
|
Utils.showToast(LocaleKeys.selectCountryCode.tr());
|
|
//("Please select Country Code");
|
|
isValid = false;
|
|
} else if (phoneNum.isEmpty) {
|
|
Utils.showToast(LocaleKeys.addPhoneNo.tr());
|
|
//("Please add Phone No");
|
|
isValid = false;
|
|
}
|
|
return isValid;
|
|
}
|
|
}
|