Active Business Toggle
This commit is contained in:
@@ -38,7 +38,7 @@ class _HomeTileState extends State<HomeTile> {
|
|||||||
Widget displayTile() {
|
Widget displayTile() {
|
||||||
return FittedBox(
|
return FittedBox(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
@@ -70,14 +70,22 @@ class _HomeTileState extends State<HomeTile> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 1),
|
const SizedBox(height: 1),
|
||||||
Text(
|
Row(
|
||||||
widget.tileName,
|
children: [
|
||||||
textAlign: TextAlign.center,
|
Flexible(
|
||||||
style: TextStyle(
|
child: Text(
|
||||||
color: mainC,
|
widget.tileName,
|
||||||
fontSize: 5.0,
|
textAlign: TextAlign.center,
|
||||||
fontWeight: FontWeight.bold,
|
softWrap: true,
|
||||||
),
|
overflow: TextOverflow.visible,
|
||||||
|
style: TextStyle(
|
||||||
|
color: mainC,
|
||||||
|
fontSize: 5.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_nav_bar/google_nav_bar.dart';
|
||||||
import 'package:patient_manager/components/homeTile.dart';
|
import 'package:patient_manager/components/homeTile.dart';
|
||||||
|
import 'package:patient_manager/components/mihAppBar.dart';
|
||||||
|
import 'package:patient_manager/components/mihAppDrawer.dart';
|
||||||
|
import 'package:patient_manager/components/mihDeleteMessage.dart';
|
||||||
import 'package:patient_manager/components/myErrorMessage.dart';
|
import 'package:patient_manager/components/myErrorMessage.dart';
|
||||||
|
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||||
import 'package:patient_manager/env/env.dart';
|
import 'package:patient_manager/env/env.dart';
|
||||||
import 'package:patient_manager/main.dart';
|
import 'package:patient_manager/main.dart';
|
||||||
import 'package:patient_manager/objects/appUser.dart';
|
import 'package:patient_manager/objects/appUser.dart';
|
||||||
@@ -17,9 +22,13 @@ class HomeTileGrid extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _HomeTileGridState extends State<HomeTileGrid> {
|
class _HomeTileGridState extends State<HomeTileGrid> {
|
||||||
late List<List<dynamic>> tileList = [];
|
late List<List<dynamic>> personalTileList = [];
|
||||||
|
late List<List<dynamic>> businessTileList = [];
|
||||||
|
late List<List<dynamic>> devTileList = [];
|
||||||
|
List<List<List<dynamic>>> pbswitch = [];
|
||||||
|
int _selectedIndex = 0;
|
||||||
|
|
||||||
void setApps(List<List<dynamic>> tileList) {
|
void setAppsNewPersonal(List<List<dynamic>> tileList) {
|
||||||
if (widget.signedInUser.fname == "") {
|
if (widget.signedInUser.fname == "") {
|
||||||
tileList.add(
|
tileList.add(
|
||||||
[
|
[
|
||||||
@@ -33,68 +42,122 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else if (widget.signedInUser.type == "personal") {
|
|
||||||
tileList.add(
|
|
||||||
[
|
|
||||||
Icons.medication,
|
|
||||||
"Patient Profile",
|
|
||||||
() {
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushNamed('/patient-profile', arguments: widget.signedInUser);
|
|
||||||
// Navigator.popAndPushNamed(context, '/patient-manager',
|
|
||||||
// arguments: widget.userEmail);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
//business
|
|
||||||
tileList.add(
|
|
||||||
[
|
|
||||||
Icons.medication,
|
|
||||||
"Patient Manager",
|
|
||||||
() {
|
|
||||||
Navigator.of(context).pushNamed('/patient-manager',
|
|
||||||
arguments: widget.signedInUser.email);
|
|
||||||
// Navigator.popAndPushNamed(context, '/patient-manager',
|
|
||||||
// arguments: widget.userEmail);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAppsPersonal(List<List<dynamic>> tileList) {
|
||||||
|
tileList.add(
|
||||||
|
[
|
||||||
|
Icons.medication,
|
||||||
|
"Patient Profile",
|
||||||
|
() {
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamed('/patient-profile', arguments: widget.signedInUser);
|
||||||
|
// Navigator.popAndPushNamed(context, '/patient-manager',
|
||||||
|
// arguments: widget.userEmail);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAppsBusiness(List<List<dynamic>> tileList) {
|
||||||
|
tileList.add(
|
||||||
|
[
|
||||||
|
Icons.medication,
|
||||||
|
"Manage Patient",
|
||||||
|
() {
|
||||||
|
Navigator.of(context).pushNamed('/patient-manager',
|
||||||
|
arguments: widget.signedInUser.email);
|
||||||
|
// Navigator.popAndPushNamed(context, '/patient-manager',
|
||||||
|
// arguments: widget.userEmail);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAppsDev(List<List<dynamic>> tileList) {
|
||||||
if (AppEnviroment.getEnv() == "Dev") {
|
if (AppEnviroment.getEnv() == "Dev") {
|
||||||
tileList.add([
|
tileList.add([
|
||||||
Icons.add,
|
Icons.add_circle_outline,
|
||||||
"Add Pat - Dev",
|
"Add Pat - Dev",
|
||||||
() {
|
() {
|
||||||
Navigator.of(context).pushNamed('/patient-manager/add',
|
Navigator.of(context).pushNamed('/patient-manager/add',
|
||||||
arguments: widget.signedInUser);
|
arguments: widget.signedInUser);
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
tileList.add(
|
||||||
|
[
|
||||||
|
Icons.perm_identity,
|
||||||
|
"Upd Prof - Dev",
|
||||||
|
() {
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamed('/profile', arguments: widget.signedInUser);
|
||||||
|
// Navigator.popAndPushNamed(context, '/patient-manager',
|
||||||
|
// arguments: widget.userEmail);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
);
|
||||||
tileList.add([
|
tileList.add([
|
||||||
Icons.password,
|
Icons.error_outline_outlined,
|
||||||
"Pass Req - Dev",
|
"Error - Dev",
|
||||||
() {
|
() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return const MyErrorMessage(errorType: "Password Requirements");
|
return const MyErrorMessage(errorType: "Invalid Email");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
tileList.add([
|
||||||
|
Icons.check_circle_outline_outlined,
|
||||||
|
"Success - Dev",
|
||||||
|
() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const MySuccessMessage(
|
||||||
|
successType: "Success",
|
||||||
|
successMessage:
|
||||||
|
"Congratulations! Your account has been created successfully. You are log in and can start exploring.\n\nPlease note: more apps will appear once you update your profile.");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
tileList.add([
|
||||||
|
Icons.delete_forever_outlined,
|
||||||
|
"Delete - Dev",
|
||||||
|
() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return MIHDeleteMessage(deleteType: "File", onTap: () {});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
tileList.add([Icons.abc, "Test 3", () {}]);
|
|
||||||
tileList.add([Icons.abc, "Test 4", () {}]);
|
|
||||||
tileList.add([Icons.abc, "Test 5", () {}]);
|
tileList.add([Icons.abc, "Test 5", () {}]);
|
||||||
tileList.add([Icons.abc, "Test 6", () {}]);
|
tileList.add([Icons.abc, "Test 6", () {}]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
void setApps(List<List<dynamic>> personalTileList,
|
||||||
void initState() {
|
List<List<dynamic>> businessTileList) {
|
||||||
//print("Home tile gird widget: ${widget.userEmail}");
|
if (widget.signedInUser.fname == "") {
|
||||||
setApps(tileList);
|
setAppsNewPersonal(personalTileList);
|
||||||
super.initState();
|
} else if (widget.signedInUser.type == "personal") {
|
||||||
|
setAppsPersonal(personalTileList);
|
||||||
|
} else {
|
||||||
|
//business
|
||||||
|
setAppsPersonal(personalTileList);
|
||||||
|
setAppsBusiness(businessTileList);
|
||||||
|
}
|
||||||
|
if (AppEnviroment.getEnv() == "Dev") {
|
||||||
|
setAppsDev(personalTileList);
|
||||||
|
setAppsDev(businessTileList);
|
||||||
|
}
|
||||||
|
pbswitch.add(personalTileList);
|
||||||
|
pbswitch.add(businessTileList);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color getPrim() {
|
Color getPrim() {
|
||||||
@@ -119,27 +182,85 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBusinessUser(AppUser signedInUser) {
|
||||||
|
if (signedInUser.type == "personal") {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
setApps(personalTileList, businessTileList);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var size = MediaQuery.of(context).size;
|
var size = MediaQuery.of(context).size;
|
||||||
double width = size.width;
|
double width = size.width;
|
||||||
double height = size.height;
|
double height = size.height;
|
||||||
|
|
||||||
return Container(
|
return Scaffold(
|
||||||
width: width,
|
appBar: const MIHAppBar(barTitle: "Mzansi Innovation Hub"),
|
||||||
height: height,
|
drawer: MIHAppDrawer(
|
||||||
child: GridView.builder(
|
signedInUser: widget.signedInUser,
|
||||||
padding: EdgeInsets.fromLTRB(width / 6, height / 16, width / 6,
|
logo: MzanziInnovationHub.of(context)!.theme.logoImage(), //logo,
|
||||||
0), //EdgeInsets.symmetric(horizontal: width / 6),
|
),
|
||||||
itemCount: tileList.length,
|
body: Container(
|
||||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
width: width,
|
||||||
maxCrossAxisExtent: 200),
|
height: height,
|
||||||
//const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
|
child: GridView.builder(
|
||||||
itemBuilder: (context, index) {
|
padding: EdgeInsets.fromLTRB(width / 6, height / 16, width / 6,
|
||||||
var tile = tileList[index];
|
0), //EdgeInsets.symmetric(horizontal: width / 6),
|
||||||
//setState(() {});
|
itemCount: pbswitch[_selectedIndex].length,
|
||||||
return buildtile(tile);
|
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
},
|
maxCrossAxisExtent: 200),
|
||||||
|
//const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
var tile = pbswitch[_selectedIndex][index];
|
||||||
|
//setState(() {});
|
||||||
|
return buildtile(tile);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bottomNavigationBar: Visibility(
|
||||||
|
visible: isBusinessUser(widget.signedInUser),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(15.0),
|
||||||
|
child: GNav(
|
||||||
|
//hoverColor: Colors.lightBlueAccent,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
iconSize: 35.0,
|
||||||
|
activeColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
tabBackgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
//gap: 20,
|
||||||
|
//padding: EdgeInsets.all(15),
|
||||||
|
tabs: [
|
||||||
|
GButton(
|
||||||
|
icon: Icons.perm_identity,
|
||||||
|
text: "Personal",
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_selectedIndex = 0;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
GButton(
|
||||||
|
icon: Icons.business,
|
||||||
|
text: "Business",
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_selectedIndex = 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
selectedIndex: _selectedIndex,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:patient_manager/components/mihAppDrawer.dart';
|
|
||||||
import 'package:patient_manager/env/env.dart';
|
import 'package:patient_manager/env/env.dart';
|
||||||
import 'package:patient_manager/components/homeTileGrid.dart';
|
import 'package:patient_manager/components/homeTileGrid.dart';
|
||||||
import 'package:patient_manager/components/mihAppBar.dart';
|
|
||||||
import 'package:patient_manager/main.dart';
|
|
||||||
import 'package:patient_manager/objects/appUser.dart';
|
import 'package:patient_manager/objects/appUser.dart';
|
||||||
import 'package:supertokens_flutter/supertokens.dart';
|
import 'package:supertokens_flutter/supertokens.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
@@ -20,19 +17,9 @@ class Home extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _HomeState extends State<Home> {
|
class _HomeState extends State<Home> {
|
||||||
//late Future<AppUser> signedInUser;
|
|
||||||
String useremail = "";
|
String useremail = "";
|
||||||
final baseAPI = AppEnviroment.baseApiUrl;
|
final baseAPI = AppEnviroment.baseApiUrl;
|
||||||
|
|
||||||
// Future<void> loadImage() async {
|
|
||||||
// try {
|
|
||||||
// var t = MzanziInnovationHub.of(context)!.theme.logoImage();
|
|
||||||
// await precacheImage(t.image, context);
|
|
||||||
// } catch (e) {
|
|
||||||
// print('Failed to load and cache the image: $e');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
Future<AppUser> getUserDetails() async {
|
Future<AppUser> getUserDetails() async {
|
||||||
//print("pat man drawer: " + endpointUserData + widget.userEmail);
|
//print("pat man drawer: " + endpointUserData + widget.userEmail);
|
||||||
var uid = await SuperTokens.getUserId();
|
var uid = await SuperTokens.getUserId();
|
||||||
@@ -46,6 +33,9 @@ class _HomeState extends State<Home> {
|
|||||||
var decodedData = jsonDecode(body);
|
var decodedData = jsonDecode(body);
|
||||||
AppUser u = AppUser.fromJson(decodedData);
|
AppUser u = AppUser.fromJson(decodedData);
|
||||||
// print(u.email);
|
// print(u.email);
|
||||||
|
//setState(() {
|
||||||
|
//_widgetOptions = setLayout(u);
|
||||||
|
//});
|
||||||
return u;
|
return u;
|
||||||
} else {
|
} else {
|
||||||
throw Exception("Error: GetUserData status code ${response.statusCode}");
|
throw Exception("Error: GetUserData status code ${response.statusCode}");
|
||||||
@@ -54,66 +44,18 @@ class _HomeState extends State<Home> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
//signedInUser = getUserDetails();
|
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
//precacheImage(logo, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @override
|
|
||||||
// void didChangeDependencies() {
|
|
||||||
// super.didChangeDependencies();
|
|
||||||
// precacheImage(logo, context);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
//loadImage();
|
|
||||||
|
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: getUserDetails(),
|
future: getUserDetails(),
|
||||||
builder: (BuildContext context, AsyncSnapshot<AppUser> snapshot) {
|
builder: (BuildContext context, AsyncSnapshot<AppUser> snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
return Scaffold(
|
return HomeTileGrid(
|
||||||
appBar: const MIHAppBar(barTitle: "Mzansi Innovation Hub"),
|
signedInUser: snapshot.data!,
|
||||||
drawer: MIHAppDrawer(
|
|
||||||
signedInUser: snapshot.data!,
|
|
||||||
logo:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.logoImage(), //logo,
|
|
||||||
), //HomeAppDrawer(userEmail: useremail),
|
|
||||||
body: HomeTileGrid(
|
|
||||||
signedInUser: snapshot.data!,
|
|
||||||
),
|
|
||||||
// floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
|
|
||||||
// floatingActionButton: Padding(
|
|
||||||
// padding: const EdgeInsets.only(top: 65, right: 5),
|
|
||||||
// child: FloatingActionButton.extended(
|
|
||||||
// label: const Text(
|
|
||||||
// "Test Pop Up",
|
|
||||||
// style: TextStyle(
|
|
||||||
// fontWeight: FontWeight.bold,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// //backgroundColor: Colors.blueAccent,
|
|
||||||
// onPressed: () {
|
|
||||||
// showDatePicker(
|
|
||||||
// context: context,
|
|
||||||
// initialDate: DateTime.now(),
|
|
||||||
// firstDate: DateTime(2000),
|
|
||||||
// lastDate: DateTime(2100),
|
|
||||||
// );
|
|
||||||
// // showDialog(
|
|
||||||
// // context: context,
|
|
||||||
// // builder: (context) =>
|
|
||||||
// // const MyErrorMessage(errorType: "Input Error"),
|
|
||||||
// // );
|
|
||||||
// },
|
|
||||||
// icon: const Icon(
|
|
||||||
// Icons.warning,
|
|
||||||
// //color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Center(
|
return Center(
|
||||||
@@ -129,7 +71,5 @@ class _HomeState extends State<Home> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
//);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user