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