Merge pull request #226 from yaso-meth/NEW--Mzansi-Directory-Package
NEW--Mzansi-Directory-Package
This commit is contained in:
@@ -8,6 +8,7 @@ class AppUser {
|
|||||||
final String app_id;
|
final String app_id;
|
||||||
final String username;
|
final String username;
|
||||||
final String pro_pic_path;
|
final String pro_pic_path;
|
||||||
|
final String purpose;
|
||||||
|
|
||||||
const AppUser(
|
const AppUser(
|
||||||
this.idUser,
|
this.idUser,
|
||||||
@@ -18,6 +19,7 @@ class AppUser {
|
|||||||
this.app_id,
|
this.app_id,
|
||||||
this.username,
|
this.username,
|
||||||
this.pro_pic_path,
|
this.pro_pic_path,
|
||||||
|
this.purpose,
|
||||||
);
|
);
|
||||||
|
|
||||||
factory AppUser.fromJson(dynamic json) {
|
factory AppUser.fromJson(dynamic json) {
|
||||||
@@ -30,6 +32,7 @@ class AppUser {
|
|||||||
json['app_id'],
|
json['app_id'],
|
||||||
json['username'],
|
json['username'],
|
||||||
json['pro_pic_path'],
|
json['pro_pic_path'],
|
||||||
|
json['purpose'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,3 +217,13 @@ class MzansiAiArguments {
|
|||||||
this.startUpQuestion,
|
this.startUpQuestion,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TestArguments {
|
||||||
|
final AppUser user;
|
||||||
|
final Business? business;
|
||||||
|
|
||||||
|
TestArguments(
|
||||||
|
this.user,
|
||||||
|
this.business,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ class Business {
|
|||||||
final String gps_location;
|
final String gps_location;
|
||||||
final String practice_no;
|
final String practice_no;
|
||||||
final String vat_no;
|
final String vat_no;
|
||||||
|
final String website;
|
||||||
|
final String rating;
|
||||||
|
final String mission_vision;
|
||||||
|
|
||||||
const Business(
|
const Business(
|
||||||
this.business_id,
|
this.business_id,
|
||||||
@@ -26,6 +29,9 @@ class Business {
|
|||||||
this.gps_location,
|
this.gps_location,
|
||||||
this.practice_no,
|
this.practice_no,
|
||||||
this.vat_no,
|
this.vat_no,
|
||||||
|
this.website,
|
||||||
|
this.rating,
|
||||||
|
this.mission_vision,
|
||||||
);
|
);
|
||||||
|
|
||||||
factory Business.fromJson(dynamic json) {
|
factory Business.fromJson(dynamic json) {
|
||||||
@@ -42,6 +48,9 @@ class Business {
|
|||||||
json['gps_location'],
|
json['gps_location'],
|
||||||
json['practice_no'],
|
json['practice_no'],
|
||||||
json['vat_no'],
|
json['vat_no'],
|
||||||
|
json['website'],
|
||||||
|
json['rating'],
|
||||||
|
json['mission_vision'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,15 @@ import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart'
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class PackageTest extends StatefulWidget {
|
class PackageTest extends StatefulWidget {
|
||||||
const PackageTest({super.key});
|
// final AppUser user;
|
||||||
|
// final Business business;
|
||||||
|
final TestArguments arguments;
|
||||||
|
const PackageTest({
|
||||||
|
super.key,
|
||||||
|
required this.arguments,
|
||||||
|
// required this.user,
|
||||||
|
// required this.business,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PackageTest> createState() => _PackageTestState();
|
State<PackageTest> createState() => _PackageTestState();
|
||||||
@@ -111,7 +119,10 @@ class _PackageTestState extends State<PackageTest> {
|
|||||||
|
|
||||||
List<Widget> getToolBody() {
|
List<Widget> getToolBody() {
|
||||||
List<Widget> toolBodies = [
|
List<Widget> toolBodies = [
|
||||||
const PackageToolOne(),
|
PackageToolOne(
|
||||||
|
user: widget.arguments.user,
|
||||||
|
business: widget.arguments.business!,
|
||||||
|
),
|
||||||
const PackageToolTwo(),
|
const PackageToolTwo(),
|
||||||
];
|
];
|
||||||
return toolBodies;
|
return toolBodies;
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
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/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_packages/mzansi_profile/business_profile/components/mih_business_card.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_pop_up_messages/mih_loading_circle.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_business_info_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';
|
||||||
@@ -25,7 +32,13 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
||||||
|
|
||||||
class PackageToolOne extends StatefulWidget {
|
class PackageToolOne extends StatefulWidget {
|
||||||
const PackageToolOne({super.key});
|
final AppUser user;
|
||||||
|
final Business business;
|
||||||
|
const PackageToolOne({
|
||||||
|
super.key,
|
||||||
|
required this.user,
|
||||||
|
required this.business,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PackageToolOne> createState() => _PackageToolOneState();
|
State<PackageToolOne> createState() => _PackageToolOneState();
|
||||||
@@ -51,6 +64,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(
|
||||||
@@ -133,6 +148,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) {
|
||||||
@@ -166,6 +183,114 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
Center(
|
||||||
|
child: MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const Mihloadingcircle(
|
||||||
|
message: "Getting your profile data",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
buttonColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
elevation: 10,
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Show Loading",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
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(
|
||||||
|
user: widget.user,
|
||||||
|
),
|
||||||
|
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 MihBusinessProfilePreview(
|
||||||
|
// business: widget.business,
|
||||||
|
// myLocation: null,
|
||||||
|
// ).redacted(
|
||||||
|
// context: context,
|
||||||
|
// redact: true,
|
||||||
|
// );
|
||||||
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
const SizedBox(height: 10),
|
||||||
MihBusinessCard(
|
MihBusinessCard(
|
||||||
businessName: "Mzansi Innovation Hub",
|
businessName: "Mzansi Innovation Hub",
|
||||||
cellNumber: "0788300006",
|
cellNumber: "0788300006",
|
||||||
@@ -361,6 +486,10 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
multiLineInput: true,
|
multiLineInput: true,
|
||||||
requiredText: false,
|
requiredText: false,
|
||||||
hintText: "Enter Multi Line Text",
|
hintText: "Enter Multi Line Text",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices()
|
||||||
|
.validateLength(_textFieldFourController.text, 50);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Align(
|
Align(
|
||||||
|
|||||||
Binary file not shown.
@@ -1,10 +1,10 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Mih_Icons';
|
font-family: 'Mih_Icons';
|
||||||
src: url('fonts/Mih_Icons.eot?kmk862');
|
src: url('fonts/Mih_Icons.eot?blbuxz');
|
||||||
src: url('fonts/Mih_Icons.eot?kmk862#iefix') format('embedded-opentype'),
|
src: url('fonts/Mih_Icons.eot?blbuxz#iefix') format('embedded-opentype'),
|
||||||
url('fonts/Mih_Icons.ttf?kmk862') format('truetype'),
|
url('fonts/Mih_Icons.ttf?blbuxz') format('truetype'),
|
||||||
url('fonts/Mih_Icons.woff?kmk862') format('woff'),
|
url('fonts/Mih_Icons.woff?blbuxz') format('woff'),
|
||||||
url('fonts/Mih_Icons.svg?kmk862#Mih_Icons') format('svg');
|
url('fonts/Mih_Icons.svg?blbuxz#Mih_Icons') format('svg');
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-display: block;
|
font-display: block;
|
||||||
@@ -26,66 +26,70 @@
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-personal_profile:before {
|
.icon-mzansi_directory:before {
|
||||||
content: "\e90f";
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-notifications:before {
|
|
||||||
content: "\e90e";
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-i_dont_know:before {
|
|
||||||
content: "\e90d";
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-business_setup:before {
|
|
||||||
content: "\e90b";
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-profile_setup:before {
|
|
||||||
content: "\e90c";
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-mih_ring:before {
|
|
||||||
content: "\e90a";
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-about_mih:before {
|
|
||||||
content: "\e900";
|
content: "\e900";
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-access_control:before {
|
.icon-personal_profile:before {
|
||||||
content: "\e901";
|
content: "\e901";
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-business_profile:before {
|
.icon-about_mih:before {
|
||||||
content: "\e902";
|
content: "\e902";
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-calculator:before {
|
.icon-access_control:before {
|
||||||
content: "\e903";
|
content: "\e903";
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-calendar:before {
|
.icon-business_profile:before {
|
||||||
content: "\e904";
|
content: "\e904";
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-mih_logo:before {
|
.icon-business_setup:before {
|
||||||
content: "\e905";
|
content: "\e905";
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-mzansi_ai:before {
|
.icon-i_dont_know:before {
|
||||||
content: "\e906";
|
content: "\e906";
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-mzansi_wallet:before {
|
.icon-mih_logo:before {
|
||||||
content: "\e907";
|
content: "\e907";
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-patient_manager:before {
|
.icon-mih_ring:before {
|
||||||
content: "\e908";
|
content: "\e908";
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-patient_profile:before {
|
.icon-mzansi_ai:before {
|
||||||
content: "\e909";
|
content: "\e909";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-mzansi_wallet:before {
|
||||||
|
content: "\e90a";
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-notifications:before {
|
||||||
|
content: "\e90b";
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-patient_manager:before {
|
||||||
|
content: "\e90c";
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-patient_profile:before {
|
||||||
|
content: "\e90d";
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-profile_setup:before {
|
||||||
|
content: "\e90e";
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-calculator:before {
|
||||||
|
content: "\e940";
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-calendar:before {
|
||||||
|
content: "\e953";
|
||||||
|
}
|
||||||
@@ -30,7 +30,8 @@ class _MihBannerAdState extends State<MihBannerAd> {
|
|||||||
onAdFailedToLoad: (ad, err) {
|
onAdFailedToLoad: (ad, err) {
|
||||||
debugPrint('BannerAd failed to load: $err');
|
debugPrint('BannerAd failed to load: $err');
|
||||||
setState(() {
|
setState(() {
|
||||||
errorMessage = 'Failed to load ad: ${err.message}';
|
errorMessage =
|
||||||
|
'Failed to load ad- Message: ${err.message} Code :${err.code}';
|
||||||
});
|
});
|
||||||
ad.dispose(); // Dispose the ad to free resources
|
ad.dispose(); // Dispose the ad to free resources
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
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) {
|
||||||
|
if (asyncSnapshot.requireData != "") {
|
||||||
|
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.iDontKnow,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Icon(
|
||||||
|
MihIcons.mihRing,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.business.Name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.business.type,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.myLocation != null || widget.myLocation!.isEmpty
|
||||||
|
? calculateDistance()
|
||||||
|
: "0.00 km",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,17 +34,18 @@ class _MihCircleAvatarState extends State<MihCircleAvatar> {
|
|||||||
late ImageProvider<Object>? imagePreview;
|
late ImageProvider<Object>? imagePreview;
|
||||||
|
|
||||||
ImageProvider<Object>? getAvatar() {
|
ImageProvider<Object>? getAvatar() {
|
||||||
Color dark = const Color(0XFF3A4454);
|
// Color dark = const Color(0XFF3A4454);
|
||||||
if (widget.imageFile == null) {
|
if (widget.imageFile == null) {
|
||||||
if (widget.backgroundColor == dark) {
|
return null;
|
||||||
print("here in light icon");
|
// if (widget.backgroundColor == dark) {
|
||||||
return const AssetImage(
|
// print("here in light icon");
|
||||||
'lib/mih_components/mih_package_components/assets/images/i-dont-know-light.png');
|
// return const AssetImage(
|
||||||
} else {
|
// 'lib/mih_components/mih_package_components/assets/images/i-dont-know-light.png');
|
||||||
print("here in dark icon");
|
// } else {
|
||||||
return const AssetImage(
|
// print("here in dark icon");
|
||||||
'lib/mih_components/mih_package_components/assets/images/i-dont-know-dark.png');
|
// return const AssetImage(
|
||||||
}
|
// 'lib/mih_components/mih_package_components/assets/images/i-dont-know-dark.png');
|
||||||
|
// }
|
||||||
} else {
|
} else {
|
||||||
return widget.imageFile;
|
return widget.imageFile;
|
||||||
}
|
}
|
||||||
@@ -69,12 +70,17 @@ class _MihCircleAvatarState extends State<MihCircleAvatar> {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
Visibility(
|
||||||
|
visible: imagePreview != null,
|
||||||
|
child: CircleAvatar(
|
||||||
radius: widget.width / 2.2,
|
radius: widget.width / 2.2,
|
||||||
backgroundColor: widget.backgroundColor,
|
backgroundColor: widget.backgroundColor,
|
||||||
backgroundImage: imagePreview,
|
backgroundImage: imagePreview,
|
||||||
),
|
),
|
||||||
FittedBox(
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: imagePreview != null,
|
||||||
|
child: FittedBox(
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
size: widget.width,
|
size: widget.width,
|
||||||
@@ -82,6 +88,15 @@ class _MihCircleAvatarState extends State<MihCircleAvatar> {
|
|||||||
color: widget.frameColor,
|
color: widget.frameColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: imagePreview == null,
|
||||||
|
child: Icon(
|
||||||
|
MihIcons.iDontKnow,
|
||||||
|
size: widget.width,
|
||||||
|
color: widget.frameColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: widget.editable,
|
visible: widget.editable,
|
||||||
child: Positioned(
|
child: Positioned(
|
||||||
|
|||||||
@@ -11,48 +11,54 @@ class MihIcons {
|
|||||||
// IconData constants based on your style.css file
|
// IconData constants based on your style.css file
|
||||||
// Note: We convert the hex code from CSS (\eXXX) to an integer (0xeXXX)
|
// Note: We convert the hex code from CSS (\eXXX) to an integer (0xeXXX)
|
||||||
|
|
||||||
static const IconData aboutMih =
|
static const IconData mzansiDirectory =
|
||||||
IconData(0xe900, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe900, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData accessControl =
|
static const IconData personalProfile =
|
||||||
IconData(0xe901, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe901, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData businessProfile =
|
static const IconData aboutMih =
|
||||||
IconData(0xe902, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe902, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData calculator =
|
static const IconData accessControl =
|
||||||
IconData(0xe903, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe903, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData calendar =
|
static const IconData businessProfile =
|
||||||
IconData(0xe904, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe904, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData mihLogo =
|
static const IconData businessSetup =
|
||||||
IconData(0xe905, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe905, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData mzansiAi =
|
static const IconData iDontKnow =
|
||||||
IconData(0xe906, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe906, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData mzansiWallet =
|
static const IconData mihLogo =
|
||||||
IconData(0xe907, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe907, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData patientManager =
|
static const IconData mihRing =
|
||||||
IconData(0xe908, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe908, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData patientProfile =
|
static const IconData mzansiAi =
|
||||||
IconData(0xe909, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe909, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData mihRing =
|
static const IconData mzansiWallet =
|
||||||
IconData(0xe90a, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe90a, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData profileSetup =
|
static const IconData notifications =
|
||||||
IconData(0xe90c, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
|
||||||
|
|
||||||
static const IconData businessSetup =
|
|
||||||
IconData(0xe90b, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe90b, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData notifications =
|
static const IconData patientManager =
|
||||||
|
IconData(0xe90c, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
|
static const IconData patientProfile =
|
||||||
|
IconData(0xe90d, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
|
static const IconData profileSetup =
|
||||||
IconData(0xe90e, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe90e, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
static const IconData personalProfile =
|
static const IconData calculator =
|
||||||
IconData(0xe90f, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
IconData(0xe940, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
|
|
||||||
|
static const IconData calendar =
|
||||||
|
IconData(0xe953, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
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/app_user.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';
|
||||||
|
|
||||||
|
class MihPersonalProfilePreview extends StatefulWidget {
|
||||||
|
final AppUser user;
|
||||||
|
const MihPersonalProfilePreview({
|
||||||
|
super.key,
|
||||||
|
required this.user,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihPersonalProfilePreview> createState() =>
|
||||||
|
_MihPersonalProfilePreviewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihPersonalProfilePreviewState extends State<MihPersonalProfilePreview> {
|
||||||
|
late Future<String> futureImageUrl;
|
||||||
|
// String imageUrl = "";
|
||||||
|
PlatformFile? file;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
futureImageUrl =
|
||||||
|
MihFileApi.getMinioFileUrl(widget.user.pro_pic_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) {
|
||||||
|
if (asyncSnapshot.requireData != "") {
|
||||||
|
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.iDontKnow,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Icon(
|
||||||
|
MihIcons.mihRing,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.user.username.isNotEmpty
|
||||||
|
? widget.user.username
|
||||||
|
: "Username",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.user.fname.isNotEmpty
|
||||||
|
? "${widget.user.fname} ${widget.user.lname}"
|
||||||
|
: "Name Surname",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.user.type.toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -87,10 +87,12 @@ class _MihTextFormFieldState extends State<MihTextFormField> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isMultiline = widget.multiLineInput == true;
|
||||||
return Center(
|
return Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: widget.width,
|
width: widget.width,
|
||||||
height: widget.height,
|
// height: widget.height,
|
||||||
|
height: isMultiline ? null : widget.height,
|
||||||
child: Theme(
|
child: Theme(
|
||||||
data: Theme.of(context).copyWith(
|
data: Theme.of(context).copyWith(
|
||||||
textSelectionTheme: TextSelectionThemeData(
|
textSelectionTheme: TextSelectionThemeData(
|
||||||
|
|||||||
@@ -26,12 +26,20 @@ class _MihToggleState extends State<MihToggle> {
|
|||||||
late bool togglePosition;
|
late bool togglePosition;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void didUpdateWidget(covariant MihToggle oldWidget) {
|
||||||
super.initState();
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (widget.initialPostion != oldWidget.initialPostion) {
|
||||||
setState(() {
|
setState(() {
|
||||||
togglePosition = widget.initialPostion;
|
togglePosition = widget.initialPostion;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
togglePosition = widget.initialPostion;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -51,7 +59,7 @@ class _MihToggleState extends State<MihToggle> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Switch(
|
Switch(
|
||||||
value: widget.initialPostion,
|
value: togglePosition,
|
||||||
trackOutlineColor: WidgetStateProperty.resolveWith<Color?>(
|
trackOutlineColor: WidgetStateProperty.resolveWith<Color?>(
|
||||||
(states) {
|
(states) {
|
||||||
if (widget.readOnly == true) {
|
if (widget.readOnly == true) {
|
||||||
@@ -81,7 +89,15 @@ class _MihToggleState extends State<MihToggle> {
|
|||||||
// activeTrackColor: widget.fillColor,
|
// activeTrackColor: widget.fillColor,
|
||||||
// inactiveThumbColor: widget.fillColor,
|
// inactiveThumbColor: widget.fillColor,
|
||||||
// inactiveTrackColor: widget.secondaryFillColor,
|
// inactiveTrackColor: widget.secondaryFillColor,
|
||||||
onChanged: widget.readOnly != true ? widget.onChange : null,
|
// onChanged: widget.readOnly != true ? widget.onChange : null,
|
||||||
|
onChanged: widget.readOnly != true
|
||||||
|
? (newValue) {
|
||||||
|
setState(() {
|
||||||
|
togglePosition = newValue; // Update internal state
|
||||||
|
});
|
||||||
|
widget.onChange(newValue); // Call the parent's onChange
|
||||||
|
}
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import '../../main.dart';
|
|||||||
import 'package:gif_view/gif_view.dart';
|
import 'package:gif_view/gif_view.dart';
|
||||||
|
|
||||||
class Mihloadingcircle extends StatefulWidget {
|
class Mihloadingcircle extends StatefulWidget {
|
||||||
const Mihloadingcircle({super.key});
|
final String? message;
|
||||||
|
const Mihloadingcircle({super.key, this.message});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Mihloadingcircle> createState() => _MihloadingcircleState();
|
State<Mihloadingcircle> createState() => _MihloadingcircleState();
|
||||||
@@ -50,23 +51,45 @@ class _MihloadingcircleState extends State<Mihloadingcircle> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
|
child: IntrinsicWidth(
|
||||||
|
child: IntrinsicHeight(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(popUpPaddingSize),
|
padding: EdgeInsets.all(popUpPaddingSize),
|
||||||
width: 250,
|
// width: 250,
|
||||||
height: 250,
|
// height: 275,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
borderRadius: BorderRadius.circular(25.0),
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
width: 5.0),
|
width: 5.0),
|
||||||
),
|
),
|
||||||
child: GifView.asset(
|
child: Column(
|
||||||
MzanziInnovationHub.of(context)!.theme.loadingImageLocation(),
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
GifView.asset(
|
||||||
|
MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.loadingImageLocation(),
|
||||||
height: 200,
|
height: 200,
|
||||||
width: 200,
|
width: 200,
|
||||||
frameRate: 30,
|
frameRate: 30,
|
||||||
|
),
|
||||||
|
widget.message != null
|
||||||
|
? Text(
|
||||||
|
widget.message!,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: SizedBox(),
|
||||||
|
],
|
||||||
)),
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_print_prevew.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_print_prevew.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/arguments.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/Example/package_test.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/Example/package_test.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_notification_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_notification_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/about_mih/about_mih.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/about_mih/about_mih.dart';
|
||||||
@@ -15,9 +16,12 @@ import 'package:mzansi_innovation_hub/mih_packages/calculator/mih_calculator.dar
|
|||||||
import 'package:mzansi_innovation_hub/mih_packages/calendar/mzansi_calendar.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/calendar/mzansi_calendar.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mih_authentication/mih_authentication.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mih_authentication/mih_authentication.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_ai/mzansi_ai.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_ai/mzansi_ai.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/mzansi_directory.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/mzansi_business_profile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/mzansi_business_profile.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/mzansi_business_profile_view.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/profile_business_add.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/profile_business_add.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/mzansi_profile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/mzansi_profile.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/mzansi_profile_view.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/components/mih_barcode_scanner.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/components/mih_barcode_scanner.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/mih_wallet.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/mih_wallet.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_manager/pat_manager.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_manager/pat_manager.dart';
|
||||||
@@ -44,16 +48,18 @@ class AppRoutes {
|
|||||||
static const String forgotPassword = '/forgot-password';
|
static const String forgotPassword = '/forgot-password';
|
||||||
static const String aboutMih = '/about';
|
static const String aboutMih = '/about';
|
||||||
static const String mzansiProfile = '/mzansi-profile';
|
static const String mzansiProfile = '/mzansi-profile';
|
||||||
|
static const String mzansiProfileView = '/mzansi-profile/view';
|
||||||
static const String businessProfileSetup = '/business-profile/set-up';
|
static const String businessProfileSetup = '/business-profile/set-up';
|
||||||
static const String businessProfileManage = '/business-profile/manage';
|
static const String businessProfileManage = '/business-profile/manage';
|
||||||
|
static const String businessProfileView = '/business-profile/view';
|
||||||
static const String patientProfile = '/patient-profile';
|
static const String patientProfile = '/patient-profile';
|
||||||
static const String patientProfileSetup = '/patient-profile/set-up';
|
static const String patientProfileSetup = '/patient-profile/set-up';
|
||||||
static const String patientProfileEdit = '/patient-profile/edit';
|
static const String patientProfileEdit = '/patient-profile/edit';
|
||||||
static const String mzansiWallet = '/mzansi-wallet';
|
static const String mzansiWallet = '/mzansi-wallet';
|
||||||
|
static const String mzansiDirectory = '/mzansi-directory';
|
||||||
static const String mihAccess = '/mih-access';
|
static const String mihAccess = '/mih-access';
|
||||||
static const String calendar = '/calendar';
|
static const String calendar = '/calendar';
|
||||||
static const String appointments =
|
static const String appointments = '/appointments';
|
||||||
'/appointments'; // Consider unifying with /calendar
|
|
||||||
static const String patientManager = '/patient-manager';
|
static const String patientManager = '/patient-manager';
|
||||||
static const String patientManagerPatient = '/patient-manager/patient';
|
static const String patientManagerPatient = '/patient-manager/patient';
|
||||||
static const String fileViewer = '/file-veiwer';
|
static const String fileViewer = '/file-veiwer';
|
||||||
@@ -115,6 +121,14 @@ class RouteGenerator {
|
|||||||
);
|
);
|
||||||
// }
|
// }
|
||||||
// break; // Use break and fall through to _errorRoute if argument type is wrong
|
// break; // Use break and fall through to _errorRoute if argument type is wrong
|
||||||
|
case AppRoutes.mzansiDirectory:
|
||||||
|
// if (args is AuthArguments) {
|
||||||
|
return MaterialPageRoute(
|
||||||
|
settings: settings,
|
||||||
|
builder: (_) => MzansiDirectory(),
|
||||||
|
);
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
case AppRoutes.notifications:
|
case AppRoutes.notifications:
|
||||||
if (args is NotificationArguments) {
|
if (args is NotificationArguments) {
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
@@ -146,6 +160,15 @@ class RouteGenerator {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AppRoutes.mzansiProfileView:
|
||||||
|
if (args is AppUser) {
|
||||||
|
return MaterialPageRoute(
|
||||||
|
settings: settings,
|
||||||
|
builder: (_) => MzansiProfileView(user: args),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case AppRoutes.businessProfileSetup:
|
case AppRoutes.businessProfileSetup:
|
||||||
if (args is AppUser) {
|
if (args is AppUser) {
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
@@ -164,6 +187,15 @@ class RouteGenerator {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AppRoutes.businessProfileView:
|
||||||
|
if (args is Business) {
|
||||||
|
return MaterialPageRoute(
|
||||||
|
settings: settings,
|
||||||
|
builder: (_) => MzansiBusinessProfileView(business: args),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case AppRoutes.patientProfile:
|
case AppRoutes.patientProfile:
|
||||||
if (args is PatientViewArguments) {
|
if (args is PatientViewArguments) {
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
@@ -288,11 +320,13 @@ class RouteGenerator {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AppRoutes.packageDevTest:
|
case AppRoutes.packageDevTest:
|
||||||
// No arguments expected for this test route
|
if (args is TestArguments) {
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
settings: settings,
|
settings: settings,
|
||||||
builder: (_) => const PackageTest(),
|
builder: (_) => PackageTest(arguments: args),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// If no match is found, fall through to the error route
|
// If no match is found, fall through to the error route
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class _AboutMihState extends State<AboutMih> {
|
|||||||
"About",
|
"About",
|
||||||
"Privacy Policy",
|
"Privacy Policy",
|
||||||
"Terms of Service",
|
"Terms of Service",
|
||||||
"Attributes",
|
"Attributions",
|
||||||
];
|
];
|
||||||
return toolTitles;
|
return toolTitles;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,11 +99,11 @@ class _MihAttributesState extends State<MihAttributes> {
|
|||||||
|
|
||||||
Widget getBody() {
|
Widget getBody() {
|
||||||
String message =
|
String message =
|
||||||
"Some APIs, Icons and Assets used in this MIH were sourced from third party providers.\n";
|
"Some APIs, Icons and Assets used in MIH were sourced from third party providers.\n";
|
||||||
message +=
|
message +=
|
||||||
"We are grateful to the talented creators for providing these resources.\n";
|
"We are grateful to the talented creators for providing these resources.\n";
|
||||||
message +=
|
message +=
|
||||||
"As per the terms for free user for these third party providers, the following assets require attribution";
|
"As per the terms for free use for these third party providers, the following assets require attribution";
|
||||||
|
|
||||||
return MihSingleChildScroll(
|
return MihSingleChildScroll(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -184,10 +184,11 @@ class _MihAttributesState extends State<MihAttributes> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
displayIcon(MihIcons.mihLogo, "Tarah Meth",
|
|
||||||
"https://www.linkedin.com/in/tarah-meth-3b6309254/"),
|
|
||||||
displayIcon(MihIcons.mihRing, "Tarah Meth",
|
displayIcon(MihIcons.mihRing, "Tarah Meth",
|
||||||
"https://www.linkedin.com/in/tarah-meth-3b6309254/"),
|
"https://www.linkedin.com/in/tarah-meth-3b6309254/"),
|
||||||
|
displayIcon(MihIcons.mihLogo, "Tarah Meth",
|
||||||
|
"https://www.linkedin.com/in/tarah-meth-3b6309254/"),
|
||||||
|
displayIcon(MihIcons.mzansiAi, "Ollama", "https://ollama.com/"),
|
||||||
displayIcon(MihIcons.mzansiWallet, "Freepik",
|
displayIcon(MihIcons.mzansiWallet, "Freepik",
|
||||||
"https://www.flaticon.com/free-icon/wallet-passes-app_3884407?term=wallet&page=1&position=21&origin=search&related_id=3884407"),
|
"https://www.flaticon.com/free-icon/wallet-passes-app_3884407?term=wallet&page=1&position=21&origin=search&related_id=3884407"),
|
||||||
displayIcon(MihIcons.patientProfile, "RaftelDesign",
|
displayIcon(MihIcons.patientProfile, "RaftelDesign",
|
||||||
@@ -200,6 +201,8 @@ class _MihAttributesState extends State<MihAttributes> {
|
|||||||
"https://www.flaticon.com/free-icon/calculator_2374409?term=calculator&page=1&position=20&origin=search&related_id=2374409"),
|
"https://www.flaticon.com/free-icon/calculator_2374409?term=calculator&page=1&position=20&origin=search&related_id=2374409"),
|
||||||
displayIcon(MihIcons.aboutMih, "Chanut",
|
displayIcon(MihIcons.aboutMih, "Chanut",
|
||||||
"https://www.flaticon.com/free-icon/info_151776?term=about&page=1&position=8&origin=search&related_id=151776"),
|
"https://www.flaticon.com/free-icon/info_151776?term=about&page=1&position=8&origin=search&related_id=151776"),
|
||||||
|
displayIcon(MihIcons.personalProfile, "Freepik",
|
||||||
|
"https://www.flaticon.com/free-icon/user_1077063?term=profile&page=1&position=6&origin=search&related_id=1077063"),
|
||||||
displayIcon(MihIcons.businessProfile, "Gravisio",
|
displayIcon(MihIcons.businessProfile, "Gravisio",
|
||||||
"https://www.flaticon.com/free-icon/contractor_11813336?term=company+profile&page=1&position=2&origin=search&related_id=11813336"),
|
"https://www.flaticon.com/free-icon/contractor_11813336?term=company+profile&page=1&position=2&origin=search&related_id=11813336"),
|
||||||
displayIcon(MihIcons.patientManager, "Vector Tank",
|
displayIcon(MihIcons.patientManager, "Vector Tank",
|
||||||
@@ -210,6 +213,8 @@ class _MihAttributesState extends State<MihAttributes> {
|
|||||||
"https://www.flaticon.com/free-icon/business_13569850?term=company+add&page=1&position=25&origin=search&related_id=13569850"),
|
"https://www.flaticon.com/free-icon/business_13569850?term=company+add&page=1&position=25&origin=search&related_id=13569850"),
|
||||||
displayIcon(MihIcons.calculator, "fawazahmed0",
|
displayIcon(MihIcons.calculator, "fawazahmed0",
|
||||||
"https://github.com/fawazahmed0/exchange-api"),
|
"https://github.com/fawazahmed0/exchange-api"),
|
||||||
|
displayIcon(MihIcons.iDontKnow, "Freepik",
|
||||||
|
"https://www.flaticon.com/free-icon/i-dont-know_5359909?term=i+dont+know&page=1&position=7&origin=search&related_id=5359909"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -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");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import 'package:mzansi_innovation_hub/mih_packages/about_mih/package_tile/about_
|
|||||||
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tiles/mih_calculator_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tiles/mih_calculator_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tiles/mzansi_calendar_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tiles/mzansi_calendar_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_ai/package_tiles/mzansi_ai_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_ai/package_tiles/mzansi_ai_tile.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tiles/mzansi_directory_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tiles/mzansi_business_profile_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tiles/mzansi_business_profile_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tiles/mzansi_setup_business_profile_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tiles/mzansi_setup_business_profile_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_manager/package_tiles/pat_manager_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_manager/package_tiles/pat_manager_tile.dart';
|
||||||
@@ -112,10 +113,9 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
|||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
//=============== Mzansi AI ===============
|
//=============== Mzansi Directory ===============
|
||||||
temp.add({
|
temp.add({
|
||||||
"Mzansi AI": MzansiAiTile(
|
"Mzansi Directory": MzansiDirectoryTile(
|
||||||
signedInUser: widget.signedInUser,
|
|
||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -126,6 +126,13 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
|||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
//=============== Mzansi AI ===============
|
||||||
|
temp.add({
|
||||||
|
"Mzansi AI": MzansiAiTile(
|
||||||
|
signedInUser: widget.signedInUser,
|
||||||
|
packageSize: packageSize,
|
||||||
|
)
|
||||||
|
});
|
||||||
//=============== About MIH ===============
|
//=============== About MIH ===============
|
||||||
temp.add({"About MIH": AboutMihTile(packageSize: packageSize)});
|
temp.add({"About MIH": AboutMihTile(packageSize: packageSize)});
|
||||||
return temp;
|
return temp;
|
||||||
@@ -278,6 +285,7 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
const SizedBox(height: 50),
|
||||||
Icon(
|
Icon(
|
||||||
MihIcons.mzansiAi,
|
MihIcons.mzansiAi,
|
||||||
size: 165,
|
size: 165,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.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_icons.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||||
@@ -14,6 +13,7 @@ import 'package:mzansi_innovation_hub/mih_packages/access_review/package_tile/mi
|
|||||||
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tiles/mih_calculator_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tiles/mih_calculator_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tiles/mzansi_calendar_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tiles/mzansi_calendar_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_ai/package_tiles/mzansi_ai_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_ai/package_tiles/mzansi_ai_tile.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tiles/mzansi_directory_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tiles/mzansi_profile_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tiles/mzansi_profile_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tiles/mzansi_setup_profile_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tiles/mzansi_setup_profile_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/package_tiles/mih_wallet_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/package_tiles/mih_wallet_tile.dart';
|
||||||
@@ -114,10 +114,9 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
|||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
//=============== Mzansi AI ===============
|
//=============== Mzansi Directory ===============
|
||||||
temp.add({
|
temp.add({
|
||||||
"Mzansi AI": MzansiAiTile(
|
"Mzansi Directory": MzansiDirectoryTile(
|
||||||
signedInUser: widget.signedInUser,
|
|
||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -133,6 +132,13 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
|||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
//=============== Mzansi AI ===============
|
||||||
|
temp.add({
|
||||||
|
"Mzansi AI": MzansiAiTile(
|
||||||
|
signedInUser: widget.signedInUser,
|
||||||
|
packageSize: packageSize,
|
||||||
|
)
|
||||||
|
});
|
||||||
//=============== Calculator ===============
|
//=============== Calculator ===============
|
||||||
temp.add({
|
temp.add({
|
||||||
"Calculator": MihCalculatorTile(
|
"Calculator": MihCalculatorTile(
|
||||||
@@ -156,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",
|
||||||
@@ -322,6 +331,7 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
const SizedBox(height: 50),
|
||||||
Icon(
|
Icon(
|
||||||
MihIcons.mzansiAi,
|
MihIcons.mzansiAi,
|
||||||
size: 165,
|
size: 165,
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
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_business_profile_preview.dart';
|
||||||
|
|
||||||
|
class BuildBusinessSearchResultsList extends StatefulWidget {
|
||||||
|
final List<Business> businessList;
|
||||||
|
final String myLocation;
|
||||||
|
const BuildBusinessSearchResultsList({
|
||||||
|
super.key,
|
||||||
|
required this.businessList,
|
||||||
|
required this.myLocation,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<BuildBusinessSearchResultsList> createState() =>
|
||||||
|
_BuildBusinessSearchResultsListState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BuildBusinessSearchResultsListState
|
||||||
|
extends State<BuildBusinessSearchResultsList> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListView.separated(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: widget.businessList.length,
|
||||||
|
separatorBuilder: (BuildContext context, index) {
|
||||||
|
return Divider(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return Material(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
'/business-profile/view',
|
||||||
|
arguments: widget.businessList[index],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
splashColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor()
|
||||||
|
.withOpacity(0.2),
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsetsGeometry.symmetric(
|
||||||
|
// vertical: 5,
|
||||||
|
horizontal: 25,
|
||||||
|
),
|
||||||
|
child: MihBusinessProfilePreview(
|
||||||
|
business: widget.businessList[index],
|
||||||
|
myLocation: widget.myLocation,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import 'package:flutter/material.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_package_components/mih_personal_profile_preview.dart';
|
||||||
|
|
||||||
|
class BuildUserSearchResultsList extends StatefulWidget {
|
||||||
|
final List<AppUser> userList;
|
||||||
|
const BuildUserSearchResultsList({
|
||||||
|
super.key,
|
||||||
|
required this.userList,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<BuildUserSearchResultsList> createState() =>
|
||||||
|
_BuildUserSearchResultsListState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BuildUserSearchResultsListState
|
||||||
|
extends State<BuildUserSearchResultsList> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListView.separated(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: widget.userList.length,
|
||||||
|
separatorBuilder: (BuildContext context, index) {
|
||||||
|
return Divider(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return Material(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
'/mzansi-profile/view',
|
||||||
|
arguments: widget.userList[index],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
splashColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor()
|
||||||
|
.withOpacity(0.2),
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsetsGeometry.symmetric(
|
||||||
|
// vertical: 5,
|
||||||
|
horizontal: 25,
|
||||||
|
),
|
||||||
|
child: MihPersonalProfilePreview(
|
||||||
|
user: widget.userList[index],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tools/mih_contacts.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tools/mih_favourite_businesses.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tools/mih_search_mzansi.dart';
|
||||||
|
|
||||||
|
class MzansiDirectory extends StatefulWidget {
|
||||||
|
const MzansiDirectory({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MzansiDirectory> createState() => _MzansiDirectoryState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||||
|
int _selcetedIndex = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MihPackage(
|
||||||
|
appActionButton: getAction(),
|
||||||
|
appTools: getTools(),
|
||||||
|
appBody: getToolBody(),
|
||||||
|
appToolTitles: getToolTitle(),
|
||||||
|
selectedbodyIndex: _selcetedIndex,
|
||||||
|
onIndexChange: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = newValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> getToolBody() {
|
||||||
|
List<Widget> toolBodies = [
|
||||||
|
MihSearchMzansi(),
|
||||||
|
MihContacts(),
|
||||||
|
MihFavouriteBusinesses(),
|
||||||
|
];
|
||||||
|
return toolBodies;
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageAction getAction() {
|
||||||
|
return MihPackageAction(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
iconSize: 35,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageTools getTools() {
|
||||||
|
Map<Widget, void Function()?> temp = {};
|
||||||
|
temp[const Icon(Icons.search)] = () {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = 0;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
// temp[const Icon(Icons.person)] = () {
|
||||||
|
// setState(() {
|
||||||
|
// _selcetedIndex = 1;
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
// temp[const Icon(Icons.business_center)] = () {
|
||||||
|
// setState(() {
|
||||||
|
// _selcetedIndex = 2;
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
return MihPackageTools(
|
||||||
|
tools: temp,
|
||||||
|
selcetedIndex: _selcetedIndex,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> getToolTitle() {
|
||||||
|
List<String> toolTitles = [
|
||||||
|
"Mzansi Search",
|
||||||
|
"Contacts",
|
||||||
|
"Favourite Businesses",
|
||||||
|
];
|
||||||
|
return toolTitles;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||||
|
|
||||||
|
class MzansiDirectoryTile extends StatefulWidget {
|
||||||
|
final double packageSize;
|
||||||
|
const MzansiDirectoryTile({
|
||||||
|
super.key,
|
||||||
|
required this.packageSize,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MzansiDirectoryTile> createState() => _MzansiDirectoryTileState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MzansiDirectoryTileState extends State<MzansiDirectoryTile> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MihPackageTile(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
'/mzansi-directory',
|
||||||
|
// arguments: WalletArguments(widget.signedInUser, 0),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
appName: "Mzansi Directory",
|
||||||
|
appIcon: Icon(
|
||||||
|
MihIcons.mzansiDirectory,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
// size: widget.packageSize,
|
||||||
|
),
|
||||||
|
iconSize: widget.packageSize,
|
||||||
|
primaryColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
secondaryColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_search_bar.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||||
|
|
||||||
|
class MihContacts extends StatefulWidget {
|
||||||
|
const MihContacts({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihContacts> createState() => _MihContactsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihContactsState extends State<MihContacts> {
|
||||||
|
final TextEditingController contactSearchController = TextEditingController();
|
||||||
|
final FocusNode searchFocusNode = FocusNode();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final Size size = MediaQuery.sizeOf(context);
|
||||||
|
final double width = size.width;
|
||||||
|
return MihPackageToolBody(
|
||||||
|
borderOn: false,
|
||||||
|
bodyItem: getBody(width),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getBody(double width) {
|
||||||
|
return MihSingleChildScroll(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||||
|
child: MihSearchBar(
|
||||||
|
controller: contactSearchController,
|
||||||
|
hintText: "Search Contacts",
|
||||||
|
prefixIcon: Icons.search,
|
||||||
|
fillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
hintColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
onPrefixIconTap: () {},
|
||||||
|
searchFocusNode: searchFocusNode,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_search_bar.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||||
|
|
||||||
|
class MihFavouriteBusinesses extends StatefulWidget {
|
||||||
|
const MihFavouriteBusinesses({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihFavouriteBusinesses> createState() => _MihFavouriteBusinessesState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
||||||
|
final TextEditingController businessSearchController =
|
||||||
|
TextEditingController();
|
||||||
|
final FocusNode searchFocusNode = FocusNode();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final Size size = MediaQuery.sizeOf(context);
|
||||||
|
final double width = size.width;
|
||||||
|
return MihPackageToolBody(
|
||||||
|
borderOn: false,
|
||||||
|
bodyItem: getBody(width),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getBody(double width) {
|
||||||
|
return MihSingleChildScroll(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||||
|
child: MihSearchBar(
|
||||||
|
controller: businessSearchController,
|
||||||
|
hintText: "Search Businesses",
|
||||||
|
prefixIcon: Icons.search,
|
||||||
|
fillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
hintColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
onPrefixIconTap: () {},
|
||||||
|
searchFocusNode: searchFocusNode,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,322 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:geolocator/geolocator.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/business.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_search_bar.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/build_business_search_resultsList.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/build_user_search_results_list.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_location_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||||
|
|
||||||
|
class MihSearchMzansi extends StatefulWidget {
|
||||||
|
const MihSearchMzansi({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihSearchMzansi> createState() => _MihSearchMzansiState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||||
|
final TextEditingController mzansiSearchController = TextEditingController();
|
||||||
|
final FocusNode searchFocusNode = FocusNode();
|
||||||
|
bool userSearch = true;
|
||||||
|
Future<List<AppUser>?> futureUserSearchResults = Future.value();
|
||||||
|
Future<List<Business>?> futureBusinessSearchResults = Future.value();
|
||||||
|
late Future<Position?> futurePosition =
|
||||||
|
MIHLocationAPI().getGPSPosition(context);
|
||||||
|
List<AppUser> userSearchResults = [];
|
||||||
|
List<Business> businessSearchResults = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
mzansiSearchController.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final Size size = MediaQuery.sizeOf(context);
|
||||||
|
final double width = size.width;
|
||||||
|
return MihPackageToolBody(
|
||||||
|
borderOn: false,
|
||||||
|
bodyItem: getBody(width),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getBody(double width) {
|
||||||
|
return MihSingleChildScroll(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||||
|
child: MihSearchBar(
|
||||||
|
controller: mzansiSearchController,
|
||||||
|
hintText: "Search Mzansi",
|
||||||
|
prefixIcon: Icons.search,
|
||||||
|
prefixAltIcon: userSearch
|
||||||
|
? MihIcons.personalProfile
|
||||||
|
: MihIcons.businessProfile,
|
||||||
|
suffixTools: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
// searchTypeVisibility = !searchTypeVisibility;
|
||||||
|
userSearch = !userSearch;
|
||||||
|
if (userSearch) {
|
||||||
|
futureUserSearchResults = MihUserServices()
|
||||||
|
.searchUsers(
|
||||||
|
mzansiSearchController.text, context);
|
||||||
|
} else {
|
||||||
|
futureBusinessSearchResults =
|
||||||
|
MihBusinessDetailsServices().searchBusinesses(
|
||||||
|
mzansiSearchController.text, context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.display_settings,
|
||||||
|
size: 35,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
))
|
||||||
|
],
|
||||||
|
fillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
hintColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
onPrefixIconTap: () {
|
||||||
|
if (userSearch) {
|
||||||
|
setState(() {
|
||||||
|
futureUserSearchResults = MihUserServices()
|
||||||
|
.searchUsers(mzansiSearchController.text, context);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
futureBusinessSearchResults = MihBusinessDetailsServices()
|
||||||
|
.searchBusinesses(mzansiSearchController.text, context);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onClearIconTap: () {
|
||||||
|
setState(() {
|
||||||
|
futureUserSearchResults = Future.value();
|
||||||
|
futureBusinessSearchResults = Future.value();
|
||||||
|
mzansiSearchController.clear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchFocusNode: searchFocusNode,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
FutureBuilder(
|
||||||
|
future: futurePosition,
|
||||||
|
builder: (context, asyncSnapshot) {
|
||||||
|
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Mihloadingcircle(
|
||||||
|
message: "Getting Your GPS Location Ready",
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final myLocation = asyncSnapshot.data
|
||||||
|
.toString()
|
||||||
|
.replaceAll("Latitude: ", "")
|
||||||
|
.replaceAll("Longitude: ", "");
|
||||||
|
print("My Location is : $myLocation");
|
||||||
|
return displaySearchResults(userSearch, myLocation);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget displaySearchResults(bool userSearch, String myLocation) {
|
||||||
|
if (userSearch) {
|
||||||
|
return FutureBuilder(
|
||||||
|
future: futureUserSearchResults,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Mihloadingcircle();
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||||
|
snapshot.hasData &&
|
||||||
|
snapshot.requireData!.isNotEmpty) {
|
||||||
|
// return Text("Pulled Data successfully");
|
||||||
|
snapshot.requireData!
|
||||||
|
.sort((a, b) => a.username.compareTo(b.username));
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"People of Mzansi",
|
||||||
|
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
BuildUserSearchResultsList(userList: snapshot.requireData!),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else if (!snapshot.hasData) {
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 50),
|
||||||
|
Icon(
|
||||||
|
MihIcons.personalProfile,
|
||||||
|
size: 165,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
"People Of Mzansi!",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||||
|
snapshot.hasData &&
|
||||||
|
snapshot.requireData!.isEmpty) {
|
||||||
|
// return Text("Pulled Data successfully");
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 50),
|
||||||
|
Icon(
|
||||||
|
MihIcons.iDontKnow,
|
||||||
|
size: 165,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
"Let's Try Refining Your Search",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Center(
|
||||||
|
child: Text(
|
||||||
|
"Error pulling Patients Data\n/users/search/${mzansiSearchController.text}",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return FutureBuilder(
|
||||||
|
future: futureBusinessSearchResults,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Mihloadingcircle();
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||||
|
snapshot.hasData &&
|
||||||
|
snapshot.requireData!.isNotEmpty) {
|
||||||
|
// return Text("Pulled Data successfully");
|
||||||
|
snapshot.requireData!.sort((a, b) => a.Name.compareTo(b.Name));
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Businesses of Mzansi",
|
||||||
|
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
BuildBusinessSearchResultsList(
|
||||||
|
businessList: snapshot.requireData!,
|
||||||
|
myLocation: myLocation,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||||
|
snapshot.hasData &&
|
||||||
|
snapshot.requireData!.isEmpty) {
|
||||||
|
// return Text("Pulled Data successfully");
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 50),
|
||||||
|
Icon(
|
||||||
|
MihIcons.iDontKnow,
|
||||||
|
size: 165,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
"Let's Try Refining Your Search",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else if (!snapshot.hasData) {
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 50),
|
||||||
|
Icon(
|
||||||
|
MihIcons.businessProfile,
|
||||||
|
size: 165,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
"Businesses Of Mzansi!",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Center(
|
||||||
|
child: Text(
|
||||||
|
"Error pulling Patients Data\n/users/search/${mzansiSearchController.text}",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,14 +8,14 @@ class MihBusinessCard extends StatefulWidget {
|
|||||||
final String cellNumber;
|
final String cellNumber;
|
||||||
final String email;
|
final String email;
|
||||||
final String gpsLocation;
|
final String gpsLocation;
|
||||||
final String website;
|
final String? website;
|
||||||
const MihBusinessCard({
|
const MihBusinessCard({
|
||||||
super.key,
|
super.key,
|
||||||
required this.businessName,
|
required this.businessName,
|
||||||
required this.cellNumber,
|
required this.cellNumber,
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.gpsLocation,
|
required this.gpsLocation,
|
||||||
required this.website,
|
this.website,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -35,15 +35,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Making Call",
|
alertTitle: "Error Making Call",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch phone to call ${widget.cellNumber}",
|
"We couldn't open your phone app to call ${widget.cellNumber}. To fix this, make sure you have a phone application installed and it's set as your default dialer.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -83,15 +85,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Creating Email",
|
alertTitle: "Error Creating Email",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch email to ${widget.email}",
|
"We couldn't launch your email app to send a message to ${widget.email}. To fix this, please confirm that you have an email application installed and that it's set as your default.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -115,8 +119,6 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
if (await canLaunchUrl(googleMapsUrl)) {
|
if (await canLaunchUrl(googleMapsUrl)) {
|
||||||
await launchUrl(googleMapsUrl);
|
await launchUrl(googleMapsUrl);
|
||||||
} else {
|
} else {
|
||||||
print(
|
|
||||||
'Could not launch Google Maps. Make sure the Google Maps app is installed or an internet connection is available.');
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@@ -124,15 +126,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Creating Maps",
|
alertTitle: "Error Creating Maps",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch maps to ${widget.businessName}",
|
"There was an issue opening maps for ${widget.businessName}. This usually happens if you don't have a maps app installed or it's not set as your default. Please install one to proceed.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -151,15 +155,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Creating Maps",
|
alertTitle: "Error Creating Maps",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch maps to ${widget.businessName}",
|
"There was an issue opening maps for ${widget.businessName}. This usually happens if you don't have a maps app installed or it's not set as your default. Please install one to proceed.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -172,7 +178,11 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _launchWebsite(String urlString) async {
|
Future<void> _launchWebsite(String urlString) async {
|
||||||
final Uri url = Uri.parse(urlString);
|
String newUrl = urlString;
|
||||||
|
if (!newUrl.startsWith("https://")) {
|
||||||
|
newUrl = "https://$urlString";
|
||||||
|
}
|
||||||
|
final Uri url = Uri.parse(newUrl);
|
||||||
try {
|
try {
|
||||||
if (await canLaunchUrl(url)) {
|
if (await canLaunchUrl(url)) {
|
||||||
await launchUrl(url);
|
await launchUrl(url);
|
||||||
@@ -185,15 +195,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Opening Website",
|
alertTitle: "Error Opening Website",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch ${widget.businessName}",
|
"We couldn't open the link to $newUrl. To view this website, please ensure you have a web browser installed and set as your default.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -212,15 +224,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Opening Website",
|
alertTitle: "Error Opening Website",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch ${widget.businessName}",
|
"We couldn't open the link to $newUrl. To view this website, please ensure you have a web browser installed and set as your default.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -250,6 +264,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(15),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsetsGeometry.symmetric(
|
padding: EdgeInsetsGeometry.symmetric(
|
||||||
|
// vertical: 5,
|
||||||
horizontal: 25,
|
horizontal: 25,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -306,7 +321,15 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Material(
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor()
|
||||||
|
.withValues(alpha: 0.6),
|
||||||
|
borderRadius: BorderRadius.circular(25),
|
||||||
|
elevation: 10,
|
||||||
|
shadowColor: Colors.black,
|
||||||
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
@@ -324,12 +347,9 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
_makePhoneCall(widget.cellNumber);
|
_makePhoneCall(widget.cellNumber);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Padding(
|
Divider(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
||||||
child: Divider(
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
_buildContactInfo(
|
_buildContactInfo(
|
||||||
"Email",
|
"Email",
|
||||||
"Send us an email.",
|
"Send us an email.",
|
||||||
@@ -344,12 +364,9 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Padding(
|
Divider(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
||||||
child: Divider(
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
_buildContactInfo(
|
_buildContactInfo(
|
||||||
"Location",
|
"Location",
|
||||||
"Come visit us.",
|
"Come visit us.",
|
||||||
@@ -357,28 +374,32 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
const Color(0xffe9e8a1),
|
const Color(0xffe9e8a1),
|
||||||
() {
|
() {
|
||||||
final latitude = double.parse(widget.gpsLocation.split(',')[0]);
|
final latitude = double.parse(widget.gpsLocation.split(',')[0]);
|
||||||
final longitude = double.parse(widget.gpsLocation.split(',')[1]);
|
final longitude =
|
||||||
|
double.parse(widget.gpsLocation.split(',')[1]);
|
||||||
_launchGoogleMapsWithUrl(
|
_launchGoogleMapsWithUrl(
|
||||||
latitude: latitude,
|
latitude: latitude,
|
||||||
longitude: longitude,
|
longitude: longitude,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// Padding(
|
Visibility(
|
||||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
visible: widget.website != null && widget.website! != "",
|
||||||
// child: Divider(
|
child: Divider(
|
||||||
// color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// _buildContactInfo(
|
Visibility(
|
||||||
// "Website",
|
visible: widget.website != null && widget.website! != "",
|
||||||
// "Find out more about us.",
|
child: _buildContactInfo(
|
||||||
// Icons.vpn_lock,
|
"Website",
|
||||||
// const Color(0xffd67d8a),
|
"Find out more about us.",
|
||||||
// () {
|
Icons.vpn_lock,
|
||||||
// _launchWebsite(widget.website);
|
const Color(0xffd67d8a),
|
||||||
// },
|
() {
|
||||||
// ),
|
_launchWebsite(widget.website!);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
// Padding(
|
// Padding(
|
||||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
// child: Divider(
|
// child: Divider(
|
||||||
@@ -420,6 +441,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
// ),
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details_view.dart';
|
||||||
|
|
||||||
|
class MzansiBusinessProfileView extends StatefulWidget {
|
||||||
|
final Business business;
|
||||||
|
const MzansiBusinessProfileView({
|
||||||
|
super.key,
|
||||||
|
required this.business,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MzansiBusinessProfileView> createState() =>
|
||||||
|
_MzansiBusinessProfileViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||||
|
int _selcetedIndex = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MihPackage(
|
||||||
|
appActionButton: getAction(),
|
||||||
|
appTools: getTools(),
|
||||||
|
appBody: getToolBody(),
|
||||||
|
appToolTitles: getToolTitle(),
|
||||||
|
selectedbodyIndex: _selcetedIndex,
|
||||||
|
onIndexChange: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = newValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageAction getAction() {
|
||||||
|
return MihPackageAction(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
iconSize: 35,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageTools getTools() {
|
||||||
|
Map<Widget, void Function()?> temp = {};
|
||||||
|
temp[const Icon(Icons.business)] = () {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = 0;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return MihPackageTools(
|
||||||
|
tools: temp,
|
||||||
|
selcetedIndex: _selcetedIndex,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> getToolBody() {
|
||||||
|
List<Widget> toolBodies = [
|
||||||
|
MihBusinessDetailsView(business: widget.business),
|
||||||
|
];
|
||||||
|
return toolBodies;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> getToolTitle() {
|
||||||
|
List<String> toolTitles = [
|
||||||
|
"Profile",
|
||||||
|
];
|
||||||
|
return toolTitles;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,8 @@ import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
|||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_business_card.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_business_info_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_business_details_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||||
@@ -12,7 +13,6 @@ 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';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_dropdwn_field.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||||
@@ -47,13 +47,17 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
final contactController = TextEditingController();
|
final contactController = TextEditingController();
|
||||||
final emailController = TextEditingController();
|
final emailController = TextEditingController();
|
||||||
final locationController = TextEditingController();
|
final locationController = TextEditingController();
|
||||||
|
final websiteController = TextEditingController();
|
||||||
|
final ratingController = TextEditingController();
|
||||||
|
final missionVisionController = TextEditingController();
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
|
||||||
late String env;
|
late String env;
|
||||||
|
|
||||||
Future<void> submitForm() async {
|
Future<void> submitForm() async {
|
||||||
if (isFormFilled()) {
|
if (isFormFilled()) {
|
||||||
int statusCode = 0;
|
int statusCode = 0;
|
||||||
statusCode = await MihBusinessDetailsServices().updateBusinessDetails(
|
statusCode = await MihBusinessDetailsServices().updateBusinessDetailsV2(
|
||||||
widget.arguments.business!.business_id,
|
widget.arguments.business!.business_id,
|
||||||
nameController.text,
|
nameController.text,
|
||||||
typeController.text,
|
typeController.text,
|
||||||
@@ -64,6 +68,9 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
contactController.text,
|
contactController.text,
|
||||||
locationController.text,
|
locationController.text,
|
||||||
fileNameController.text,
|
fileNameController.text,
|
||||||
|
websiteController.text,
|
||||||
|
ratingController.text.isEmpty ? "0" : ratingController.text,
|
||||||
|
missionVisionController.text,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
if (statusCode == 200) {
|
if (statusCode == 200) {
|
||||||
@@ -246,22 +253,6 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.secondaryColor(),
|
|
||||||
inputColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.primaryColor(),
|
|
||||||
controller: regController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Registration No.",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
@@ -277,18 +268,33 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
return MihValidationServices().isEmpty(value);
|
return MihValidationServices().isEmpty(value);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 10),
|
||||||
MihDropdownField(
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
controller: typeController,
|
controller: typeController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
hintText: "Business Type",
|
hintText: "Business Type",
|
||||||
dropdownOptions: const ["Doctors Office", "Other"],
|
|
||||||
editable: true,
|
|
||||||
enableSearch: true,
|
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return MihValidationServices().isEmpty(value);
|
return MihValidationServices().isEmpty(value);
|
||||||
},
|
},
|
||||||
requiredText: true,
|
|
||||||
),
|
),
|
||||||
|
// 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),
|
const SizedBox(height: 10),
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
@@ -297,30 +303,13 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
inputColor: MzanziInnovationHub.of(context)!
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
controller: practiceNoController,
|
controller: emailController,
|
||||||
multiLineInput: false,
|
multiLineInput: false,
|
||||||
requiredText:
|
requiredText: true,
|
||||||
typeController.text == "Doctors Office",
|
hintText: "Business Email",
|
||||||
hintText: "Practice Number",
|
validator: (value) {
|
||||||
validator: (validateValue) {
|
|
||||||
return MihValidationServices()
|
return MihValidationServices()
|
||||||
.isEmpty(validateValue);
|
.validateEmail(value);
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.secondaryColor(),
|
|
||||||
inputColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.primaryColor(),
|
|
||||||
controller: vatNoController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "VAT Number",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
@@ -347,13 +336,110 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
inputColor: MzanziInnovationHub.of(context)!
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
controller: emailController,
|
controller: websiteController,
|
||||||
multiLineInput: false,
|
multiLineInput: false,
|
||||||
requiredText: true,
|
requiredText: false,
|
||||||
hintText: "Business Email",
|
hintText: "Business Website",
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return MihValidationServices()
|
return MihValidationServices()
|
||||||
.validateEmail(value);
|
.validateWebsite(value, false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihTextFormField(
|
||||||
|
height: 250,
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: missionVisionController,
|
||||||
|
multiLineInput: true,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Business Mission & Vision",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().validateLength(
|
||||||
|
missionVisionController.text, 256);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
child: ValueListenableBuilder(
|
||||||
|
valueListenable: _counter,
|
||||||
|
builder: (BuildContext context, int value,
|
||||||
|
Widget? child) {
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"$value",
|
||||||
|
style: TextStyle(
|
||||||
|
color: getMissionVisionLimitColor(256),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
Text(
|
||||||
|
"/256",
|
||||||
|
style: TextStyle(
|
||||||
|
color: getMissionVisionLimitColor(256),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: regController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Registration No.",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: practiceNoController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText:
|
||||||
|
typeController.text == "Doctors Office",
|
||||||
|
hintText: "Practice Number",
|
||||||
|
validator: (validateValue) {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: vatNoController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "VAT Number",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
@@ -377,6 +463,14 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
const SizedBox(width: 10.0),
|
const SizedBox(width: 10.0),
|
||||||
MihButton(
|
MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const Mihloadingcircle(
|
||||||
|
message: "Getting your location",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
MIHLocationAPI()
|
MIHLocationAPI()
|
||||||
.getGPSPosition(context)
|
.getGPSPosition(context)
|
||||||
.then((position) {
|
.then((position) {
|
||||||
@@ -386,6 +480,8 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
"${position.latitude}, ${position.longitude}";
|
"${position.latitude}, ${position.longitude}";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//Dismiss loading indicator
|
||||||
|
Navigator.of(context).pop();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
buttonColor: MzanziInnovationHub.of(context)!
|
buttonColor: MzanziInnovationHub.of(context)!
|
||||||
@@ -442,6 +538,14 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color getMissionVisionLimitColor(int limit) {
|
||||||
|
if (_counter.value <= limit) {
|
||||||
|
return MzanziInnovationHub.of(context)!.theme.secondaryColor();
|
||||||
|
} else {
|
||||||
|
return MzanziInnovationHub.of(context)!.theme.errorColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -454,6 +558,9 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
contactController.dispose();
|
contactController.dispose();
|
||||||
emailController.dispose();
|
emailController.dispose();
|
||||||
locationController.dispose();
|
locationController.dispose();
|
||||||
|
websiteController.dispose();
|
||||||
|
ratingController.dispose();
|
||||||
|
missionVisionController.dispose();
|
||||||
imageFile = null;
|
imageFile = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,12 +578,20 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
contactController.text = widget.arguments.business!.contact_no;
|
contactController.text = widget.arguments.business!.contact_no;
|
||||||
emailController.text = widget.arguments.business!.bus_email;
|
emailController.text = widget.arguments.business!.bus_email;
|
||||||
locationController.text = widget.arguments.business!.gps_location;
|
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") {
|
if (AppEnviroment.getEnv() == "Prod") {
|
||||||
env = "Prod";
|
env = "Prod";
|
||||||
} else {
|
} else {
|
||||||
env = "Dev";
|
env = "Dev";
|
||||||
}
|
}
|
||||||
|
missionVisionController.addListener(() {
|
||||||
|
setState(() {
|
||||||
|
_counter.value = missionVisionController.text.characters.length;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -530,10 +645,9 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Center(
|
// FittedBox(
|
||||||
// child: Text(
|
// child: Text(
|
||||||
// "*DEMO TEXT* This would be the bio of the user telling us a bit about themself and let. This would be the bio of the user telling us a bit about themself and let. This would be the bio of the user telling us a bit about themself",
|
// "Mission & Vision",
|
||||||
// textAlign: TextAlign.center,
|
|
||||||
// style: TextStyle(
|
// style: TextStyle(
|
||||||
// fontSize: 15,
|
// fontSize: 15,
|
||||||
// fontWeight: FontWeight.bold,
|
// fontWeight: FontWeight.bold,
|
||||||
@@ -543,6 +657,24 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 700,
|
||||||
|
child: Text(
|
||||||
|
widget.arguments.business!.mission_vision.isNotEmpty
|
||||||
|
? widget.arguments.business!.mission_vision
|
||||||
|
: "No Mission & Vision added yet",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 700,
|
width: 700,
|
||||||
@@ -552,8 +684,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
email: widget.arguments.business!.bus_email,
|
email: widget.arguments.business!.bus_email,
|
||||||
gpsLocation: widget.arguments.business!.gps_location,
|
gpsLocation: widget.arguments.business!.gps_location,
|
||||||
//To-Do: Add the business Website
|
//To-Do: Add the business Website
|
||||||
website:
|
website: widget.arguments.business!.website,
|
||||||
"https://app.mzansi-innovation-hub.co.za/privacy.html",
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30.0),
|
const SizedBox(height: 30.0),
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
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_icons.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_business_info_card.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_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_package_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||||
|
|
||||||
|
class MihBusinessDetailsView extends StatefulWidget {
|
||||||
|
final Business business;
|
||||||
|
const MihBusinessDetailsView({
|
||||||
|
super.key,
|
||||||
|
required this.business,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihBusinessDetailsView> createState() => _MihBusinessDetailsViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihBusinessDetailsViewState extends State<MihBusinessDetailsView> {
|
||||||
|
late Future<String> futureImageUrl;
|
||||||
|
PlatformFile? file;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
futureImageUrl =
|
||||||
|
MihFileApi.getMinioFileUrl(widget.business.logo_path, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
return MihPackageToolBody(
|
||||||
|
borderOn: false,
|
||||||
|
innerHorizontalPadding: 10,
|
||||||
|
bodyItem: getBody(screenWidth, context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getBody(double width, BuildContext context) {
|
||||||
|
double profilePictureWidth = 150;
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
MihSingleChildScroll(
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||||
|
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||||
|
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
FutureBuilder(
|
||||||
|
future: futureImageUrl,
|
||||||
|
builder: (context, asyncSnapshot) {
|
||||||
|
if (asyncSnapshot.connectionState ==
|
||||||
|
ConnectionState.done &&
|
||||||
|
asyncSnapshot.hasData) {
|
||||||
|
if (asyncSnapshot.requireData != "") {
|
||||||
|
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.iDontKnow,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Icon(
|
||||||
|
MihIcons.mihRing,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// Center(
|
||||||
|
// child: MihCircleAvatar(
|
||||||
|
// imageFile: widget.logoImage,
|
||||||
|
// width: 150,
|
||||||
|
// editable: false,
|
||||||
|
// fileNameController: fileNameController,
|
||||||
|
// userSelectedfile: imageFile,
|
||||||
|
// frameColor:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
// backgroundColor:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
// onChange: (selectedfile) {
|
||||||
|
// setState(() {
|
||||||
|
// imageFile = selectedfile;
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
FittedBox(
|
||||||
|
child: Text(
|
||||||
|
widget.business.Name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 35,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// FittedBox(
|
||||||
|
// child: Text(
|
||||||
|
// "Mission & Vision",
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 15,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// color: MzanziInnovationHub.of(context)!
|
||||||
|
// .theme
|
||||||
|
// .secondaryColor(),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 700,
|
||||||
|
child: Text(
|
||||||
|
widget.business.mission_vision.isNotEmpty
|
||||||
|
? widget.business.mission_vision
|
||||||
|
: "No Mission & Vision added yet",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
SizedBox(
|
||||||
|
width: 700,
|
||||||
|
child: MihBusinessCard(
|
||||||
|
businessName: widget.business.Name,
|
||||||
|
cellNumber: widget.business.contact_no,
|
||||||
|
email: widget.business.bus_email,
|
||||||
|
gpsLocation: widget.business.gps_location,
|
||||||
|
//To-Do: Add the business Website
|
||||||
|
website: widget.business.website,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,13 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.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_package_tool_body.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_search_bar.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_search_bar.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';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.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/arguments.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/builders/build_user_list.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/builders/build_user_list.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
|
||||||
|
|
||||||
class MihBusinessUserSearch extends StatefulWidget {
|
class MihBusinessUserSearch extends StatefulWidget {
|
||||||
final BusinessArguments arguments;
|
final BusinessArguments arguments;
|
||||||
@@ -33,18 +30,19 @@ class _MihBusinessUserSearchState extends State<MihBusinessUserSearch> {
|
|||||||
String errorBody = "";
|
String errorBody = "";
|
||||||
|
|
||||||
Future<List<AppUser>> fetchUsers(String search) async {
|
Future<List<AppUser>> fetchUsers(String search) async {
|
||||||
final response = await http
|
return MihUserServices().searchUsers(search, context);
|
||||||
.get(Uri.parse("${AppEnviroment.baseApiUrl}/users/search/$search"));
|
// final response = await http
|
||||||
errorCode = response.statusCode.toString();
|
// .get(Uri.parse("${AppEnviroment.baseApiUrl}/users/search/$search"));
|
||||||
errorBody = response.body;
|
// errorCode = response.statusCode.toString();
|
||||||
if (response.statusCode == 200) {
|
// errorBody = response.body;
|
||||||
Iterable l = jsonDecode(response.body);
|
// if (response.statusCode == 200) {
|
||||||
List<AppUser> users =
|
// Iterable l = jsonDecode(response.body);
|
||||||
List<AppUser>.from(l.map((model) => AppUser.fromJson(model)));
|
// List<AppUser> users =
|
||||||
return users;
|
// List<AppUser>.from(l.map((model) => AppUser.fromJson(model)));
|
||||||
} else {
|
// return users;
|
||||||
throw Exception('failed to load patients');
|
// } else {
|
||||||
}
|
// throw Exception('failed to load patients');
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void submitUserForm() {
|
void submitUserForm() {
|
||||||
@@ -142,7 +140,7 @@ class _MihBusinessUserSearchState extends State<MihBusinessUserSearch> {
|
|||||||
} else {
|
} else {
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"$errorCode: Error pulling Patients Data\n/patients/search/$userSearch\n$errorBody",
|
"$errorCode: Error pulling Patients Data\n/users/search/$userSearch\n$errorBody",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 25,
|
fontSize: 25,
|
||||||
color:
|
color:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
|
|
||||||
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_services/mih_alert_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||||
@@ -56,12 +57,16 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
final locationController = TextEditingController();
|
final locationController = TextEditingController();
|
||||||
final practiceNoController = TextEditingController();
|
final practiceNoController = TextEditingController();
|
||||||
final vatNoController = TextEditingController();
|
final vatNoController = TextEditingController();
|
||||||
|
final websiteController = TextEditingController();
|
||||||
|
final ratingController = TextEditingController();
|
||||||
|
final missionVisionController = TextEditingController();
|
||||||
|
|
||||||
ImageProvider<Object>? logoPreview;
|
ImageProvider<Object>? logoPreview;
|
||||||
ImageProvider<Object>? signaturePreview;
|
ImageProvider<Object>? signaturePreview;
|
||||||
PlatformFile? selectedLogo;
|
PlatformFile? selectedLogo;
|
||||||
PlatformFile? selectedSignature;
|
PlatformFile? selectedSignature;
|
||||||
|
|
||||||
|
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
|
||||||
final ValueNotifier<String> busType = ValueNotifier("");
|
final ValueNotifier<String> busType = ValueNotifier("");
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
late String env;
|
late String env;
|
||||||
@@ -123,6 +128,9 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
contactController.text,
|
contactController.text,
|
||||||
locationController.text,
|
locationController.text,
|
||||||
logonameController.text,
|
logonameController.text,
|
||||||
|
websiteController.text,
|
||||||
|
"0",
|
||||||
|
missionVisionController.text,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
print(response.body);
|
print(response.body);
|
||||||
@@ -223,7 +231,7 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
headerAlignment: MainAxisAlignment.center,
|
headerAlignment: MainAxisAlignment.center,
|
||||||
headerItems: [
|
headerItems: [
|
||||||
Text(
|
Text(
|
||||||
"Add Business Profile",
|
"Set Up Business Profile",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 25,
|
fontSize: 25,
|
||||||
@@ -233,6 +241,14 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color getMissionVisionLimitColor(int limit) {
|
||||||
|
if (_counter.value <= limit) {
|
||||||
|
return MzanziInnovationHub.of(context)!.theme.secondaryColor();
|
||||||
|
} else {
|
||||||
|
return MzanziInnovationHub.of(context)!.theme.errorColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MIHBody getBody(double width) {
|
MIHBody getBody(double width) {
|
||||||
return MIHBody(
|
return MIHBody(
|
||||||
borderOn: false,
|
borderOn: false,
|
||||||
@@ -273,22 +289,6 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
MihForm(
|
MihForm(
|
||||||
formKey: _formKey,
|
formKey: _formKey,
|
||||||
formFields: [
|
formFields: [
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.secondaryColor(),
|
|
||||||
inputColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.primaryColor(),
|
|
||||||
controller: regController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Registration No.",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
@@ -304,47 +304,6 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
return MihValidationServices().isEmpty(value);
|
return MihValidationServices().isEmpty(value);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15.0),
|
|
||||||
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),
|
|
||||||
ValueListenableBuilder(
|
|
||||||
valueListenable: busType,
|
|
||||||
builder: (BuildContext context, String value,
|
|
||||||
Widget? child) {
|
|
||||||
return Visibility(
|
|
||||||
visible: value == "Doctors Office",
|
|
||||||
child: MihTextFormField(
|
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.secondaryColor(),
|
|
||||||
inputColor: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.primaryColor(),
|
|
||||||
controller: practiceNoController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Practice Number",
|
|
||||||
validator: (validateValue) {
|
|
||||||
if (value == "Doctors Office") {
|
|
||||||
return MihValidationServices()
|
|
||||||
.isEmpty(validateValue);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
@@ -353,14 +312,41 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
inputColor: MzanziInnovationHub.of(context)!
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
controller: vatNoController,
|
controller: typeController,
|
||||||
multiLineInput: false,
|
multiLineInput: false,
|
||||||
requiredText: true,
|
requiredText: true,
|
||||||
hintText: "VAT Number",
|
hintText: "Business Type",
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
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),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: emailController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Business Email",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().validateEmail(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
@@ -385,12 +371,111 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
inputColor: MzanziInnovationHub.of(context)!
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
controller: emailController,
|
controller: websiteController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: false,
|
||||||
|
hintText: "Business Website",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices()
|
||||||
|
.validateWebsite(value, false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
height: 250,
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: missionVisionController,
|
||||||
|
multiLineInput: true,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Business Mission & Vision",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().validateLength(
|
||||||
|
missionVisionController.text, 256);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
child: ValueListenableBuilder(
|
||||||
|
valueListenable: _counter,
|
||||||
|
builder:
|
||||||
|
(BuildContext context, int value, Widget? child) {
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"$value",
|
||||||
|
style: TextStyle(
|
||||||
|
color: getMissionVisionLimitColor(256),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
Text(
|
||||||
|
"/256",
|
||||||
|
style: TextStyle(
|
||||||
|
color: getMissionVisionLimitColor(256),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: regController,
|
||||||
multiLineInput: false,
|
multiLineInput: false,
|
||||||
requiredText: true,
|
requiredText: true,
|
||||||
hintText: "Business Email",
|
hintText: "Registration No.",
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return MihValidationServices().validateEmail(value);
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: practiceNoController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: false,
|
||||||
|
hintText: "Practice Number",
|
||||||
|
validator: (validateValue) {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
inputColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
controller: vatNoController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "VAT Number",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
@@ -414,6 +499,14 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
const SizedBox(width: 10.0),
|
const SizedBox(width: 10.0),
|
||||||
MihButton(
|
MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const Mihloadingcircle(
|
||||||
|
message: "Getting your location",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
MIHLocationAPI()
|
MIHLocationAPI()
|
||||||
.getGPSPosition(context)
|
.getGPSPosition(context)
|
||||||
.then((position) {
|
.then((position) {
|
||||||
@@ -423,6 +516,7 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
"${position.latitude}, ${position.longitude}";
|
"${position.latitude}, ${position.longitude}";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Navigator.of(context).pop();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
buttonColor: MzanziInnovationHub.of(context)!
|
buttonColor: MzanziInnovationHub.of(context)!
|
||||||
@@ -573,6 +667,7 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
super.initState();
|
||||||
typeController.addListener(typeSelected);
|
typeController.addListener(typeSelected);
|
||||||
setState(() {
|
setState(() {
|
||||||
fnameController.text = widget.signedInUser.fname;
|
fnameController.text = widget.signedInUser.fname;
|
||||||
@@ -584,7 +679,11 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
|||||||
} else {
|
} else {
|
||||||
env = "Dev";
|
env = "Dev";
|
||||||
}
|
}
|
||||||
super.initState();
|
missionVisionController.addListener(() {
|
||||||
|
setState(() {
|
||||||
|
_counter.value = missionVisionController.text.characters.length;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class _MzansiProfileState extends State<MzansiProfile> {
|
|||||||
|
|
||||||
MihPackageTools getTools() {
|
MihPackageTools getTools() {
|
||||||
Map<Widget, void Function()?> temp = {};
|
Map<Widget, void Function()?> temp = {};
|
||||||
temp[const Icon(Icons.perm_identity)] = () {
|
temp[const Icon(Icons.person)] = () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selcetedIndex = 0;
|
_selcetedIndex = 0;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_profile_view.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class MzansiProfileView extends StatefulWidget {
|
||||||
|
final AppUser user;
|
||||||
|
const MzansiProfileView({
|
||||||
|
super.key,
|
||||||
|
required this.user,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MzansiProfileView> createState() => _MzansiProfileViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MzansiProfileViewState extends State<MzansiProfileView> {
|
||||||
|
int _selcetedIndex = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MihPackage(
|
||||||
|
appActionButton: getAction(),
|
||||||
|
appTools: getTools(),
|
||||||
|
appBody: getToolBody(),
|
||||||
|
appToolTitles: getToolTitle(),
|
||||||
|
selectedbodyIndex: _selcetedIndex,
|
||||||
|
onIndexChange: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = newValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageAction getAction() {
|
||||||
|
return MihPackageAction(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
iconSize: 35,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageTools getTools() {
|
||||||
|
Map<Widget, void Function()?> temp = {};
|
||||||
|
temp[const Icon(Icons.person)] = () {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = 0;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return MihPackageTools(
|
||||||
|
tools: temp,
|
||||||
|
selcetedIndex: _selcetedIndex,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> getToolBody() {
|
||||||
|
List<Widget> toolBodies = [];
|
||||||
|
toolBodies.add(MihPersonalProfileView(
|
||||||
|
user: widget.user,
|
||||||
|
));
|
||||||
|
return toolBodies;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> getToolTitle() {
|
||||||
|
List<String> toolTitles = [
|
||||||
|
"Profile",
|
||||||
|
];
|
||||||
|
return toolTitles;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,8 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
final usernameController = TextEditingController();
|
final usernameController = TextEditingController();
|
||||||
final fnameController = TextEditingController();
|
final fnameController = TextEditingController();
|
||||||
final lnameController = TextEditingController();
|
final lnameController = TextEditingController();
|
||||||
|
final purposeController = TextEditingController();
|
||||||
|
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
|
||||||
PlatformFile? proPic;
|
PlatformFile? proPic;
|
||||||
late ImageProvider<Object>? propicPreview;
|
late ImageProvider<Object>? propicPreview;
|
||||||
late bool businessUser;
|
late bool businessUser;
|
||||||
@@ -112,12 +114,13 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateUserApiCall() async {
|
Future<void> updateUserApiCall() async {
|
||||||
int responseCode = await MihUserServices().updateUser(
|
int responseCode = await MihUserServices().updateUserV2(
|
||||||
widget.arguments.signedInUser,
|
widget.arguments.signedInUser,
|
||||||
fnameController.text,
|
fnameController.text,
|
||||||
lnameController.text,
|
lnameController.text,
|
||||||
usernameController.text,
|
usernameController.text,
|
||||||
proPicController.text,
|
proPicController.text,
|
||||||
|
purposeController.text,
|
||||||
businessUser,
|
businessUser,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
@@ -184,6 +187,14 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color getPurposeLimitColor(int limit) {
|
||||||
|
if (_counter.value <= limit) {
|
||||||
|
return MzanziInnovationHub.of(context)!.theme.secondaryColor();
|
||||||
|
} else {
|
||||||
|
return MzanziInnovationHub.of(context)!.theme.errorColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void editProfileWindow(double width) {
|
void editProfileWindow(double width) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -282,6 +293,52 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
height: 250,
|
||||||
|
fillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
inputColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
controller: purposeController,
|
||||||
|
multiLineInput: true,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Your Purpose",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices()
|
||||||
|
.validateLength(purposeController.text, 256);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
child: ValueListenableBuilder(
|
||||||
|
valueListenable: _counter,
|
||||||
|
builder:
|
||||||
|
(BuildContext context, int value, Widget? child) {
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"$value",
|
||||||
|
style: TextStyle(
|
||||||
|
color: getPurposeLimitColor(256),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
Text(
|
||||||
|
"/256",
|
||||||
|
style: TextStyle(
|
||||||
|
color: getPurposeLimitColor(256),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
MihToggle(
|
MihToggle(
|
||||||
hintText: "Activate Business Account",
|
hintText: "Activate Business Account",
|
||||||
initialPostion: businessUser,
|
initialPostion: businessUser,
|
||||||
@@ -336,11 +393,13 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
usernameController.dispose();
|
usernameController.dispose();
|
||||||
fnameController.dispose();
|
fnameController.dispose();
|
||||||
lnameController.dispose();
|
lnameController.dispose();
|
||||||
|
purposeController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
super.initState();
|
||||||
var proPicName = "";
|
var proPicName = "";
|
||||||
if (widget.arguments.signedInUser.pro_pic_path.isNotEmpty) {
|
if (widget.arguments.signedInUser.pro_pic_path.isNotEmpty) {
|
||||||
proPicName = widget.arguments.signedInUser.pro_pic_path.split("/").last;
|
proPicName = widget.arguments.signedInUser.pro_pic_path.split("/").last;
|
||||||
@@ -350,6 +409,11 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
} else {
|
} else {
|
||||||
env = "Dev";
|
env = "Dev";
|
||||||
}
|
}
|
||||||
|
purposeController.addListener(() {
|
||||||
|
setState(() {
|
||||||
|
_counter.value = purposeController.text.characters.length;
|
||||||
|
});
|
||||||
|
});
|
||||||
setState(() {
|
setState(() {
|
||||||
propicPreview = widget.arguments.propicFile;
|
propicPreview = widget.arguments.propicFile;
|
||||||
oldProPicName = proPicName;
|
oldProPicName = proPicName;
|
||||||
@@ -357,9 +421,9 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
fnameController.text = widget.arguments.signedInUser.fname;
|
fnameController.text = widget.arguments.signedInUser.fname;
|
||||||
lnameController.text = widget.arguments.signedInUser.lname;
|
lnameController.text = widget.arguments.signedInUser.lname;
|
||||||
usernameController.text = widget.arguments.signedInUser.username;
|
usernameController.text = widget.arguments.signedInUser.username;
|
||||||
|
purposeController.text = widget.arguments.signedInUser.purpose;
|
||||||
businessUser = isBusinessUser();
|
businessUser = isBusinessUser();
|
||||||
});
|
});
|
||||||
super.initState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -404,7 +468,9 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
),
|
),
|
||||||
FittedBox(
|
FittedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
"@${widget.arguments.signedInUser.username}",
|
widget.arguments.signedInUser.username.isNotEmpty
|
||||||
|
? widget.arguments.signedInUser.username
|
||||||
|
: "username",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 35,
|
fontSize: 35,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@@ -416,7 +482,9 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
),
|
),
|
||||||
FittedBox(
|
FittedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
"${widget.arguments.signedInUser.fname} ${widget.arguments.signedInUser.lname}",
|
widget.arguments.signedInUser.fname.isNotEmpty
|
||||||
|
? "${widget.arguments.signedInUser.fname} ${widget.arguments.signedInUser.lname}"
|
||||||
|
: "Name Surname",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 25,
|
fontSize: 25,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@@ -438,20 +506,25 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
// Center(
|
Center(
|
||||||
// child: Text(
|
child: SizedBox(
|
||||||
// "*DEMO TEXT* This would be the bio of the user telling us a bit about themself and let. This would be the bio of the user telling us a bit about themself and let. This would be the bio of the user telling us a bit about themself",
|
width: 700,
|
||||||
// textAlign: TextAlign.center,
|
child: Text(
|
||||||
// style: TextStyle(
|
widget.arguments.signedInUser.purpose.isNotEmpty
|
||||||
// fontSize: 15,
|
? widget.arguments.signedInUser.purpose
|
||||||
// fontWeight: FontWeight.bold,
|
: "No purpose added yet",
|
||||||
// color: MzanziInnovationHub.of(context)!
|
textAlign: TextAlign.center,
|
||||||
// .theme
|
style: TextStyle(
|
||||||
// .secondaryColor(),
|
fontSize: 15,
|
||||||
// ),
|
fontWeight: FontWeight.bold,
|
||||||
// ),
|
color: MzanziInnovationHub.of(context)!
|
||||||
// ),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 30.0),
|
const SizedBox(height: 30.0),
|
||||||
Center(
|
Center(
|
||||||
child: MihButton(
|
child: MihButton(
|
||||||
@@ -463,7 +536,9 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||||||
MzanziInnovationHub.of(context)!.theme.successColor(),
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
width: 300,
|
width: 300,
|
||||||
child: Text(
|
child: Text(
|
||||||
"Edit Profile",
|
widget.arguments.signedInUser.username.isEmpty
|
||||||
|
? "Set Up Profile"
|
||||||
|
: "Edit Profile",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: MzanziInnovationHub.of(context)!
|
color: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
|
|||||||
@@ -0,0 +1,198 @@
|
|||||||
|
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_package_components/mih_icons.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_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_package_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class MihPersonalProfileView extends StatefulWidget {
|
||||||
|
final AppUser user;
|
||||||
|
const MihPersonalProfileView({
|
||||||
|
super.key,
|
||||||
|
required this.user,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihPersonalProfileView> createState() => _MihPersonalProfileViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
|
||||||
|
late Future<String> futureImageUrl;
|
||||||
|
PlatformFile? file;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
futureImageUrl =
|
||||||
|
MihFileApi.getMinioFileUrl(widget.user.pro_pic_path, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
return MihPackageToolBody(
|
||||||
|
borderOn: false,
|
||||||
|
innerHorizontalPadding: 10,
|
||||||
|
bodyItem: getBody(screenWidth),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getBody(double width) {
|
||||||
|
double profilePictureWidth = 150;
|
||||||
|
return MihSingleChildScroll(
|
||||||
|
child: Padding(
|
||||||
|
padding: MzanziInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||||
|
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||||
|
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
FutureBuilder(
|
||||||
|
future: futureImageUrl,
|
||||||
|
builder: (context, asyncSnapshot) {
|
||||||
|
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||||
|
asyncSnapshot.hasData) {
|
||||||
|
if (asyncSnapshot.requireData != "") {
|
||||||
|
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.iDontKnow,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Icon(
|
||||||
|
MihIcons.mihRing,
|
||||||
|
size: profilePictureWidth,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// return Center(
|
||||||
|
// child: MihCircleAvatar(
|
||||||
|
// imageFile: propicPreview,
|
||||||
|
// width: 150,
|
||||||
|
// editable: false,
|
||||||
|
// fileNameController: proPicController,
|
||||||
|
// userSelectedfile: proPic,
|
||||||
|
// frameColor: MzanziInnovationHub.of(context)!
|
||||||
|
// .theme
|
||||||
|
// .secondaryColor(),
|
||||||
|
// backgroundColor:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
// onChange: (selectedImage) {
|
||||||
|
// setState(() {
|
||||||
|
// proPic = selectedImage;
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
}),
|
||||||
|
FittedBox(
|
||||||
|
child: Text(
|
||||||
|
widget.user.username.isNotEmpty
|
||||||
|
? widget.user.username
|
||||||
|
: "Username",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 35,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FittedBox(
|
||||||
|
child: Text(
|
||||||
|
widget.user.fname.isNotEmpty
|
||||||
|
? "${widget.user.fname} ${widget.user.lname}"
|
||||||
|
: "Name Surname",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FittedBox(
|
||||||
|
child: Text(
|
||||||
|
widget.user.type.toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 700,
|
||||||
|
child: Text(
|
||||||
|
widget.user.purpose.isNotEmpty
|
||||||
|
? widget.user.purpose
|
||||||
|
: "No purpose added yet",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30.0),
|
||||||
|
// Center(
|
||||||
|
// child: MihButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// // Connect with the user
|
||||||
|
// },
|
||||||
|
// buttonColor:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
// width: 300,
|
||||||
|
// child: Text(
|
||||||
|
// widget.user.username.isEmpty
|
||||||
|
// ? "Set Up Profile"
|
||||||
|
// : "Edit Profile",
|
||||||
|
// style: TextStyle(
|
||||||
|
// color:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
// fontSize: 20,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,26 @@ import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
|||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
|
|
||||||
class MihBusinessDetailsServices {
|
class MihBusinessDetailsServices {
|
||||||
|
Future<List<Business>> searchBusinesses(
|
||||||
|
String searchText,
|
||||||
|
BuildContext context,
|
||||||
|
) async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse("${AppEnviroment.baseApiUrl}/businesses/search/$searchText"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Iterable l = jsonDecode(response.body);
|
||||||
|
List<Business> businesses =
|
||||||
|
List<Business>.from(l.map((model) => Business.fromJson(model)));
|
||||||
|
return businesses;
|
||||||
|
} else {
|
||||||
|
throw Exception('failed to load users');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<Business?> getBusinessDetails(
|
Future<Business?> getBusinessDetails(
|
||||||
String app_id,
|
String app_id,
|
||||||
) async {
|
) async {
|
||||||
@@ -38,6 +58,9 @@ class MihBusinessDetailsServices {
|
|||||||
String businessPhoneNumber,
|
String businessPhoneNumber,
|
||||||
String businessLocation,
|
String businessLocation,
|
||||||
String businessLogoFilename,
|
String businessLogoFilename,
|
||||||
|
String businessWebsite,
|
||||||
|
String businessRating,
|
||||||
|
String businessMissionVision,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
) async {
|
) async {
|
||||||
showDialog(
|
showDialog(
|
||||||
@@ -46,6 +69,9 @@ class MihBusinessDetailsServices {
|
|||||||
return const Mihloadingcircle();
|
return const Mihloadingcircle();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
String logoPath = businessLogoFilename.isNotEmpty
|
||||||
|
? "$appId/business_files/$businessLogoFilename"
|
||||||
|
: "";
|
||||||
var response = await http.post(
|
var response = await http.post(
|
||||||
Uri.parse("${AppEnviroment.baseApiUrl}/business/insert/"),
|
Uri.parse("${AppEnviroment.baseApiUrl}/business/insert/"),
|
||||||
headers: <String, String>{
|
headers: <String, String>{
|
||||||
@@ -56,18 +82,73 @@ class MihBusinessDetailsServices {
|
|||||||
"type": businessType,
|
"type": businessType,
|
||||||
"registration_no": businessRegistrationNo,
|
"registration_no": businessRegistrationNo,
|
||||||
"logo_name": businessLogoFilename,
|
"logo_name": businessLogoFilename,
|
||||||
"logo_path": "$appId/business_files/$businessLogoFilename",
|
"logo_path": logoPath,
|
||||||
"contact_no": businessPhoneNumber,
|
"contact_no": businessPhoneNumber,
|
||||||
"bus_email": businessEmail,
|
"bus_email": businessEmail,
|
||||||
"gps_location": businessLocation,
|
"gps_location": businessLocation,
|
||||||
"practice_no": businessPracticeNo,
|
"practice_no": businessPracticeNo,
|
||||||
"vat_no": businessVatNo,
|
"vat_no": businessVatNo,
|
||||||
|
"website": businessWebsite,
|
||||||
|
"rating": businessRating,
|
||||||
|
"mission_vision": businessMissionVision,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> updateBusinessDetailsV2(
|
||||||
|
String business_id,
|
||||||
|
String business_name,
|
||||||
|
String business_type,
|
||||||
|
String business_registration_no,
|
||||||
|
String business_practice_no,
|
||||||
|
String business_vat_no,
|
||||||
|
String business_email,
|
||||||
|
String business_phone_number,
|
||||||
|
String business_location,
|
||||||
|
String business_logo_name,
|
||||||
|
String businessWebsite,
|
||||||
|
String businessRating,
|
||||||
|
String businessMissionVision,
|
||||||
|
BuildContext context,
|
||||||
|
) async {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const Mihloadingcircle();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
var response = await http.put(
|
||||||
|
Uri.parse("${AppEnviroment.baseApiUrl}/business/update/v2/"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
body: jsonEncode(<String, dynamic>{
|
||||||
|
"business_id": business_id,
|
||||||
|
"Name": business_name,
|
||||||
|
"type": business_type,
|
||||||
|
"registration_no": business_registration_no,
|
||||||
|
"logo_name": business_logo_name,
|
||||||
|
"logo_path": "$business_id/business_files/$business_logo_name",
|
||||||
|
"contact_no": business_phone_number,
|
||||||
|
"bus_email": business_email,
|
||||||
|
"gps_location": business_location,
|
||||||
|
"practice_no": business_practice_no,
|
||||||
|
"vat_no": business_vat_no,
|
||||||
|
"website": businessWebsite,
|
||||||
|
"rating": businessRating,
|
||||||
|
"mission_vision": businessMissionVision,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return 200;
|
||||||
|
} else {
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> updateBusinessDetails(
|
Future<int> updateBusinessDetails(
|
||||||
String business_id,
|
String business_id,
|
||||||
String business_name,
|
String business_name,
|
||||||
@@ -110,7 +191,6 @@ class MihBusinessDetailsServices {
|
|||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return 200;
|
return 200;
|
||||||
} else {
|
} else {
|
||||||
internetConnectionPopUp(context);
|
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||||
@@ -14,29 +13,20 @@ class MIHLocationAPI {
|
|||||||
///if user has blocked permission (denied or denied forver), user will get error pop up.
|
///if user has blocked permission (denied or denied forver), user will get error pop up.
|
||||||
///if user has granted permission (while in use), function will return Position object.
|
///if user has granted permission (while in use), function will return Position object.
|
||||||
Future<Position?> getGPSPosition(BuildContext context) async {
|
Future<Position?> getGPSPosition(BuildContext context) async {
|
||||||
showDialog(
|
print("Before checkPermission"); // Debug
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return const Mihloadingcircle();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
//Check the type of permission granted
|
|
||||||
LocationPermission permission = await Geolocator.checkPermission();
|
LocationPermission permission = await Geolocator.checkPermission();
|
||||||
|
print("After checkPermission: $permission"); // Debug
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
//First time user (auto denied pernission) request permission from user
|
|
||||||
permission = await Geolocator.requestPermission();
|
permission = await Geolocator.requestPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
//User denied permission
|
|
||||||
showPermissionError(context);
|
showPermissionError(context);
|
||||||
return null;
|
return null;
|
||||||
} else if (permission == LocationPermission.deniedForever) {
|
} else if (permission == LocationPermission.deniedForever) {
|
||||||
//User denied permission Forever
|
|
||||||
showPermissionError(context);
|
showPermissionError(context);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
Position location = await Geolocator.getCurrentPosition(
|
Position location = await Geolocator.getCurrentPosition(
|
||||||
locationSettings: locationSettings);
|
locationSettings: locationSettings);
|
||||||
//print(location);
|
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
} else if (permission == LocationPermission.deniedForever) {
|
} else if (permission == LocationPermission.deniedForever) {
|
||||||
@@ -45,15 +35,17 @@ class MIHLocationAPI {
|
|||||||
} else {
|
} else {
|
||||||
Position location = await Geolocator.getCurrentPosition(
|
Position location = await Geolocator.getCurrentPosition(
|
||||||
locationSettings: locationSettings);
|
locationSettings: locationSettings);
|
||||||
//print(location);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|||||||
@@ -63,6 +63,26 @@ class MihUserServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<AppUser>> searchUsers(
|
||||||
|
String searchText,
|
||||||
|
BuildContext context,
|
||||||
|
) async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse("${AppEnviroment.baseApiUrl}/users/search/$searchText"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Iterable l = jsonDecode(response.body);
|
||||||
|
List<AppUser> users =
|
||||||
|
List<AppUser>.from(l.map((model) => AppUser.fromJson(model)));
|
||||||
|
return users;
|
||||||
|
} else {
|
||||||
|
throw Exception('failed to load users');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<AppUser?> getUserDetails(
|
Future<AppUser?> getUserDetails(
|
||||||
String app_id,
|
String app_id,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
@@ -83,6 +103,46 @@ class MihUserServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> updateUserV2(
|
||||||
|
AppUser signedInUser,
|
||||||
|
String firstName,
|
||||||
|
String lastName,
|
||||||
|
String username,
|
||||||
|
String profilePicture,
|
||||||
|
String purpose,
|
||||||
|
bool isBusinessUser,
|
||||||
|
BuildContext context,
|
||||||
|
) async {
|
||||||
|
var fileName = profilePicture.replaceAll(RegExp(r' '), '-');
|
||||||
|
var filePath = "${signedInUser.app_id}/profile_files/$fileName";
|
||||||
|
String profileType;
|
||||||
|
if (isBusinessUser) {
|
||||||
|
profileType = "business";
|
||||||
|
} else {
|
||||||
|
profileType = "personal";
|
||||||
|
}
|
||||||
|
var response = await http.put(
|
||||||
|
Uri.parse("${AppEnviroment.baseApiUrl}/user/update/v2/"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
body: jsonEncode(<String, dynamic>{
|
||||||
|
"idusers": signedInUser.idUser,
|
||||||
|
"username": username,
|
||||||
|
"fnam": firstName,
|
||||||
|
"lname": lastName,
|
||||||
|
"type": profileType,
|
||||||
|
"pro_pic_path": filePath,
|
||||||
|
"purpose": purpose,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return response.statusCode;
|
||||||
|
} else {
|
||||||
|
return response.statusCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> updateUser(
|
Future<int> updateUser(
|
||||||
AppUser signedInUser,
|
AppUser signedInUser,
|
||||||
String firstName,
|
String firstName,
|
||||||
|
|||||||
@@ -16,6 +16,18 @@ class MihValidationServices {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? validateWebsite(String? website, bool required) {
|
||||||
|
final websiteRegex = RegExp(
|
||||||
|
r'^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$');
|
||||||
|
if (!required && website!.isEmpty) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!websiteRegex.hasMatch(website!)) {
|
||||||
|
return "Invalid Website Format";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String? validateEmail(String? email) {
|
String? validateEmail(String? email) {
|
||||||
if (email == null || email.isEmpty) {
|
if (email == null || email.isEmpty) {
|
||||||
return "Email is required";
|
return "Email is required";
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ class businessInsertRequest(BaseModel):
|
|||||||
gps_location: str
|
gps_location: str
|
||||||
practice_no: str
|
practice_no: str
|
||||||
vat_no: str
|
vat_no: str
|
||||||
|
website: str
|
||||||
|
rating: str
|
||||||
|
mission_vision: str
|
||||||
|
|
||||||
class businessUpdateRequest(BaseModel):
|
class businessUpdateRequest(BaseModel):
|
||||||
business_id: str
|
business_id: str
|
||||||
@@ -41,6 +44,60 @@ class businessUpdateRequest(BaseModel):
|
|||||||
practice_no: str
|
practice_no: str
|
||||||
vat_no: str
|
vat_no: str
|
||||||
|
|
||||||
|
class businessUpdateRequestV2(BaseModel):
|
||||||
|
business_id: str
|
||||||
|
Name: str
|
||||||
|
type: str
|
||||||
|
registration_no: str
|
||||||
|
logo_name: str
|
||||||
|
logo_path: str
|
||||||
|
contact_no: str
|
||||||
|
bus_email: str
|
||||||
|
gps_location: str
|
||||||
|
practice_no: str
|
||||||
|
vat_no: str
|
||||||
|
website: str
|
||||||
|
rating: str
|
||||||
|
mission_vision: str
|
||||||
|
|
||||||
|
|
||||||
|
# Get List of all files
|
||||||
|
@router.get("/businesses/search/{search}", tags=["MIH Business"])
|
||||||
|
async def read_all_businesses(search: str, session: SessionContainer = Depends(verify_session())): #, session: SessionContainer = Depends(verify_session())
|
||||||
|
db = database.dbConnection.dbAppDataConnect()
|
||||||
|
cursor = db.cursor()
|
||||||
|
query = "SELECT business.business_id, business.Name, business.type, business.registration_no, "
|
||||||
|
query += "business.logo_name, business.logo_path, business.contact_no, business.bus_email, "
|
||||||
|
query += "business.gps_location, "
|
||||||
|
query += "practice_no, vat_no, "
|
||||||
|
query += "website, rating, mission_vision "
|
||||||
|
query += "FROM business "
|
||||||
|
query += "WHERE LOWER(business.Name) LIKE %s OR LOWER(business.type) LIKE %s"
|
||||||
|
search_term = f"%{search.lower()}%" # Add wildcards and lowercase
|
||||||
|
cursor.execute(query, (search_term, search_term))
|
||||||
|
items = [
|
||||||
|
{
|
||||||
|
"business_id": item[0],
|
||||||
|
"Name": item[1],
|
||||||
|
"type": item[2],
|
||||||
|
"registration_no": item[3],
|
||||||
|
"logo_name": item[4],
|
||||||
|
"logo_path": item[5],
|
||||||
|
"contact_no": item[6],
|
||||||
|
"bus_email": item[7],
|
||||||
|
"app_id": "",
|
||||||
|
"gps_location": item[8],
|
||||||
|
"practice_no": item[9],
|
||||||
|
"vat_no": item[10],
|
||||||
|
"website": item[11],
|
||||||
|
"rating": item[12],
|
||||||
|
"mission_vision": item[13],
|
||||||
|
}
|
||||||
|
for item in cursor.fetchall()
|
||||||
|
]
|
||||||
|
cursor.close()
|
||||||
|
db.close()
|
||||||
|
return items
|
||||||
|
|
||||||
# Get List of all files
|
# Get List of all files
|
||||||
@router.get("/business/business_id/{business_id}", tags=["MIH Business"])
|
@router.get("/business/business_id/{business_id}", tags=["MIH Business"])
|
||||||
@@ -50,7 +107,8 @@ async def read_business_by_business_id(business_id: str, session: SessionContain
|
|||||||
query = "SELECT business.business_id, business.Name, business.type, business.registration_no, "
|
query = "SELECT business.business_id, business.Name, business.type, business.registration_no, "
|
||||||
query += "business.logo_name, business.logo_path, business.contact_no, business.bus_email, "
|
query += "business.logo_name, business.logo_path, business.contact_no, business.bus_email, "
|
||||||
query += "business_users.app_id, business.gps_location, "
|
query += "business_users.app_id, business.gps_location, "
|
||||||
query += "practice_no, vat_no "
|
query += "practice_no, vat_no, "
|
||||||
|
query += "website, rating, mission_vision "
|
||||||
query += "FROM business "
|
query += "FROM business "
|
||||||
query += "inner join business_users "
|
query += "inner join business_users "
|
||||||
query += "on business.business_id=business_users.business_id "
|
query += "on business.business_id=business_users.business_id "
|
||||||
@@ -73,6 +131,9 @@ async def read_business_by_business_id(business_id: str, session: SessionContain
|
|||||||
"gps_location": item[9],
|
"gps_location": item[9],
|
||||||
"practice_no": item[10],
|
"practice_no": item[10],
|
||||||
"vat_no": item[11],
|
"vat_no": item[11],
|
||||||
|
"website": item[12],
|
||||||
|
"rating": item[13],
|
||||||
|
"mission_vision": item[14],
|
||||||
}
|
}
|
||||||
for item in cursor.fetchall()
|
for item in cursor.fetchall()
|
||||||
]
|
]
|
||||||
@@ -93,7 +154,8 @@ async def read_business_by_app_id(app_id: str, session: SessionContainer = Depen
|
|||||||
query = "SELECT business.business_id, business.Name, business.type, business.registration_no, "
|
query = "SELECT business.business_id, business.Name, business.type, business.registration_no, "
|
||||||
query += "business.logo_name, business.logo_path, business.contact_no, business.bus_email, "
|
query += "business.logo_name, business.logo_path, business.contact_no, business.bus_email, "
|
||||||
query += "business_users.app_id, business.gps_location, "
|
query += "business_users.app_id, business.gps_location, "
|
||||||
query += "practice_no, vat_no "
|
query += "practice_no, vat_no, "
|
||||||
|
query += "website, rating, mission_vision "
|
||||||
query += "FROM business "
|
query += "FROM business "
|
||||||
query += "inner join business_users "
|
query += "inner join business_users "
|
||||||
query += "on business.business_id=business_users.business_id "
|
query += "on business.business_id=business_users.business_id "
|
||||||
@@ -116,6 +178,9 @@ async def read_business_by_app_id(app_id: str, session: SessionContainer = Depen
|
|||||||
"gps_location": item[9],
|
"gps_location": item[9],
|
||||||
"practice_no": item[10],
|
"practice_no": item[10],
|
||||||
"vat_no": item[11],
|
"vat_no": item[11],
|
||||||
|
"website": item[12],
|
||||||
|
"rating": item[13],
|
||||||
|
"mission_vision": item[14],
|
||||||
}
|
}
|
||||||
for item in cursor.fetchall()
|
for item in cursor.fetchall()
|
||||||
]
|
]
|
||||||
@@ -132,8 +197,8 @@ async def insert_business_details(itemRequest : businessInsertRequest, session:
|
|||||||
db = database.dbConnection.dbAppDataConnect()
|
db = database.dbConnection.dbAppDataConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "insert into business "
|
query = "insert into business "
|
||||||
query += "(business_id, Name, type, registration_no, logo_name, logo_path, contact_no, bus_email, gps_location, practice_no, vat_no) "
|
query += "(business_id, Name, type, registration_no, logo_name, logo_path, contact_no, bus_email, gps_location, practice_no, vat_no, website, rating, mission_vision) "
|
||||||
query += "values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
query += "values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||||
uuidString = str(uuid.uuid1())
|
uuidString = str(uuid.uuid1())
|
||||||
userData = (uuidString,
|
userData = (uuidString,
|
||||||
itemRequest.Name,
|
itemRequest.Name,
|
||||||
@@ -145,9 +210,12 @@ async def insert_business_details(itemRequest : businessInsertRequest, session:
|
|||||||
itemRequest.bus_email,
|
itemRequest.bus_email,
|
||||||
itemRequest.gps_location,
|
itemRequest.gps_location,
|
||||||
itemRequest.practice_no,
|
itemRequest.practice_no,
|
||||||
itemRequest.vat_no)
|
itemRequest.vat_no,
|
||||||
|
itemRequest.website,
|
||||||
|
itemRequest.rating,
|
||||||
|
itemRequest.mission_vision,
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
|
|
||||||
print(query)
|
print(query)
|
||||||
print(userData)
|
print(userData)
|
||||||
cursor.execute(query, userData)
|
cursor.execute(query, userData)
|
||||||
@@ -188,3 +256,36 @@ async def Update_Business_details(itemRequest : businessUpdateRequest, session:
|
|||||||
cursor.close()
|
cursor.close()
|
||||||
db.close()
|
db.close()
|
||||||
return {"message": "Successfully Updated Record"}
|
return {"message": "Successfully Updated Record"}
|
||||||
|
|
||||||
|
@router.put("/business/update/v2/", tags=["MIH Business"])
|
||||||
|
async def Update_Business_details(itemRequest : businessUpdateRequestV2, session: SessionContainer = Depends(verify_session())): #, session: SessionContainer = Depends(verify_session())
|
||||||
|
db = database.dbConnection.dbAppDataConnect()
|
||||||
|
# print(itemRequest.gps_location)
|
||||||
|
cursor = db.cursor()
|
||||||
|
query = "update business "
|
||||||
|
query += "set Name=%s, type=%s, registration_no=%s, logo_name=%s, logo_path=%s, contact_no=%s, bus_email=%s, gps_location=%s, practice_no=%s, vat_no=%s, website=%s, rating=%s, mission_vision=%s "
|
||||||
|
query += "where business_id=%s"
|
||||||
|
userData = (itemRequest.Name,
|
||||||
|
itemRequest.type,
|
||||||
|
itemRequest.registration_no,
|
||||||
|
itemRequest.logo_name,
|
||||||
|
itemRequest.logo_path,
|
||||||
|
itemRequest.contact_no,
|
||||||
|
itemRequest.bus_email,
|
||||||
|
itemRequest.gps_location,
|
||||||
|
itemRequest.practice_no,
|
||||||
|
itemRequest.vat_no,
|
||||||
|
itemRequest.website,
|
||||||
|
itemRequest.rating,
|
||||||
|
itemRequest.mission_vision,
|
||||||
|
itemRequest.business_id,
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
cursor.execute(query, userData)
|
||||||
|
except Exception as error:
|
||||||
|
raise HTTPException(status_code=404, detail=error)
|
||||||
|
#return {"query": query, "message": error}
|
||||||
|
db.commit()
|
||||||
|
cursor.close()
|
||||||
|
db.close()
|
||||||
|
return {"message": "Successfully Updated Record"}
|
||||||
@@ -22,6 +22,15 @@ class userInsertRequest(BaseModel):
|
|||||||
email: str
|
email: str
|
||||||
app_id: str
|
app_id: str
|
||||||
|
|
||||||
|
class userUpdateRequestV2(BaseModel):
|
||||||
|
idusers: int
|
||||||
|
username: str
|
||||||
|
fnam: str
|
||||||
|
lname: str
|
||||||
|
type: str
|
||||||
|
pro_pic_path: str
|
||||||
|
purpose: str
|
||||||
|
|
||||||
class userUpdateRequest(BaseModel):
|
class userUpdateRequest(BaseModel):
|
||||||
idusers: int
|
idusers: int
|
||||||
username: str
|
username: str
|
||||||
@@ -76,6 +85,7 @@ async def read_all_users(search: str, session: SessionContainer = Depends(verify
|
|||||||
"app_id": item[5],
|
"app_id": item[5],
|
||||||
"username": item[6],
|
"username": item[6],
|
||||||
"pro_pic_path": item[7],
|
"pro_pic_path": item[7],
|
||||||
|
"purpose": item[8],
|
||||||
}
|
}
|
||||||
for item in cursor.fetchall()
|
for item in cursor.fetchall()
|
||||||
]
|
]
|
||||||
@@ -113,6 +123,7 @@ async def read_users_by_app_id(app_id: str, session: SessionContainer = Depends(
|
|||||||
"app_id": item[5],
|
"app_id": item[5],
|
||||||
"username": item[6],
|
"username": item[6],
|
||||||
"pro_pic_path": item[7],
|
"pro_pic_path": item[7],
|
||||||
|
"purpose": item[8],
|
||||||
}
|
}
|
||||||
for item in cursor.fetchall()
|
for item in cursor.fetchall()
|
||||||
]
|
]
|
||||||
@@ -126,10 +137,10 @@ async def insert_User_details(itemRequest : userInsertRequest, session: SessionC
|
|||||||
db = database.dbConnection.dbAppDataConnect()
|
db = database.dbConnection.dbAppDataConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "insert into users "
|
query = "insert into users "
|
||||||
query += "(email, fname, lname, type, app_id, username, pro_pic_path) "
|
query += "(email, fname, lname, type, app_id, username, pro_pic_path, purpose) "
|
||||||
query += "values (%s, %s, %s, %s, %s, %s, %s)"
|
query += "values (%s, %s, %s, %s, %s, %s, %s, %s)"
|
||||||
userData = (itemRequest.email,"","","personal",
|
userData = (itemRequest.email,"","","personal",
|
||||||
itemRequest.app_id, "", "")
|
itemRequest.app_id, "", "","")
|
||||||
try:
|
try:
|
||||||
cursor.execute(query, userData)
|
cursor.execute(query, userData)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
@@ -140,6 +151,32 @@ async def insert_User_details(itemRequest : userInsertRequest, session: SessionC
|
|||||||
db.close()
|
db.close()
|
||||||
return {"message": "Successfully Created Record"}
|
return {"message": "Successfully Created Record"}
|
||||||
|
|
||||||
|
# Update User on table
|
||||||
|
@router.put("/user/update/v2/", tags=["MIH Users"])
|
||||||
|
async def Update_User_details(itemRequest : userUpdateRequestV2, session: SessionContainer = Depends(verify_session())):
|
||||||
|
db = database.dbConnection.dbAppDataConnect()
|
||||||
|
cursor = db.cursor()
|
||||||
|
query = "update users "
|
||||||
|
query += "set username=%s, fname=%s, lname=%s, type=%s, pro_pic_path=%s, purpose=%s "
|
||||||
|
query += "where idusers=%s"
|
||||||
|
userData = (itemRequest.username,
|
||||||
|
itemRequest.fnam,
|
||||||
|
itemRequest.lname,
|
||||||
|
itemRequest.type,
|
||||||
|
itemRequest.pro_pic_path,
|
||||||
|
itemRequest.purpose,
|
||||||
|
itemRequest.idusers,
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
cursor.execute(query, userData)
|
||||||
|
except Exception as error:
|
||||||
|
raise HTTPException(status_code=404, detail=error)
|
||||||
|
#return {"query": query, "message": error}
|
||||||
|
db.commit()
|
||||||
|
cursor.close()
|
||||||
|
db.close()
|
||||||
|
return {"message": "Successfully Updated Record"}
|
||||||
|
|
||||||
# Update User on table
|
# Update User on table
|
||||||
@router.put("/user/update/", tags=["MIH Users"])
|
@router.put("/user/update/", tags=["MIH Users"])
|
||||||
async def Update_User_details(itemRequest : userUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
async def Update_User_details(itemRequest : userUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
|
|||||||
Reference in New Issue
Block a user