From 6c605e7a66fd00b115ff227a5597275a412d3c35 Mon Sep 17 00:00:00 2001 From: yaso-meth Date: Fri, 26 Jul 2024 12:56:51 +0200 Subject: [PATCH] get signed in users details from home screen --- .../lib/components/homeTileGrid.dart | 75 ++++++++----------- 1 file changed, 33 insertions(+), 42 deletions(-) diff --git a/Frontend/patient_manager/lib/components/homeTileGrid.dart b/Frontend/patient_manager/lib/components/homeTileGrid.dart index aca18ada..9c2ea568 100644 --- a/Frontend/patient_manager/lib/components/homeTileGrid.dart +++ b/Frontend/patient_manager/lib/components/homeTileGrid.dart @@ -2,75 +2,66 @@ import 'package:flutter/material.dart'; import 'package:patient_manager/components/homeTile.dart'; import 'package:patient_manager/env/env.dart'; import 'package:patient_manager/main.dart'; +import 'package:patient_manager/objects/appUser.dart'; class HomeTileGrid extends StatefulWidget { - final String userEmail; - const HomeTileGrid({super.key, required this.userEmail}); + final AppUser signedInUser; + const HomeTileGrid({ + super.key, + required this.signedInUser, + }); @override State createState() => _HomeTileGridState(); } class _HomeTileGridState extends State { - late List> tileList; + late List> tileList = []; - List> setApps() { - if (AppEnviroment.getEnv() == "Dev") { - return [ + void setApps(List> tileList) { + if (widget.signedInUser.type == "personal") { + tileList.add( [ Icons.medication, - "Patient Manager", + "Patient Profile", () { - // Navigator.of(context) - // .pushNamed('/patient-manager', arguments: widget.userEmail); - Navigator.popAndPushNamed(context, '/patient-manager', - arguments: widget.userEmail); + Navigator.of(context) + .pushNamed('/patient-profile', arguments: widget.signedInUser); + // Navigator.popAndPushNamed(context, '/patient-manager', + // arguments: widget.userEmail); } ], - [Icons.abc, "Test 1", () {}], - [Icons.abc, "Test 2", () {}], - [Icons.abc, "Test 3", () {}], - [Icons.abc, "Test 4", () {}], - [Icons.abc, "Test 5", () {}], - [Icons.abc, "Test 6", () {}], - ]; + ); } else { - return [ + //business + tileList.add( [ Icons.medication, "Patient Manager", () { - // Navigator.of(context) - // .pushNamed('/patient-manager', arguments: widget.userEmail); - Navigator.popAndPushNamed(context, '/patient-manager', - arguments: widget.userEmail); + Navigator.of(context).pushNamed('/patient-manager', + arguments: widget.signedInUser.email); + // Navigator.popAndPushNamed(context, '/patient-manager', + // arguments: widget.userEmail); } ], - ]; + ); + } + + if (AppEnviroment.getEnv() == "Dev") { + tileList.add([Icons.abc, "Test 1", () {}]); + tileList.add([Icons.abc, "Test 2", () {}]); + tileList.add([Icons.abc, "Test 3", () {}]); + tileList.add([Icons.abc, "Test 4", () {}]); + tileList.add([Icons.abc, "Test 5", () {}]); + tileList.add([Icons.abc, "Test 6", () {}]); } } @override void initState() { //print("Home tile gird widget: ${widget.userEmail}"); - tileList = [ - [ - Icons.medication, - "Patient Manager", - () { - // Navigator.of(context) - // .pushNamed('/patient-manager', arguments: widget.userEmail); - Navigator.popAndPushNamed(context, '/patient-manager', - arguments: widget.userEmail); - } - ], - [Icons.abc, "Test 1", () {}], - [Icons.abc, "Test 2", () {}], - [Icons.abc, "Test 3", () {}], - [Icons.abc, "Test 4", () {}], - [Icons.abc, "Test 5", () {}], - [Icons.abc, "Test 6", () {}], - ]; + setApps(tileList); super.initState(); }