forked from yaso_meth/mih-project
preload user profile picture
This commit is contained in:
@@ -21,11 +21,13 @@ class HomeTileGrid extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final BusinessUser? businessUser;
|
||||
final Business? business;
|
||||
final ImageProvider<Object>? propicFile;
|
||||
const HomeTileGrid({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
required this.businessUser,
|
||||
required this.business,
|
||||
required this.propicFile,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -401,7 +403,10 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: Scaffold(
|
||||
appBar: const MIHAppBar(barTitle: "Mzansi Innovation\nHub"),
|
||||
appBar: MIHAppBar(
|
||||
barTitle: "Mzansi Innovation\nHub",
|
||||
propicFile: widget.propicFile,
|
||||
),
|
||||
drawer: MIHAppDrawer(
|
||||
signedInUser: widget.signedInUser,
|
||||
),
|
||||
|
||||
@@ -3,8 +3,12 @@ import 'package:patient_manager/main.dart';
|
||||
|
||||
class MIHAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
final String barTitle;
|
||||
|
||||
const MIHAppBar({super.key, required this.barTitle});
|
||||
final ImageProvider<Object>? propicFile;
|
||||
const MIHAppBar({
|
||||
super.key,
|
||||
required this.barTitle,
|
||||
required this.propicFile,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHAppBar> createState() => _MIHAppBarState();
|
||||
|
||||
@@ -25,6 +25,9 @@ class _HomeState extends State<Home> {
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
late Future<BusinessArguments> profile;
|
||||
|
||||
late String proPicUrl;
|
||||
ImageProvider<Object>? propicFile;
|
||||
|
||||
Future<BusinessArguments> getProfile() async {
|
||||
AppUser userData;
|
||||
Business? busData;
|
||||
@@ -119,6 +122,28 @@ class _HomeState extends State<Home> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getFileUrlApiCall(AppUser signedInUser) async {
|
||||
if (signedInUser.pro_pic_path == "") {
|
||||
return "";
|
||||
} else if (AppEnviroment.getEnv() == "Dev") {
|
||||
return "${AppEnviroment.baseFileUrl}/mih/${signedInUser.pro_pic_path}";
|
||||
} else {
|
||||
var url =
|
||||
"${AppEnviroment.baseApiUrl}/minio/pull/file/${signedInUser.pro_pic_path}/prod";
|
||||
var response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
String body = response.body;
|
||||
var decodedData = jsonDecode(body);
|
||||
|
||||
return decodedData['minioURL'];
|
||||
} else {
|
||||
throw Exception(
|
||||
"Error: GetUserData status code ${response.statusCode}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
@@ -138,10 +163,18 @@ class _HomeState extends State<Home> {
|
||||
builder: (BuildContext context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.hasData) {
|
||||
getFileUrlApiCall(snapshot.requireData.signedInUser)
|
||||
.then((results) {
|
||||
setState(() {
|
||||
proPicUrl = results;
|
||||
propicFile = NetworkImage(proPicUrl);
|
||||
});
|
||||
});
|
||||
return HomeTileGrid(
|
||||
signedInUser: snapshot.requireData.signedInUser,
|
||||
businessUser: snapshot.data!.businessUser,
|
||||
business: snapshot.data!.business,
|
||||
propicFile: propicFile,
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
|
||||
@@ -267,7 +267,10 @@ class _PatientAccessRequestState extends State<PatientAccessRequest> {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
return Scaffold(
|
||||
appBar: const MIHAppBar(barTitle: "Access Reviews"),
|
||||
appBar: const MIHAppBar(
|
||||
barTitle: "Access Reviews",
|
||||
propicFile: null,
|
||||
),
|
||||
//drawer: MIHAppDrawer(signedInUser: widget.signedInUser),
|
||||
body: SafeArea(child: viewAccessRequest(screenWidth, screenHeight)),
|
||||
);
|
||||
|
||||
@@ -343,7 +343,10 @@ class _AddPatientState extends State<AddPatient> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const MIHAppBar(barTitle: "Add Patient"),
|
||||
appBar: const MIHAppBar(
|
||||
barTitle: "Add Patient",
|
||||
propicFile: null,
|
||||
),
|
||||
//drawer: MIHAppDrawer(signedInUser: widget.signedInUser),
|
||||
body: SafeArea(
|
||||
child: KeyboardListener(
|
||||
|
||||
@@ -608,7 +608,10 @@ class _EditPatientState extends State<EditPatient> {
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
appBar: const MIHAppBar(barTitle: "Edit Patient"),
|
||||
appBar: const MIHAppBar(
|
||||
barTitle: "Edit Patient",
|
||||
propicFile: null,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: KeyboardListener(
|
||||
focusNode: _focusNode,
|
||||
|
||||
@@ -478,7 +478,10 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
return Scaffold(
|
||||
appBar: const MIHAppBar(barTitle: "Patient Manager"),
|
||||
appBar: const MIHAppBar(
|
||||
barTitle: "Patient Manager",
|
||||
propicFile: null,
|
||||
),
|
||||
//drawer: MIHAppDrawer(signedInUser: widget.arguments.signedInUser),
|
||||
//floatingActionButtonLocation: FloatingActionButtonLocation.,
|
||||
// floatingActionButton: FloatingActionButton.extended(
|
||||
|
||||
@@ -96,7 +96,10 @@ class _PatientViewState extends State<PatientView> {
|
||||
// loadImage();
|
||||
// var logo = MzanziInnovationHub.of(context)!.theme.logoImage();
|
||||
return Scaffold(
|
||||
appBar: const MIHAppBar(barTitle: "Patient Profile"),
|
||||
appBar: const MIHAppBar(
|
||||
barTitle: "Patient Profile",
|
||||
propicFile: null,
|
||||
),
|
||||
//drawer: showDrawer(),
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
|
||||
@@ -229,7 +229,10 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const MIHAppBar(barTitle: "Add Business"),
|
||||
appBar: const MIHAppBar(
|
||||
barTitle: "Add Business",
|
||||
propicFile: null,
|
||||
),
|
||||
//drawer: MIHAppDrawer(signedInUser: widget.signedInUser),
|
||||
body: SafeArea(
|
||||
child: KeyboardListener(
|
||||
|
||||
@@ -312,7 +312,10 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const MIHAppBar(barTitle: "Business Profile"),
|
||||
appBar: const MIHAppBar(
|
||||
barTitle: "Business Profile",
|
||||
propicFile: null,
|
||||
),
|
||||
//drawer: MIHAppDrawer(signedInUser: widget.arguments.signedInUser),
|
||||
body: SafeArea(
|
||||
child: KeyboardListener(
|
||||
|
||||
@@ -3,11 +3,9 @@ import 'dart:convert';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:gif/gif.dart';
|
||||
import 'package:patient_manager/components/inputsAndButtons/mihFileInput.dart';
|
||||
import 'package:patient_manager/components/mihAppBar.dart';
|
||||
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
|
||||
// import 'package:patient_manager/components/mihAppDrawer.dart';
|
||||
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
|
||||
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
|
||||
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
|
||||
@@ -41,7 +39,6 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
||||
late Future<String> proPicUrl;
|
||||
late bool businessUser;
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
late final GifController _controller;
|
||||
|
||||
late String oldProPicName;
|
||||
|
||||
@@ -231,7 +228,6 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
proPicController.dispose();
|
||||
usernameController.dispose();
|
||||
fnameController.dispose();
|
||||
@@ -262,7 +258,10 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const MIHAppBar(barTitle: "Update Profile"),
|
||||
appBar: const MIHAppBar(
|
||||
barTitle: "Update Profile",
|
||||
propicFile: null,
|
||||
),
|
||||
//drawer: MIHAppDrawer(signedInUser: widget.signedInUser),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
|
||||
Reference in New Issue
Block a user