v.1.2.7 #36
+7
-15
@@ -24,7 +24,6 @@ class MzansiBusinessProfileView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
int _selectedIndex = 0;
|
||||
late final MihBusinessDetailsView _businessDetailsView;
|
||||
late final MihBusinessReviews _businessReviews;
|
||||
late final MihBusinessQrCode _businessQrCode;
|
||||
@@ -57,6 +56,7 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
super.initState();
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
directoryProvider.setBusinessViewIndex(0);
|
||||
_fetchBusinessDetails(directoryProvider);
|
||||
}
|
||||
|
||||
@@ -78,11 +78,9 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
packageTools: getTools(),
|
||||
packageToolBodies: getToolBody(directoryProvider),
|
||||
packageToolTitles: getToolTitle(),
|
||||
selectedBodyIndex: _selectedIndex,
|
||||
selectedBodyIndex: directoryProvider.businessViewIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selectedIndex = newValue;
|
||||
});
|
||||
directoryProvider.setBusinessViewIndex(newValue);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -114,23 +112,17 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.business)] = () {
|
||||
setState(() {
|
||||
_selectedIndex = 0;
|
||||
});
|
||||
context.read<MzansiDirectoryProvider>().setBusinessViewIndex(0);
|
||||
};
|
||||
temp[const Icon(Icons.star_rate_rounded)] = () {
|
||||
setState(() {
|
||||
_selectedIndex = 1;
|
||||
});
|
||||
context.read<MzansiDirectoryProvider>().setBusinessViewIndex(1);
|
||||
};
|
||||
temp[const Icon(Icons.qr_code_rounded)] = () {
|
||||
setState(() {
|
||||
_selectedIndex = 2;
|
||||
});
|
||||
context.read<MzansiDirectoryProvider>().setBusinessViewIndex(2);
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selectedIndex: _selectedIndex,
|
||||
selectedIndex: context.watch<MzansiDirectoryProvider>().businessViewIndex,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ class MzansiProfileView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MzansiProfileViewState extends State<MzansiProfileView> {
|
||||
int _selectedIndex = 0;
|
||||
late final MihPersonalProfileView _personalProfileView;
|
||||
late final MihPersonalQrCode _personalQrCode;
|
||||
|
||||
void _loadUserData() async {
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
directoryProvider.setPersonalViewIndex(0);
|
||||
if (widget.username != null) {
|
||||
final user = await MihUserServices()
|
||||
.getMIHUserDetailsByUsername(widget.username!, context);
|
||||
@@ -68,11 +68,9 @@ class _MzansiProfileViewState extends State<MzansiProfileView> {
|
||||
packageTools: getTools(),
|
||||
packageToolBodies: getToolBody(),
|
||||
packageToolTitles: getToolTitle(),
|
||||
selectedBodyIndex: _selectedIndex,
|
||||
selectedBodyIndex: directoryProvider.personalViewIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selectedIndex = newValue;
|
||||
});
|
||||
directoryProvider.setPersonalViewIndex(newValue);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -95,18 +93,14 @@ class _MzansiProfileViewState extends State<MzansiProfileView> {
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.person)] = () {
|
||||
setState(() {
|
||||
_selectedIndex = 0;
|
||||
});
|
||||
context.read<MzansiDirectoryProvider>().setPersonalViewIndex(0);
|
||||
};
|
||||
temp[const Icon(Icons.qr_code_rounded)] = () {
|
||||
setState(() {
|
||||
_selectedIndex = 1;
|
||||
});
|
||||
context.read<MzansiDirectoryProvider>().setPersonalViewIndex(1);
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selectedIndex: _selectedIndex,
|
||||
selectedIndex: context.watch<MzansiDirectoryProvider>().personalViewIndex,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -56,7 +56,8 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
||||
String bgColor =
|
||||
MihColors.secondary().toARGB32().toRadixString(16).substring(2, 8);
|
||||
// KenLogger.warning(bgColor);
|
||||
String encodedData = Uri.encodeComponent("$_qrCodedata${user.username}");
|
||||
String encodedData =
|
||||
Uri.encodeComponent("$_qrCodedata${user.username.toLowerCase()}");
|
||||
return "https://api.qrserver.com/v1/create-qr-code/?data=$encodedData&size=${qrSize}x$qrSize&bgcolor=$bgColor&color=$color";
|
||||
}
|
||||
|
||||
@@ -398,7 +399,7 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
||||
shareMIHLink(
|
||||
context,
|
||||
"Check out ${user.username} on the MIH app's Mzansi Directory",
|
||||
"$_qrCodedata${user.username}",
|
||||
"$_qrCodedata${user.username.toLowerCase()}",
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -3,10 +3,11 @@ import 'package:geolocator/geolocator.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/bookmarked_business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/profile_link.dart';
|
||||
|
||||
class MzansiDirectoryProvider extends ChangeNotifier {
|
||||
int toolIndex;
|
||||
int personalViewIndex;
|
||||
int businessViewIndex;
|
||||
Position? userPosition;
|
||||
String userLocation;
|
||||
bool personalSearch;
|
||||
@@ -24,6 +25,8 @@ class MzansiDirectoryProvider extends ChangeNotifier {
|
||||
|
||||
MzansiDirectoryProvider({
|
||||
this.toolIndex = 0,
|
||||
this.personalViewIndex = 0,
|
||||
this.businessViewIndex = 0,
|
||||
this.personalSearch = true,
|
||||
this.userLocation = "Unknown Location",
|
||||
this.searchTerm = "",
|
||||
@@ -32,6 +35,8 @@ class MzansiDirectoryProvider extends ChangeNotifier {
|
||||
|
||||
void reset() {
|
||||
toolIndex = 0;
|
||||
personalViewIndex = 0;
|
||||
businessViewIndex = 0;
|
||||
userPosition = null;
|
||||
userLocation = "Unknown Location";
|
||||
personalSearch = true;
|
||||
@@ -50,6 +55,16 @@ class MzansiDirectoryProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setPersonalViewIndex(int index) {
|
||||
personalViewIndex = index;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setBusinessViewIndex(int index) {
|
||||
businessViewIndex = index;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setUserPosition(Position? position) {
|
||||
userPosition = position;
|
||||
if (position == null) {
|
||||
|
||||
Reference in New Issue
Block a user