work from bae
This commit is contained in:
@@ -1,12 +1,16 @@
|
|||||||
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';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_banner_ad.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_banner_ad.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_business_profile_preview.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_personal_profile_preview.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_personal_profile_preview.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_business_card.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_business_card.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_location_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||||
@@ -28,9 +32,11 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
|||||||
|
|
||||||
class PackageToolOne extends StatefulWidget {
|
class PackageToolOne extends StatefulWidget {
|
||||||
final AppUser user;
|
final AppUser user;
|
||||||
|
final Business business;
|
||||||
const PackageToolOne({
|
const PackageToolOne({
|
||||||
super.key,
|
super.key,
|
||||||
required this.user,
|
required this.user,
|
||||||
|
required this.business,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -57,6 +63,8 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
bool switchpositioin = true;
|
bool switchpositioin = true;
|
||||||
final FocusNode searchFocusNode = FocusNode();
|
final FocusNode searchFocusNode = FocusNode();
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
late Future<Position?> myCoordinates;
|
||||||
|
String myLocation = "";
|
||||||
|
|
||||||
void showTestFullWindow() {
|
void showTestFullWindow() {
|
||||||
showDialog(
|
showDialog(
|
||||||
@@ -139,6 +147,8 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
// const NetworkImage(
|
// const NetworkImage(
|
||||||
// "https://lh3.googleusercontent.com/nW4ZZ89Q1ATz7Ht3nsAVWXL_cwNi4gNusqQZiL60UuuI3FG-VM7bTYDoJ-sUr2kDTdorfQYjxo5PjDM-0MO5rA=s512");
|
// "https://lh3.googleusercontent.com/nW4ZZ89Q1ATz7Ht3nsAVWXL_cwNi4gNusqQZiL60UuuI3FG-VM7bTYDoJ-sUr2kDTdorfQYjxo5PjDM-0MO5rA=s512");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// myCoordinates = MIHLocationAPI().getGPSPosition(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getBody(double width) {
|
Widget getBody(double width) {
|
||||||
@@ -172,10 +182,95 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Personal Preview",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
MihPersonalProfilePreview(
|
MihPersonalProfilePreview(
|
||||||
user: widget.user,
|
user: widget.user,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Business Preview",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
FutureBuilder(
|
||||||
|
future: MIHLocationAPI().getGPSPosition(context),
|
||||||
|
builder: (context, asyncSnapshot) {
|
||||||
|
// print(asyncSnapshot.connectionState);
|
||||||
|
if (asyncSnapshot.connectionState ==
|
||||||
|
ConnectionState.waiting) {
|
||||||
|
return Container(
|
||||||
|
width: 150,
|
||||||
|
height: 50,
|
||||||
|
color: Colors.black,
|
||||||
|
child: Center(child: CircularProgressIndicator()),
|
||||||
|
);
|
||||||
|
} else if (asyncSnapshot.hasError ||
|
||||||
|
!asyncSnapshot.hasData ||
|
||||||
|
asyncSnapshot.data == null) {
|
||||||
|
return Container(
|
||||||
|
width: 150,
|
||||||
|
height: 50,
|
||||||
|
color: Colors.red,
|
||||||
|
child: Center(child: Text("Location unavailable")),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final myLocation = asyncSnapshot.data
|
||||||
|
.toString()
|
||||||
|
.replaceAll("Latitude: ", "")
|
||||||
|
.replaceAll("Longitude: ", "");
|
||||||
|
print("My Location is this: $myLocation");
|
||||||
|
return MihBusinessProfilePreview(
|
||||||
|
business: widget.business,
|
||||||
|
myLocation: myLocation,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// // print(asyncSnapshot.requireData);
|
||||||
|
// if (asyncSnapshot.connectionState ==
|
||||||
|
// ConnectionState.done &&
|
||||||
|
// asyncSnapshot.hasData) {
|
||||||
|
// print(asyncSnapshot.requireData);
|
||||||
|
// myLocation = asyncSnapshot.requireData.toString();
|
||||||
|
// return MihBusinessProfilePreview(
|
||||||
|
// business: widget.business,
|
||||||
|
// myLocation: myLocation,
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// return Container(
|
||||||
|
// width: 150,
|
||||||
|
// height: 50,
|
||||||
|
// color: Colors.black,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
}),
|
||||||
|
const SizedBox(height: 10),
|
||||||
MihBusinessCard(
|
MihBusinessCard(
|
||||||
businessName: "Mzansi Innovation Hub",
|
businessName: "Mzansi Innovation Hub",
|
||||||
cellNumber: "0788300006",
|
cellNumber: "0788300006",
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_location_services.dart';
|
||||||
|
|
||||||
|
class MihBusinessProfilePreview extends StatefulWidget {
|
||||||
|
final Business business;
|
||||||
|
final String myLocation;
|
||||||
|
const MihBusinessProfilePreview({
|
||||||
|
super.key,
|
||||||
|
required this.business,
|
||||||
|
required this.myLocation,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihBusinessProfilePreview> createState() =>
|
||||||
|
_MihBusinessProfilePreviewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihBusinessProfilePreviewState extends State<MihBusinessProfilePreview> {
|
||||||
|
late Future<String> futureImageUrl;
|
||||||
|
PlatformFile? file;
|
||||||
|
|
||||||
|
String calculateDistance() {
|
||||||
|
double distanceInKm = MIHLocationAPI().getDistanceInMeaters(
|
||||||
|
widget.myLocation, widget.business.gps_location) /
|
||||||
|
1000;
|
||||||
|
return "${distanceInKm.toStringAsFixed(2)} km";
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
futureImageUrl =
|
||||||
|
MihFileApi.getMinioFileUrl(widget.business.logo_path, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
double profilePictureWidth = 60;
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
FutureBuilder(
|
||||||
|
future: futureImageUrl,
|
||||||
|
builder: (context, asyncSnapshot) {
|
||||||
|
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||||
|
asyncSnapshot.hasData) {
|
||||||
|
return MihCircleAvatar(
|
||||||
|
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||||
|
width: profilePictureWidth,
|
||||||
|
editable: false,
|
||||||
|
fileNameController: TextEditingController(),
|
||||||
|
userSelectedfile: file,
|
||||||
|
frameColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
backgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
onChange: () {},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Icon(
|
||||||
|
MihIcons.mihLogo,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.business.Name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
calculateDistance(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,7 +64,7 @@ class _MihPersonalProfilePreviewState extends State<MihPersonalProfilePreview> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"@${widget.user.username}",
|
widget.user.username,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
|
|||||||
@@ -902,8 +902,8 @@ class _MIHHomeLegacyState extends State<MIHHomeLegacy> {
|
|||||||
MIHLocationAPI().getGPSPosition(context).then((position) {
|
MIHLocationAPI().getGPSPosition(context).then((position) {
|
||||||
if (position != null) {
|
if (position != null) {
|
||||||
print(position);
|
print(position);
|
||||||
print(
|
// print(
|
||||||
"Distance: ${MIHLocationAPI().getDistanceInMeaters(position, position)}m");
|
// "Distance: ${MIHLocationAPI().getDistanceInMeaters(position, position)}m");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -162,7 +162,10 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
'/package-dev',
|
'/package-dev',
|
||||||
arguments: widget.signedInUser,
|
arguments: TestArguments(
|
||||||
|
widget.signedInUser,
|
||||||
|
widget.business,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
appName: "Test",
|
appName: "Test",
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
),
|
),
|
||||||
FittedBox(
|
FittedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
"@${widget.arguments.signedInUser.username}",
|
widget.arguments.signedInUser.username,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 35,
|
fontSize: 35,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|||||||
@@ -39,9 +39,13 @@ class MIHLocationAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double getDistanceInMeaters(Position startPosition, Position endPosition) {
|
double getDistanceInMeaters(String startPosition, String endPosition) {
|
||||||
return Geolocator.distanceBetween(startPosition.latitude,
|
double startLatitude = double.parse(startPosition.split(", ")[0]);
|
||||||
startPosition.longitude, endPosition.latitude, endPosition.longitude);
|
double startLogitude = double.parse(startPosition.split(", ")[1]);
|
||||||
|
double endLatitude = double.parse(endPosition.split(", ")[0]);
|
||||||
|
double endLogitude = double.parse(endPosition.split(", ")[1]);
|
||||||
|
return Geolocator.distanceBetween(
|
||||||
|
startLatitude, startLogitude, endLatitude, endLogitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showPermissionError(BuildContext context) {
|
void showPermissionError(BuildContext context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user