Remove Gnav and replace with switch

This commit is contained in:
2024-08-23 15:24:36 +02:00
parent d979761891
commit 4439a2545c

View File

@@ -1,5 +1,4 @@
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/mihAppBar.dart';
import 'package:patient_manager/components/mihAppDrawer.dart'; import 'package:patient_manager/components/mihAppDrawer.dart';
@@ -35,6 +34,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
late List<List<dynamic>> businessTileList = []; late List<List<dynamic>> businessTileList = [];
late List<List<dynamic>> devTileList = []; late List<List<dynamic>> devTileList = [];
late Future<List<List<List<dynamic>>>> pbswitch; late Future<List<List<List<dynamic>>>> pbswitch;
late bool businessUserSwitch;
int _selectedIndex = 0; int _selectedIndex = 0;
final baseAPI = AppEnviroment.baseApiUrl; final baseAPI = AppEnviroment.baseApiUrl;
@@ -306,6 +306,14 @@ class _HomeTileGridState extends State<HomeTileGrid> {
} }
} }
String getHeading(int index) {
if (index == 0) {
return "Personal Apps";
} else {
return "Business Apps";
}
}
@override @override
void dispose() { void dispose() {
// TODO: implement dispose // TODO: implement dispose
@@ -315,6 +323,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
@override @override
void initState() { void initState() {
pbswitch = setApps(personalTileList, businessTileList); pbswitch = setApps(personalTileList, businessTileList);
businessUserSwitch = false;
super.initState(); super.initState();
} }
@@ -340,14 +349,65 @@ class _HomeTileGridState extends State<HomeTileGrid> {
builder: (ctx, snapshot) { builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
var apps = snapshot.requireData; var apps = snapshot.requireData;
return SizedBox( return Column(
width: width, children: [
height: height, Padding(
padding: const EdgeInsets.only(top: 10, left: 10),
child: Row(
children: [
Text(
"Switch\nProfile",
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15.0,
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
),
),
const SizedBox(width: 10.0),
Switch(
value: businessUserSwitch,
onChanged: (bool value) {
setState(() {
businessUserSwitch = value;
});
if (businessUserSwitch) {
setState(() {
_selectedIndex = 1;
});
} else {
setState(() {
_selectedIndex = 0;
});
}
},
),
],
),
),
Text(
getHeading(_selectedIndex),
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 35.0,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
Expanded(
child: GridView.builder( child: GridView.builder(
padding: EdgeInsets.fromLTRB(width / 6, height / 16, width / 6, padding: EdgeInsets.fromLTRB(
width / 6,
height / 35,
width / 6,
0), //EdgeInsets.symmetric(horizontal: width / 6), 0), //EdgeInsets.symmetric(horizontal: width / 6),
itemCount: apps[_selectedIndex].length, itemCount: apps[_selectedIndex].length,
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( gridDelegate:
const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200), maxCrossAxisExtent: 200),
//const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), //const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
itemBuilder: (context, index) { itemBuilder: (context, index) {
@@ -356,48 +416,50 @@ class _HomeTileGridState extends State<HomeTileGrid> {
return buildtile(tile); return buildtile(tile);
}, },
), ),
),
],
); );
} }
return const Mihloadingcircle(); return const Mihloadingcircle();
}, },
), ),
bottomNavigationBar: Visibility( // bottomNavigationBar: Visibility(
visible: isBusinessUser(widget.signedInUser), // visible: isBusinessUser(widget.signedInUser),
child: Padding( // child: Padding(
padding: const EdgeInsets.all(15.0), // padding: const EdgeInsets.all(15.0),
child: GNav( // child: GNav(
//hoverColor: Colors.lightBlueAccent, // //hoverColor: Colors.lightBlueAccent,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), // color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
iconSize: 35.0, // iconSize: 35.0,
activeColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), // activeColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
tabBackgroundColor: // tabBackgroundColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(), // MzanziInnovationHub.of(context)!.theme.secondaryColor(),
//gap: 20, // //gap: 20,
//padding: EdgeInsets.all(15), // //padding: EdgeInsets.all(15),
tabs: [ // tabs: [
GButton( // GButton(
icon: Icons.perm_identity, // icon: Icons.perm_identity,
text: "Personal", // text: "Personal",
onPressed: () { // onPressed: () {
setState(() { // setState(() {
_selectedIndex = 0; // _selectedIndex = 0;
}); // });
}, // },
), // ),
GButton( // GButton(
icon: Icons.business_center, // icon: Icons.business_center,
text: "Business", // text: "Business",
onPressed: () { // onPressed: () {
setState(() { // setState(() {
_selectedIndex = 1; // _selectedIndex = 1;
}); // });
}, // },
), // ),
], // ],
selectedIndex: _selectedIndex, // selectedIndex: _selectedIndex,
), // ),
), // ),
), // ),
); );
} }
} }