switch to new image api strat and fix onboarding cache strat
This commit is contained in:
parent
48b434dad9
commit
a5bdee892c
39 changed files with 540 additions and 791 deletions
|
|
@ -1,18 +1,13 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_authentication_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_authentication_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
|
||||
class MihRegister extends StatefulWidget {
|
||||
const MihRegister({
|
||||
|
|
@ -31,142 +26,11 @@ class _MihRegisterState extends State<MihRegister> {
|
|||
final _formKey = GlobalKey<FormState>();
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
|
||||
Future<void> addUserAPICall(String email, String uid) async {
|
||||
//await getOfficeIdByUser(docOfficeIdApiUrl + widget.userEmail);
|
||||
//print(futureDocOfficeId.toString());
|
||||
await MihUserServices().createUser(
|
||||
email,
|
||||
uid,
|
||||
context,
|
||||
);
|
||||
// var response = await http.post(
|
||||
// Uri.parse("$baseAPI/user/insert/"),
|
||||
// headers: <String, String>{
|
||||
// "Content-Type": "application/json; charset=UTF-8"
|
||||
// },
|
||||
// body: jsonEncode(<String, dynamic>{
|
||||
// "email": email,
|
||||
// "app_id": uid,
|
||||
// }),
|
||||
// );
|
||||
// if (response.statusCode == 201) {
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
// '/',
|
||||
// (route) => false,
|
||||
// arguments: AuthArguments(
|
||||
// true,
|
||||
// true,
|
||||
// ),
|
||||
// );
|
||||
// // signUpSuccess();
|
||||
// // setState(() {
|
||||
// // successfulSignUp = true;
|
||||
// // });
|
||||
// } else {
|
||||
// internetConnectionPopUp();
|
||||
// }
|
||||
}
|
||||
|
||||
Future<void> signUserUp() async {
|
||||
context.read<MzansiProfileProvider>().reset();
|
||||
if (!validEmail()) {
|
||||
MihAlertServices().invalidEmailAlert(context);
|
||||
} else if (passwordController.text != confirmPasswordController.text) {
|
||||
MihAlertServices().passwordMatchAlert(context);
|
||||
} else {
|
||||
//var _backgroundColor = Colors.transparent;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
try {
|
||||
Uri uri = Uri.parse(
|
||||
"$baseAPI/auth/emailpassword/email/exists?email=${emailController.text}");
|
||||
//print("Here");
|
||||
var response = await http.get(uri);
|
||||
//print(response.body);
|
||||
//print("response 1: ${response.statusCode}");
|
||||
if (response.statusCode == 200) {
|
||||
var userExists = jsonDecode(response.body);
|
||||
if (userExists["exists"]) {
|
||||
Navigator.of(context).pop();
|
||||
MihAlertServices().emailExistsAlert(context);
|
||||
} else {
|
||||
var response2 = await http.post(
|
||||
Uri.parse("$baseAPI/auth/signup"),
|
||||
body:
|
||||
'{"formFields": [{"id": "email","value": "${emailController.text}"}, {"id": "password","value": "${passwordController.text}"}]}',
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
);
|
||||
//print("response 2: ${response2.statusCode}");
|
||||
if (response2.statusCode == 200) {
|
||||
//print("response 2: ${response2.body}");
|
||||
var userCreated = jsonDecode(response2.body);
|
||||
//print("Created user $userCreated");
|
||||
if (userCreated["status"] == "OK") {
|
||||
//print("Here1");
|
||||
//Creat user in db
|
||||
String uid = await SuperTokens.getUserId();
|
||||
//print("uid: $uid");
|
||||
addUserAPICall(emailController.text, uid);
|
||||
Navigator.of(context).pop();
|
||||
//print("Here1");
|
||||
} else if (userCreated["status"] == "FIELD_ERROR") {
|
||||
Navigator.of(context).pop();
|
||||
MihAlertServices().passwordRequirementAlert(context);
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} on Exception catch (error) {
|
||||
Navigator.of(context).pop();
|
||||
loginError(error.toString());
|
||||
emailController.clear();
|
||||
passwordController.clear();
|
||||
confirmPasswordController.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void submitFormInput() async {
|
||||
await signUserUp();
|
||||
}
|
||||
|
||||
bool validEmail() {
|
||||
String text = emailController.text;
|
||||
var regex = RegExp(r'^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$');
|
||||
return regex.hasMatch(text);
|
||||
}
|
||||
|
||||
void loginError(error) {
|
||||
MihAlertServices().errorAdvancedAlert(
|
||||
"Sign Up Error",
|
||||
"An error occurred while signing up: $error Please try again later.",
|
||||
[
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
buttonColor: MihColors.secondary(),
|
||||
width: 200,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
await MihAuthenticationServices().signUserUp(
|
||||
emailController.text,
|
||||
passwordController.text,
|
||||
confirmPasswordController.text,
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
|||
final proPicController = TextEditingController();
|
||||
late Widget profilePictureLoaded;
|
||||
|
||||
void resetProviders() {
|
||||
context.read<AboutMihProvider>().reset();
|
||||
Future<void> clearCacheAndProviders() async {
|
||||
context.read<MihAccessControllsProvider>().reset();
|
||||
context.read<MihAuthenticationProvider>().reset();
|
||||
context.read<MihBannerAdProvider>().reset();
|
||||
|
|
@ -40,8 +39,10 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
|||
context.read<MihMineSweeperProvider>().reset();
|
||||
context.read<MzansiAiProvider>().reset();
|
||||
context.read<MzansiDirectoryProvider>().reset();
|
||||
context.read<MzansiWalletProvider>().reset();
|
||||
context.read<PatientManagerProvider>().reset();
|
||||
await context.read<AboutMihProvider>().clearAboutMihCacheAndProvider();
|
||||
await context.read<MzansiWalletProvider>().clearWalletCacheAndProvider();
|
||||
await context.read<MzansiProfileProvider>().clearProfileCacheAndProvider();
|
||||
}
|
||||
|
||||
Future<bool> signOut() async {
|
||||
|
|
@ -187,32 +188,6 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
|||
),
|
||||
),
|
||||
),
|
||||
// ListTile(
|
||||
// title: Row(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// children: [
|
||||
// Icon(
|
||||
// Icons.home_outlined,
|
||||
// color:
|
||||
// MihColors.secondary(),
|
||||
// ),
|
||||
// const SizedBox(width: 25.0),
|
||||
// Text(
|
||||
// "Home",
|
||||
// style: TextStyle(
|
||||
// //fontWeight: FontWeight.bold,
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// onTap: () {
|
||||
// Navigator.of(context)
|
||||
// .pushNamedAndRemoveUntil('/', (route) => false);
|
||||
// },
|
||||
// ),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
|
|
@ -291,8 +266,7 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
|||
});
|
||||
if (await SuperTokens.doesSessionExist() ==
|
||||
false) {
|
||||
resetProviders();
|
||||
await Future.delayed(Duration.zero);
|
||||
await clearCacheAndProviders();
|
||||
if (context.mounted) {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
|
|
@ -313,21 +287,6 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
|||
height: 30,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// setState(() {
|
||||
// if (MzansiInnovationHub.of(context)?.theme.mode ==
|
||||
// "Dark") {
|
||||
// //darkm = !darkm;
|
||||
// MzansiInnovationHub.of(context)!
|
||||
// .changeTheme(ThemeMode.light);
|
||||
// //print("Dark Mode: $darkm");
|
||||
// } else {
|
||||
// //darkm = !darkm;
|
||||
// MzansiInnovationHub.of(context)!
|
||||
// .changeTheme(ThemeMode.dark);
|
||||
// //print("Dark Mode: $darkm");
|
||||
// }
|
||||
// // Navigator.of(context).popAndPushNamed('/',);
|
||||
// });
|
||||
context.goNamed("aboutMih");
|
||||
},
|
||||
child: Icon(
|
||||
|
|
@ -335,27 +294,6 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
|
|||
color: MihColors.primary(),
|
||||
),
|
||||
),
|
||||
// IconButton(
|
||||
// onPressed: () {
|
||||
// setState(() {
|
||||
// if (MzansiInnovationHub.of(context)?.theme.mode == "Dark") {
|
||||
// //darkm = !darkm;
|
||||
// MzansiInnovationHub.of(context)!.changeTheme(ThemeMode.light);
|
||||
// //print("Dark Mode: $darkm");
|
||||
// } else {
|
||||
// //darkm = !darkm;
|
||||
// MzansiInnovationHub.of(context)!.changeTheme(ThemeMode.dark);
|
||||
// //print("Dark Mode: $darkm");
|
||||
// }
|
||||
// Navigator.of(context).popAndPushNamed('/');
|
||||
// });
|
||||
// },
|
||||
// icon: Icon(
|
||||
// Icons.light_mode,
|
||||
// color: MihColors.primary(),
|
||||
// size: 35,
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,56 +16,55 @@ class MihUserConsentWindow extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _MihUserConsentWindowState extends State<MihUserConsentWindow> {
|
||||
void createOrUpdateAccpetance(MzansiProfileProvider mzansiProfileProvider) {
|
||||
void createOrUpdateAccpetance(
|
||||
MzansiProfileProvider mzansiProfileProvider) async {
|
||||
UserConsent? userConsent = mzansiProfileProvider.userConsent;
|
||||
userConsent != null
|
||||
? MihUserConsentServices()
|
||||
.updateUserConsentStatus(
|
||||
DateTime.now().toIso8601String(),
|
||||
DateTime.now().toIso8601String(),
|
||||
mzansiProfileProvider,
|
||||
context,
|
||||
)
|
||||
.then((value) {
|
||||
if (!mounted) return;
|
||||
if (value == 200) {
|
||||
context.goNamed("mihHome");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
child: Text("Thank you for accepting our Policies"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
child: Text("There was an error, please try again later"),
|
||||
),
|
||||
);
|
||||
}
|
||||
})
|
||||
: MihUserConsentServices()
|
||||
.insertUserConsentStatus(
|
||||
DateTime.now().toIso8601String(),
|
||||
DateTime.now().toIso8601String(),
|
||||
mzansiProfileProvider,
|
||||
context,
|
||||
)
|
||||
.then((value) {
|
||||
if (value == 201) {
|
||||
context.goNamed("mihHome");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
child: Text("Thank you for accepting our Policies"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
child: Text("There was an error, please try again later"),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
if (userConsent != null) {
|
||||
MihUserConsentServices()
|
||||
.updateUserConsentStatus(
|
||||
DateTime.now().toIso8601String(),
|
||||
DateTime.now().toIso8601String(),
|
||||
mzansiProfileProvider,
|
||||
context,
|
||||
)
|
||||
.then((value) {
|
||||
if (!mounted) return;
|
||||
if (value == 200) {
|
||||
context.goNamed("mihHome");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
child: Text("Thank you for accepting our Policies"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
child: Text("There was an error, please try again later"),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
bool success = await mzansiProfileProvider.addUserConsent(UserConsent(
|
||||
app_id: mzansiProfileProvider.user!.app_id,
|
||||
privacy_policy_accepted: DateTime.now(),
|
||||
terms_of_services_accepted: DateTime.now(),
|
||||
));
|
||||
if (success) {
|
||||
context.pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
child: Text("Thank you for accepting our Policies"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
child: Text("There was an error, please try again later"),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ class _MihHomeState extends State<MihHome> {
|
|||
mzansiProfileProvider.loadCachedProfileState();
|
||||
if (mzansiProfileProvider.user == null) {
|
||||
await mzansiProfileProvider.syncWithMihServerData();
|
||||
} else {
|
||||
mzansiProfileProvider.syncWithMihServerData();
|
||||
}
|
||||
if(mzansiProfileProvider.isLocalModificationsPending()){
|
||||
mzansiProfileProvider.syncWithMihServerData();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -209,15 +209,6 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
|||
void initState() {
|
||||
super.initState();
|
||||
searchController.addListener(searchPackage);
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
if (profileProvider.user == null || profileProvider.user?.username == "") {
|
||||
personalPackagesMap = setNerUserPersonalPackage();
|
||||
autoNavToProfile();
|
||||
} else {
|
||||
personalPackagesMap = setPersonalPackagesMap(profileProvider);
|
||||
}
|
||||
searchPackage();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -237,6 +228,14 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
|||
return Consumer2<MzansiProfileProvider, MzansiAiProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
MzansiAiProvider mzansiAiProvider, Widget? child) {
|
||||
if (profileProvider.user == null ||
|
||||
profileProvider.user?.username == "") {
|
||||
personalPackagesMap = setNerUserPersonalPackage();
|
||||
autoNavToProfile();
|
||||
} else {
|
||||
personalPackagesMap = setPersonalPackagesMap(profileProvider);
|
||||
}
|
||||
searchPackage();
|
||||
return Column(
|
||||
children: [
|
||||
Visibility(
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
|||
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_mine_sweeper_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildMinesweeperLeaderboardList extends StatefulWidget {
|
||||
|
|
@ -43,89 +44,69 @@ class _BuildMinesweeperLeaderboardListState
|
|||
},
|
||||
itemCount: mineSweeperProvider.leaderboard!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return FutureBuilder(
|
||||
future: mineSweeperProvider.leaderboardUserPicturesUrl[index],
|
||||
builder: (context, asyncSnapshot) {
|
||||
ImageProvider<Object>? imageFile;
|
||||
bool loading = true;
|
||||
if (asyncSnapshot.connectionState == ConnectionState.done) {
|
||||
loading = false;
|
||||
if (asyncSnapshot.hasData) {
|
||||
imageFile = asyncSnapshot.requireData != ""
|
||||
? CachedNetworkImageProvider(
|
||||
asyncSnapshot.requireData)
|
||||
: null;
|
||||
} else {
|
||||
imageFile = null;
|
||||
}
|
||||
} else {
|
||||
imageFile = null;
|
||||
}
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"#${index + 1}",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: getMedalColor(index),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
loading
|
||||
? Icon(
|
||||
MihIcons.mihRing,
|
||||
size: 80,
|
||||
color: MihColors.secondary(),
|
||||
)
|
||||
: imageFile == null
|
||||
? Icon(
|
||||
MihIcons.mihIDontKnow,
|
||||
size: 80,
|
||||
color: MihColors.secondary(),
|
||||
)
|
||||
: MihCircleAvatar(
|
||||
key: UniqueKey(),
|
||||
imageFile: imageFile,
|
||||
width: 80,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: null,
|
||||
userSelectedfile: null,
|
||||
frameColor: getMedalColor(index),
|
||||
backgroundColor: MihColors.primary(),
|
||||
onChange: () {},
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${mineSweeperProvider.leaderboard![index].username}${profileProvider.user!.username == mineSweeperProvider.leaderboard![index].username ? " (You)" : ""}",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: getMedalColor(index),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Score: ${mineSweeperProvider.leaderboard![index].game_score}\nTime: ${mineSweeperProvider.leaderboard![index].game_time}",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
// fontWeight: FontWeight.bold,
|
||||
color: getMedalColor(index),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"#${index + 1}",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: getMedalColor(index),
|
||||
),
|
||||
);
|
||||
});
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
mineSweeperProvider.leaderboard![index].proPicUrl
|
||||
.endsWith('/') ||
|
||||
mineSweeperProvider.leaderboard![index].proPicUrl ==
|
||||
''
|
||||
? Icon(
|
||||
MihIcons.mihIDontKnow,
|
||||
size: 80,
|
||||
color: MihColors.secondary(),
|
||||
)
|
||||
: MihCircleAvatar(
|
||||
key: UniqueKey(),
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(mineSweeperProvider
|
||||
.leaderboard![index].proPicUrl)),
|
||||
width: 80,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: null,
|
||||
userSelectedfile: null,
|
||||
frameColor: getMedalColor(index),
|
||||
backgroundColor: MihColors.primary(),
|
||||
onChange: () {},
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${mineSweeperProvider.leaderboard![index].username}${profileProvider.user!.username == mineSweeperProvider.leaderboard![index].username ? " (You)" : ""}",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: getMedalColor(index),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Score: ${mineSweeperProvider.leaderboard![index].game_score}\nTime: ${mineSweeperProvider.leaderboard![index].game_time}",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
// fontWeight: FontWeight.bold,
|
||||
color: getMedalColor(index),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_mine_sweeper_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mine_sweeper/builders/build_minesweeper_leaderboard_list.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_minesweeper_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
|
@ -24,16 +21,7 @@ class _MihMineSweeperLeaderBoardState extends State<MihMineSweeperLeaderBoard> {
|
|||
MihMineSweeperProvider mineSweeperProvider =
|
||||
context.read<MihMineSweeperProvider>();
|
||||
filterController.text = mineSweeperProvider.difficulty;
|
||||
KenLogger.success("getting data");
|
||||
await MihMinesweeperServices().getTop20Leaderboard(mineSweeperProvider);
|
||||
List<Future<String>> userPicturesUrl = [];
|
||||
Future<String> userPicUrl;
|
||||
for (final ranking in mineSweeperProvider.leaderboard!) {
|
||||
userPicUrl = MihFileApi.getMinioFileUrl(ranking.proPicUrl);
|
||||
userPicturesUrl.add(userPicUrl);
|
||||
}
|
||||
mineSweeperProvider.setLeaderboardUserPictures(
|
||||
leaderboardUserPicturesUrl: userPicturesUrl);
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,10 +26,8 @@ class _MihMineSweeperLeaderBoardState extends State<MyScoreBoard> {
|
|||
MihMineSweeperProvider mineSweeperProvider =
|
||||
context.read<MihMineSweeperProvider>();
|
||||
filterController.text = mineSweeperProvider.difficulty;
|
||||
KenLogger.success("getting data");
|
||||
await MihMinesweeperServices()
|
||||
.getMyScoreboard(profileProvider, mineSweeperProvider);
|
||||
KenLogger.success("${mineSweeperProvider.myScoreboard}");
|
||||
}
|
||||
|
||||
void refreshLeaderBoard(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
|||
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_business_profile_preview.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildBusinessSearchResultsList extends StatefulWidget {
|
||||
|
|
@ -27,8 +28,6 @@ class _BuildBusinessSearchResultsListState
|
|||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
// shrinkWrap: true,
|
||||
// physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.businessList.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
|
|
@ -54,32 +53,14 @@ class _BuildBusinessSearchResultsListState
|
|||
// vertical: 5,
|
||||
horizontal: 25,
|
||||
),
|
||||
child: FutureBuilder(
|
||||
future: directoryProvider.busSearchImagesUrl![
|
||||
widget.businessList[index].business_id],
|
||||
builder: (context, asyncSnapshot) {
|
||||
ImageProvider<Object>? imageFile;
|
||||
bool loading = true;
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.done) {
|
||||
loading = false;
|
||||
if (asyncSnapshot.hasData) {
|
||||
imageFile = asyncSnapshot.requireData != ""
|
||||
? CachedNetworkImageProvider(
|
||||
asyncSnapshot.requireData)
|
||||
: null;
|
||||
} else {
|
||||
imageFile = null;
|
||||
}
|
||||
} else {
|
||||
imageFile = null;
|
||||
}
|
||||
return MihBusinessProfilePreview(
|
||||
business: widget.businessList[index],
|
||||
imageFile: imageFile,
|
||||
loading: loading,
|
||||
);
|
||||
}),
|
||||
child: MihBusinessProfilePreview(
|
||||
business: widget.businessList[index],
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(
|
||||
widget.businessList[index].logo_path),
|
||||
),
|
||||
loading: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
|||
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_business_profile_preview.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildFavouriteBusinessesList extends StatefulWidget {
|
||||
|
|
@ -59,32 +60,15 @@ class _BuildFavouriteBusinessesListState
|
|||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 25,
|
||||
),
|
||||
child: FutureBuilder(
|
||||
future: directoryProvider.favBusImagesUrl![
|
||||
widget.favouriteBusinesses[index]!.business_id],
|
||||
builder: (context, asyncSnapshot) {
|
||||
ImageProvider<Object>? imageFile;
|
||||
bool loading = true;
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.done) {
|
||||
loading = false;
|
||||
if (asyncSnapshot.hasData) {
|
||||
imageFile = asyncSnapshot.requireData != ""
|
||||
? CachedNetworkImageProvider(
|
||||
asyncSnapshot.requireData)
|
||||
: null;
|
||||
} else {
|
||||
imageFile = null;
|
||||
}
|
||||
} else {
|
||||
imageFile = null;
|
||||
}
|
||||
return MihBusinessProfilePreview(
|
||||
business: widget.favouriteBusinesses[index]!,
|
||||
imageFile: imageFile,
|
||||
loading: loading,
|
||||
);
|
||||
}),
|
||||
child: MihBusinessProfilePreview(
|
||||
business: widget.favouriteBusinesses[index]!,
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(
|
||||
widget.favouriteBusinesses[index]!.logo_path,
|
||||
),
|
||||
),
|
||||
loading: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
|||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_personal_profile_preview.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildUserSearchResultsList extends StatefulWidget {
|
||||
|
|
@ -27,8 +28,6 @@ class _BuildUserSearchResultsListState
|
|||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
// shrinkWrap: true,
|
||||
// physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.userList.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
|
|
@ -53,32 +52,14 @@ class _BuildUserSearchResultsListState
|
|||
// vertical: 5,
|
||||
horizontal: 25,
|
||||
),
|
||||
child: FutureBuilder(
|
||||
future: directoryProvider
|
||||
.userSearchImagesUrl![widget.userList[index].app_id],
|
||||
builder: (context, asyncSnapshot) {
|
||||
ImageProvider<Object>? imageFile;
|
||||
bool loading = true;
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.done) {
|
||||
loading = false;
|
||||
if (asyncSnapshot.hasData) {
|
||||
imageFile = asyncSnapshot.requireData != ""
|
||||
? CachedNetworkImageProvider(
|
||||
asyncSnapshot.requireData)
|
||||
: null;
|
||||
} else {
|
||||
imageFile = null;
|
||||
}
|
||||
} else {
|
||||
imageFile = null;
|
||||
}
|
||||
return MihPersonalProfilePreview(
|
||||
user: widget.userList[index],
|
||||
imageFile: imageFile,
|
||||
loading: loading,
|
||||
);
|
||||
}),
|
||||
child: MihPersonalProfilePreview(
|
||||
user: widget.userList[index],
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(
|
||||
widget.userList[index].pro_pic_path),
|
||||
),
|
||||
loading: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import 'package:mzansi_innovation_hub/mih_providers/mzansi_directory_provider.da
|
|||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/build_favourite_businesses_list.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.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_mzansi_directory_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
|
@ -37,20 +36,15 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
|||
directoryProvider,
|
||||
);
|
||||
List<Business> favBus = [];
|
||||
Map<String, Future<String>> favBusImages = {};
|
||||
Future<String> businessLogoUrl;
|
||||
for (var bus in directoryProvider.bookmarkedBusinesses) {
|
||||
await MihBusinessDetailsServices()
|
||||
.getBusinessDetailsByBusinessId(bus.business_id)
|
||||
.then((business) async {
|
||||
favBus.add(business!);
|
||||
businessLogoUrl = MihFileApi.getMinioFileUrl(business.logo_path);
|
||||
favBusImages[business.business_id] = businessLogoUrl;
|
||||
});
|
||||
}
|
||||
directoryProvider.setFavouriteBusinesses(
|
||||
businesses: favBus,
|
||||
businessesImagesUrl: favBusImages,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
||||
|
|
@ -9,7 +8,6 @@ import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/bui
|
|||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/build_user_search_results_list.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_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
|
@ -26,8 +24,6 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
|||
final TextEditingController mzansiSearchController = TextEditingController();
|
||||
final TextEditingController businessTypeController = TextEditingController();
|
||||
final FocusNode searchFocusNode = FocusNode();
|
||||
// late bool userSearch;
|
||||
// Future<List<AppUser>?> futureUserSearchResults = Future.value();
|
||||
List<AppUser> userSearchResults = [];
|
||||
List<Business> businessSearchResults = [];
|
||||
late Future<List<String>> availableBusinessTypes;
|
||||
|
|
@ -51,9 +47,8 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
|||
}
|
||||
|
||||
void clearAll(MzansiDirectoryProvider directoryProvider) {
|
||||
directoryProvider
|
||||
.setSearchedBusinesses(searchedBusinesses: [], businessesImagesUrl: {});
|
||||
directoryProvider.setSearchedUsers(searchedUsers: [], userImagesUrl: {});
|
||||
directoryProvider.setSearchedBusinesses(searchedBusinesses: []);
|
||||
directoryProvider.setSearchedUsers(searchedUsers: []);
|
||||
directoryProvider.setSearchTerm(searchTerm: "");
|
||||
setState(() {
|
||||
mzansiSearchController.clear();
|
||||
|
|
@ -73,19 +68,8 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
|||
directoryProvider.searchTerm.isNotEmpty) {
|
||||
final userResults = await MihUserServices()
|
||||
.searchUsers(profileProvider, directoryProvider.searchTerm, context);
|
||||
Map<String, Future<String>> userImages = {};
|
||||
Future<String> usernProPicUrl;
|
||||
for (var user in userResults) {
|
||||
usernProPicUrl = MihFileApi.getMinioFileUrl(user.pro_pic_path);
|
||||
userImages[user.app_id] = usernProPicUrl;
|
||||
// != ""
|
||||
// ? CachedNetworkImageProvider(usernProPicUrl)
|
||||
// : null;
|
||||
}
|
||||
|
||||
directoryProvider.setSearchedUsers(
|
||||
searchedUsers: userResults,
|
||||
userImagesUrl: userImages,
|
||||
);
|
||||
} else {
|
||||
List<Business>? businessSearchResults = [];
|
||||
|
|
@ -98,18 +82,8 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
|||
.searchBusinesses(directoryProvider.searchTerm,
|
||||
directoryProvider.businessTypeFilter, context);
|
||||
}
|
||||
Map<String, Future<String>> busImagesUrl = {};
|
||||
Future<String> businessLogoUrl;
|
||||
for (var bus in businessSearchResults) {
|
||||
businessLogoUrl = MihFileApi.getMinioFileUrl(bus.logo_path);
|
||||
busImagesUrl[bus.business_id] = businessLogoUrl;
|
||||
// != ""
|
||||
// ? CachedNetworkImageProvider(businessLogoUrl)
|
||||
// : null;
|
||||
}
|
||||
directoryProvider.setSearchedBusinesses(
|
||||
searchedBusinesses: businessSearchResults,
|
||||
businessesImagesUrl: busImagesUrl,
|
||||
);
|
||||
}
|
||||
setState(() {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
|
|||
}
|
||||
directoryProvider.setFavouriteBusinesses(
|
||||
businesses: favBus,
|
||||
businessesImagesUrl: favBusImages,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ class _MihDeleteBookmarkAlertState extends State<MihDeleteBookmarkAlert> {
|
|||
}
|
||||
directoryProvider.setFavouriteBusinesses(
|
||||
businesses: favBus,
|
||||
businessesImagesUrl: favBusImages,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,58 +69,20 @@ class _MihBusinessDetailsViewState extends State<MihBusinessDetailsView> {
|
|||
: EdgeInsets.symmetric(horizontal: width * 0),
|
||||
child: Column(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "") {
|
||||
return MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.secondary(),
|
||||
backgroundColor: MihColors.primary(),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihIDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.secondary(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.secondary(),
|
||||
);
|
||||
}
|
||||
}),
|
||||
// Center(
|
||||
// child: MihCircleAvatar(
|
||||
// imageFile: widget.logoImage,
|
||||
// width: 150,
|
||||
// editable: false,
|
||||
// fileNameController: fileNameController,
|
||||
// userSelectedfile: imageFile,
|
||||
// frameColor:
|
||||
// MihColors.secondary(),
|
||||
// backgroundColor:
|
||||
// MihColors.primary(),
|
||||
// onChange: (selectedfile) {
|
||||
// setState(() {
|
||||
// imageFile = selectedfile;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(
|
||||
directoryProvider.selectedBusiness!.logo_path),
|
||||
),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.secondary(),
|
||||
backgroundColor: MihColors.primary(),
|
||||
onChange: () {},
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
directoryProvider.selectedBusiness!.Name,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:file_saver/file_saver.dart';
|
||||
|
|
@ -59,7 +57,7 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
String encodedData =
|
||||
Uri.encodeComponent("$qrCodedata${business.business_id}");
|
||||
|
||||
return "https://api.qrserver.com/v1/create-qr-code/?data=$encodedData&size=${qrSize}x${qrSize}&bgcolor=$bgColor&color=$color";
|
||||
return "https://api.qrserver.com/v1/create-qr-code/?data=$encodedData&size=${qrSize}x$qrSize&bgcolor=$bgColor&color=$color";
|
||||
}
|
||||
|
||||
Future<void> saveImage(Uint8List imageBytes) async {
|
||||
|
|
@ -206,41 +204,18 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
)
|
||||
: FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "" ||
|
||||
asyncSnapshot.requireData.isNotEmpty) {
|
||||
return MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihIDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.primary(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.primary(),
|
||||
);
|
||||
}
|
||||
},
|
||||
: MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(business.logo_path),
|
||||
),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
|
|
|
|||
|
|
@ -86,12 +86,9 @@ class _MihEditPersonalProfileWindowState
|
|||
);
|
||||
if (responseCode == 200) {
|
||||
setState(() {
|
||||
setProfileVariables(mzansiProfileProvider);
|
||||
newSelectedProPic = null;
|
||||
});
|
||||
// if (originalProfileTypeIsBusiness == false && businessUser == true) {
|
||||
// stayOnPersonalSide = false;
|
||||
// }
|
||||
await mzansiProfileProvider.syncWithMihServerData();
|
||||
String message = "Your information has been updated successfully!";
|
||||
successPopUp(
|
||||
mzansiProfileProvider,
|
||||
|
|
|
|||
|
|
@ -174,35 +174,67 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
|
|||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
addProfileLinksWindow();
|
||||
},
|
||||
buttonColor: MihColors.green(),
|
||||
width: mzansiProfileProvider.personalLinks.isNotEmpty
|
||||
? 50
|
||||
: null,
|
||||
height: 50,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.add,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
if (mzansiProfileProvider.personalLinks.isEmpty)
|
||||
Text(
|
||||
"Add Links",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
mzansiProfileProvider.user!.username != ""
|
||||
? MihButton(
|
||||
onPressed: () {
|
||||
addProfileLinksWindow();
|
||||
},
|
||||
buttonColor: MihColors.green(),
|
||||
width:
|
||||
mzansiProfileProvider.personalLinks.isNotEmpty
|
||||
? 50
|
||||
: null,
|
||||
height: 50,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.add,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
if (mzansiProfileProvider
|
||||
.personalLinks.isEmpty)
|
||||
Text(
|
||||
"Add Links",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: MihButton(
|
||||
onPressed: () {
|
||||
editProfileWindow();
|
||||
},
|
||||
buttonColor: MihColors.green(),
|
||||
width: null,
|
||||
height: 50,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.edit,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
"Add Profile",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8.0),
|
||||
if (mzansiProfileProvider.personalLinks.isNotEmpty)
|
||||
MihButton(
|
||||
|
|
|
|||
|
|
@ -75,40 +75,21 @@ class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
|
|||
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: CachedNetworkImageProvider(
|
||||
asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.secondary(),
|
||||
backgroundColor: MihColors.primary(),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihIDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.secondary(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.secondary(),
|
||||
);
|
||||
}
|
||||
}),
|
||||
MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(
|
||||
directoryProvider.selectedUser!.pro_pic_path,
|
||||
),
|
||||
),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.secondary(),
|
||||
backgroundColor: MihColors.primary(),
|
||||
onChange: () {},
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
directoryProvider.selectedUser!.username.isNotEmpty
|
||||
|
|
|
|||
|
|
@ -206,41 +206,18 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
|||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
)
|
||||
: FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "" ||
|
||||
asyncSnapshot.requireData.isNotEmpty) {
|
||||
return MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihIDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.primary(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.primary(),
|
||||
);
|
||||
}
|
||||
},
|
||||
: MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(user.pro_pic_path),
|
||||
),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue