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 {
|
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)) {
|
if (await canLaunchUrl(url)) {
|
||||||
await launchUrl(url);
|
await launchUrl(url);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:country_code_picker/country_code_picker.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
@@ -44,6 +45,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
final typeController = TextEditingController();
|
final typeController = TextEditingController();
|
||||||
final practiceNoController = TextEditingController();
|
final practiceNoController = TextEditingController();
|
||||||
final vatNoController = TextEditingController();
|
final vatNoController = TextEditingController();
|
||||||
|
final countryCodeController = TextEditingController();
|
||||||
final contactController = TextEditingController();
|
final contactController = TextEditingController();
|
||||||
final emailController = TextEditingController();
|
final emailController = TextEditingController();
|
||||||
final locationController = TextEditingController();
|
final locationController = TextEditingController();
|
||||||
@@ -65,7 +67,8 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
practiceNoController.text,
|
practiceNoController.text,
|
||||||
vatNoController.text,
|
vatNoController.text,
|
||||||
emailController.text,
|
emailController.text,
|
||||||
contactController.text,
|
getNumberWithCountryCode(),
|
||||||
|
// contactController.text,
|
||||||
locationController.text,
|
locationController.text,
|
||||||
fileNameController.text,
|
fileNameController.text,
|
||||||
websiteController.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) {
|
void editBizProfileWindow(double width) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -204,6 +235,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
windowTitle: 'Edit Profile',
|
windowTitle: 'Edit Profile',
|
||||||
onWindowTapClose: () {
|
onWindowTapClose: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
resetControllers();
|
||||||
},
|
},
|
||||||
windowBody: MihSingleChildScroll(
|
windowBody: MihSingleChildScroll(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -302,20 +334,61 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
MihTextFormField(
|
Container(
|
||||||
fillColor: MzansiInnovationHub.of(context)!
|
width: 300,
|
||||||
.theme
|
alignment: Alignment.topLeft,
|
||||||
.secondaryColor(),
|
child: const Text(
|
||||||
inputColor: MzansiInnovationHub.of(context)!
|
"Contact Number:",
|
||||||
.theme
|
style: TextStyle(
|
||||||
.primaryColor(),
|
fontSize: 18,
|
||||||
controller: contactController,
|
fontWeight: FontWeight.bold,
|
||||||
multiLineInput: false,
|
),
|
||||||
requiredText: true,
|
),
|
||||||
hintText: "Contact Number",
|
),
|
||||||
validator: (value) {
|
Row(
|
||||||
return MihValidationServices().isEmpty(value);
|
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),
|
const SizedBox(height: 10),
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
@@ -395,7 +468,8 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
requiredText: false,
|
requiredText: false,
|
||||||
hintText: "Registration No.",
|
hintText: "Registration No.",
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return MihValidationServices().isEmpty(value);
|
// return MihValidationServices().isEmpty(value);
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
@@ -427,7 +501,8 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
requiredText: false,
|
requiredText: false,
|
||||||
hintText: "VAT Number",
|
hintText: "VAT Number",
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return MihValidationServices().isEmpty(value);
|
// return MihValidationServices().isEmpty(value);
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -556,31 +659,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
setState(() {
|
resetControllers();
|
||||||
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;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:country_code_picker/country_code_picker.dart';
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.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 titleController = TextEditingController();
|
||||||
final signtureController = TextEditingController();
|
final signtureController = TextEditingController();
|
||||||
final accessController = TextEditingController();
|
final accessController = TextEditingController();
|
||||||
|
final countryCodeController = TextEditingController();
|
||||||
final contactController = TextEditingController();
|
final contactController = TextEditingController();
|
||||||
final emailController = TextEditingController();
|
final emailController = TextEditingController();
|
||||||
final locationController = TextEditingController();
|
final locationController = TextEditingController();
|
||||||
@@ -124,7 +126,8 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
practiceNoController.text,
|
practiceNoController.text,
|
||||||
vatNoController.text,
|
vatNoController.text,
|
||||||
emailController.text,
|
emailController.text,
|
||||||
contactController.text,
|
getNumberWithCountryCode(),
|
||||||
|
// "${countryCodeController.text}-${contactController.text}",
|
||||||
locationController.text,
|
locationController.text,
|
||||||
logonameController.text,
|
logonameController.text,
|
||||||
websiteController.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() {
|
void internetConnectionPopUp() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -319,17 +334,6 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
return MihValidationServices().isEmpty(value);
|
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),
|
const SizedBox(height: 10.0),
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
fillColor: MzansiInnovationHub.of(context)!
|
fillColor: MzansiInnovationHub.of(context)!
|
||||||
@@ -347,20 +351,60 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
MihTextFormField(
|
Container(
|
||||||
fillColor: MzansiInnovationHub.of(context)!
|
width: 300,
|
||||||
.theme
|
alignment: Alignment.topLeft,
|
||||||
.secondaryColor(),
|
child: const Text(
|
||||||
inputColor: MzansiInnovationHub.of(context)!
|
"Contact Number:",
|
||||||
.theme
|
style: TextStyle(
|
||||||
.primaryColor(),
|
fontSize: 18,
|
||||||
controller: contactController,
|
fontWeight: FontWeight.bold,
|
||||||
multiLineInput: false,
|
),
|
||||||
requiredText: true,
|
),
|
||||||
hintText: "Contact Number",
|
),
|
||||||
validator: (value) {
|
Row(
|
||||||
return MihValidationServices().isEmpty(value);
|
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),
|
const SizedBox(height: 10.0),
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
|
|||||||
Reference in New Issue
Block a user