forked from yaso_meth/mih-project
use country copde picker and set contatc no field to number only
This commit is contained in:
@@ -40,7 +40,8 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
}
|
||||
|
||||
Future<void> _makePhoneCall(String phoneNumber) async {
|
||||
final Uri url = Uri(scheme: 'tel', path: phoneNumber);
|
||||
String formattedNumber = phoneNumber.replaceAll("-", "");
|
||||
final Uri url = Uri(scheme: 'tel', path: formattedNumber);
|
||||
if (await canLaunchUrl(url)) {
|
||||
await launchUrl(url);
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:country_code_picker/country_code_picker.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
@@ -44,6 +45,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
final typeController = TextEditingController();
|
||||
final practiceNoController = TextEditingController();
|
||||
final vatNoController = TextEditingController();
|
||||
final countryCodeController = TextEditingController();
|
||||
final contactController = TextEditingController();
|
||||
final emailController = TextEditingController();
|
||||
final locationController = TextEditingController();
|
||||
@@ -65,7 +67,8 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
practiceNoController.text,
|
||||
vatNoController.text,
|
||||
emailController.text,
|
||||
contactController.text,
|
||||
getNumberWithCountryCode(),
|
||||
// contactController.text,
|
||||
locationController.text,
|
||||
fileNameController.text,
|
||||
websiteController.text,
|
||||
@@ -196,6 +199,34 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
}
|
||||
}
|
||||
|
||||
void setContactNumberControllers() {
|
||||
if (widget.arguments.business!.contact_no[0] == "+") {
|
||||
List<String> contactDetails =
|
||||
widget.arguments.business!.contact_no.split("-");
|
||||
setState(() {
|
||||
countryCodeController.text = contactDetails[0];
|
||||
contactController.text = contactDetails[1];
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
countryCodeController.text = "+27";
|
||||
contactController.text = widget.arguments.business!.contact_no;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String getNumberWithCountryCode() {
|
||||
String numberWithoutBeginingZero = "";
|
||||
if (contactController.text[0] == "0") {
|
||||
numberWithoutBeginingZero = contactController.text
|
||||
.replaceAll(" ", "")
|
||||
.substring(1, contactController.text.length);
|
||||
} else {
|
||||
numberWithoutBeginingZero = contactController.text.replaceAll("-", " ");
|
||||
}
|
||||
return "${countryCodeController.text}-$numberWithoutBeginingZero";
|
||||
}
|
||||
|
||||
void editBizProfileWindow(double width) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -204,6 +235,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
windowTitle: 'Edit Profile',
|
||||
onWindowTapClose: () {
|
||||
Navigator.of(context).pop();
|
||||
resetControllers();
|
||||
},
|
||||
windowBody: MihSingleChildScroll(
|
||||
child: Padding(
|
||||
@@ -302,20 +334,61 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.secondaryColor(),
|
||||
inputColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
controller: contactController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Contact Number",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
Container(
|
||||
width: 300,
|
||||
alignment: Alignment.topLeft,
|
||||
child: const Text(
|
||||
"Contact Number:",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
CountryCodePicker(
|
||||
padding: EdgeInsetsGeometry.all(0),
|
||||
onChanged: (selectedCode) {
|
||||
setState(() {
|
||||
countryCodeController.text =
|
||||
selectedCode.toString();
|
||||
});
|
||||
debugPrint(
|
||||
"Selected Country Code: ${countryCodeController.text}");
|
||||
},
|
||||
initialSelection: countryCodeController.text,
|
||||
showDropDownButton: false,
|
||||
pickerStyle: PickerStyle.bottomSheet,
|
||||
dialogBackgroundColor:
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
barrierColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
),
|
||||
Expanded(
|
||||
child: MihTextFormField(
|
||||
fillColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.secondaryColor(),
|
||||
inputColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
controller: contactController,
|
||||
numberMode: true,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: null,
|
||||
validator: (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
@@ -395,7 +468,8 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
requiredText: false,
|
||||
hintText: "Registration No.",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
// return MihValidationServices().isEmpty(value);
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
@@ -427,7 +501,8 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
requiredText: false,
|
||||
hintText: "VAT Number",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
// return MihValidationServices().isEmpty(value);
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
@@ -535,6 +610,34 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
}
|
||||
}
|
||||
|
||||
void resetControllers() {
|
||||
setState(() {
|
||||
fileNameController.text =
|
||||
widget.arguments.business!.logo_path.split("/").last;
|
||||
regController.text = widget.arguments.business!.registration_no;
|
||||
nameController.text = widget.arguments.business!.Name;
|
||||
typeController.text = widget.arguments.business!.type;
|
||||
practiceNoController.text = widget.arguments.business!.practice_no;
|
||||
vatNoController.text = widget.arguments.business!.vat_no;
|
||||
emailController.text = widget.arguments.business!.bus_email;
|
||||
locationController.text = widget.arguments.business!.gps_location;
|
||||
websiteController.text = widget.arguments.business!.website;
|
||||
ratingController.text = widget.arguments.business!.rating;
|
||||
missionVisionController.text = widget.arguments.business!.mission_vision;
|
||||
});
|
||||
setContactNumberControllers();
|
||||
if (AppEnviroment.getEnv() == "Prod") {
|
||||
env = "Prod";
|
||||
} else {
|
||||
env = "Dev";
|
||||
}
|
||||
missionVisionController.addListener(() {
|
||||
setState(() {
|
||||
_counter.value = missionVisionController.text.characters.length;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
@@ -556,31 +659,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
setState(() {
|
||||
fileNameController.text =
|
||||
widget.arguments.business!.logo_path.split("/").last;
|
||||
regController.text = widget.arguments.business!.registration_no;
|
||||
nameController.text = widget.arguments.business!.Name;
|
||||
typeController.text = widget.arguments.business!.type;
|
||||
practiceNoController.text = widget.arguments.business!.practice_no;
|
||||
vatNoController.text = widget.arguments.business!.vat_no;
|
||||
contactController.text = widget.arguments.business!.contact_no;
|
||||
emailController.text = widget.arguments.business!.bus_email;
|
||||
locationController.text = widget.arguments.business!.gps_location;
|
||||
websiteController.text = widget.arguments.business!.website;
|
||||
ratingController.text = widget.arguments.business!.rating;
|
||||
missionVisionController.text = widget.arguments.business!.mission_vision;
|
||||
});
|
||||
if (AppEnviroment.getEnv() == "Prod") {
|
||||
env = "Prod";
|
||||
} else {
|
||||
env = "Dev";
|
||||
}
|
||||
missionVisionController.addListener(() {
|
||||
setState(() {
|
||||
_counter.value = missionVisionController.text.characters.length;
|
||||
});
|
||||
});
|
||||
resetControllers();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:country_code_picker/country_code_picker.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
@@ -51,6 +52,7 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
final titleController = TextEditingController();
|
||||
final signtureController = TextEditingController();
|
||||
final accessController = TextEditingController();
|
||||
final countryCodeController = TextEditingController();
|
||||
final contactController = TextEditingController();
|
||||
final emailController = TextEditingController();
|
||||
final locationController = TextEditingController();
|
||||
@@ -124,7 +126,8 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
practiceNoController.text,
|
||||
vatNoController.text,
|
||||
emailController.text,
|
||||
contactController.text,
|
||||
getNumberWithCountryCode(),
|
||||
// "${countryCodeController.text}-${contactController.text}",
|
||||
locationController.text,
|
||||
logonameController.text,
|
||||
websiteController.text,
|
||||
@@ -141,6 +144,18 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
}
|
||||
}
|
||||
|
||||
String getNumberWithCountryCode() {
|
||||
String numberWithoutBeginingZero = "";
|
||||
if (contactController.text[0] == "0") {
|
||||
numberWithoutBeginingZero = contactController.text
|
||||
.replaceAll(" ", "")
|
||||
.substring(1, contactController.text.length);
|
||||
} else {
|
||||
numberWithoutBeginingZero = contactController.text.replaceAll("-", " ");
|
||||
}
|
||||
return "${countryCodeController.text}-$numberWithoutBeginingZero";
|
||||
}
|
||||
|
||||
void internetConnectionPopUp() {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -319,17 +334,6 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
// MihDropdownField(
|
||||
// controller: typeController,
|
||||
// hintText: "Business Type",
|
||||
// dropdownOptions: const ["Doctors Office", "Other"],
|
||||
// editable: true,
|
||||
// enableSearch: true,
|
||||
// validator: (value) {
|
||||
// return MihValidationServices().isEmpty(value);
|
||||
// },
|
||||
// requiredText: true,
|
||||
// ),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MzansiInnovationHub.of(context)!
|
||||
@@ -347,20 +351,60 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.secondaryColor(),
|
||||
inputColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
controller: contactController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Contact Number",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
Container(
|
||||
width: 300,
|
||||
alignment: Alignment.topLeft,
|
||||
child: const Text(
|
||||
"Contact Number:",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
CountryCodePicker(
|
||||
padding: EdgeInsetsGeometry.all(0),
|
||||
onChanged: (selectedCode) {
|
||||
setState(() {
|
||||
countryCodeController.text =
|
||||
selectedCode.toString();
|
||||
});
|
||||
debugPrint(
|
||||
"Selected Country Code: ${countryCodeController.text}");
|
||||
},
|
||||
initialSelection: '+27',
|
||||
showDropDownButton: false,
|
||||
pickerStyle: PickerStyle.bottomSheet,
|
||||
dialogBackgroundColor:
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
barrierColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
),
|
||||
Expanded(
|
||||
child: MihTextFormField(
|
||||
fillColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.secondaryColor(),
|
||||
inputColor: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
controller: contactController,
|
||||
numberMode: true,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: null,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
|
||||
Reference in New Issue
Block a user