|
|
|
|
@ -2,7 +2,8 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
import 'package:supplier_new/signup/verification_screen.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
|
import 'package:geocoding/geocoding.dart';
|
|
|
|
|
import '../common/settings.dart';
|
|
|
|
|
|
|
|
|
|
class SignUp extends StatefulWidget {
|
|
|
|
|
@ -17,6 +18,8 @@ class SignUp extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _SignUpState extends State<SignUp> {
|
|
|
|
|
double? latitude;
|
|
|
|
|
double? longitude;
|
|
|
|
|
final TextEditingController businessNameController = TextEditingController();
|
|
|
|
|
final TextEditingController registrationNumberController = TextEditingController();
|
|
|
|
|
final TextEditingController yearsInBusinessController = TextEditingController();
|
|
|
|
|
@ -38,11 +41,55 @@ class _SignUpState extends State<SignUp> {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Future<void> getLocationFromMap() async {
|
|
|
|
|
|
|
|
|
|
bool serviceEnabled;
|
|
|
|
|
LocationPermission permission;
|
|
|
|
|
|
|
|
|
|
serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
|
|
|
|
if (!serviceEnabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
permission = await Geolocator.checkPermission();
|
|
|
|
|
|
|
|
|
|
if (permission == LocationPermission.denied) {
|
|
|
|
|
permission = await Geolocator.requestPermission();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Position position = await Geolocator.getCurrentPosition(
|
|
|
|
|
desiredAccuracy: LocationAccuracy.high);
|
|
|
|
|
|
|
|
|
|
/// Save latitude & longitude
|
|
|
|
|
latitude = position.latitude;
|
|
|
|
|
longitude = position.longitude;
|
|
|
|
|
|
|
|
|
|
List<Placemark> placemarks =
|
|
|
|
|
await placemarkFromCoordinates(latitude!, longitude!);
|
|
|
|
|
|
|
|
|
|
Placemark place = placemarks[0];
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
|
|
addressLine1Controller.text =
|
|
|
|
|
"${place.street}, ${place.subLocality}";
|
|
|
|
|
|
|
|
|
|
addressLine2Controller.text = place.locality ?? "";
|
|
|
|
|
|
|
|
|
|
cityController.text = place.locality ?? "";
|
|
|
|
|
|
|
|
|
|
stateController.text = place.administrativeArea ?? "";
|
|
|
|
|
|
|
|
|
|
zipController.text = place.postalCode ?? "";
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
mobileNumberController.text = widget.mobileNumber ?? '';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -99,7 +146,7 @@ class _SignUpState extends State<SignUp> {
|
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
|
|
|
|
|
|
_buildTextField('Primary Contact Name *', 'Full Name',contactNameController),
|
|
|
|
|
_buildTextField('Position/Title *', 'Job title',positionController),
|
|
|
|
|
// _buildTextField('Position/Title *', 'Job title',positionController),
|
|
|
|
|
_buildTextField('Mobile Number *', 'Mobile Number',mobileNumberController,readOnly: true),
|
|
|
|
|
_buildTextField('Additional Mobile Number', 'Alternate Number',additionalMobileController),
|
|
|
|
|
_buildTextField('Email Address', 'Email Address',emailController),
|
|
|
|
|
@ -119,22 +166,28 @@ class _SignUpState extends State<SignUp> {
|
|
|
|
|
|
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 45.0), // Add space on the left
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Image.asset(
|
|
|
|
|
'images/maps.png',
|
|
|
|
|
width: 20,
|
|
|
|
|
height: 20,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
Text(
|
|
|
|
|
"Add Location from Maps",
|
|
|
|
|
style: fontTextStyle(14, Color(0xFF2D2E30),FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
padding: const EdgeInsets.only(left: 45.0),
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
getLocationFromMap();
|
|
|
|
|
},
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Image.asset(
|
|
|
|
|
'images/maps.png',
|
|
|
|
|
width: 20,
|
|
|
|
|
height: 20,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
Text(
|
|
|
|
|
"Add Location from Maps",
|
|
|
|
|
style: fontTextStyle(
|
|
|
|
|
14, const Color(0xFF2D2E30), FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
SizedBox(
|
|
|
|
|
@ -146,7 +199,6 @@ class _SignUpState extends State<SignUp> {
|
|
|
|
|
yearsInBusinessController.text != ''&&
|
|
|
|
|
contactNameController.text != ''&&
|
|
|
|
|
mobileNumberController.text != ''&&
|
|
|
|
|
positionController.text != ''&&
|
|
|
|
|
addressLine1Controller.text != ''&&
|
|
|
|
|
addressLine2Controller.text != ''&&
|
|
|
|
|
cityController.text != ''&&
|
|
|
|
|
@ -175,8 +227,8 @@ class _SignUpState extends State<SignUp> {
|
|
|
|
|
payload["state"] = stateController.text.toString();
|
|
|
|
|
payload["zip"] = zipController.text.toString();
|
|
|
|
|
payload["country"] = '';
|
|
|
|
|
payload["latitude"] = 0;
|
|
|
|
|
payload["longitude"] = 0;
|
|
|
|
|
payload["latitude"] = latitude ?? 0;
|
|
|
|
|
payload["longitude"] = longitude ?? 0;
|
|
|
|
|
payload["fcmId"] = fcmToken;
|
|
|
|
|
payload["description"] ='';
|
|
|
|
|
payload["bussinessname"] = businessNameController.text.toString();
|
|
|
|
|
|