remove future builder and add switch Icon

This commit is contained in:
2024-08-23 15:40:41 +02:00
parent 3616c534db
commit 67358e515a

View File

@@ -33,7 +33,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
late List<List<dynamic>> personalTileList = []; late List<List<dynamic>> personalTileList = [];
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 List<List<List<dynamic>>> pbswitch;
late bool businessUserSwitch; late bool businessUserSwitch;
int _selectedIndex = 0; int _selectedIndex = 0;
final baseAPI = AppEnviroment.baseApiUrl; final baseAPI = AppEnviroment.baseApiUrl;
@@ -246,9 +246,8 @@ class _HomeTileGridState extends State<HomeTileGrid> {
} }
} }
Future<List<List<List<dynamic>>>> setApps( List<List<List<dynamic>>> setApps(List<List<dynamic>> personalTileList,
List<List<dynamic>> personalTileList, List<List<dynamic>> businessTileList) {
List<List<dynamic>> businessTileList) async {
//print(widget.businessUser); //print(widget.businessUser);
if (widget.signedInUser.fname == "") { if (widget.signedInUser.fname == "") {
//print("New personal user"); //print("New personal user");
@@ -344,85 +343,59 @@ class _HomeTileGridState extends State<HomeTileGrid> {
signedInUser: widget.signedInUser, signedInUser: widget.signedInUser,
//logo: MzanziInnovationHub.of(context)!.theme.logoImage(), //logo, //logo: MzanziInnovationHub.of(context)!.theme.logoImage(), //logo,
), ),
body: FutureBuilder( body: Column(
future: pbswitch,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
var apps = snapshot.requireData;
return Column(
children: [ children: [
Padding( Row(
padding: const EdgeInsets.only(top: 10, left: 10),
child: Row(
children: [ children: [
Text( IconButton(
"Switch\nProfile", onPressed: () {
textAlign: TextAlign.center, //print(businessUserSwitch);
style: TextStyle( if (!businessUserSwitch) {
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(() { setState(() {
businessUserSwitch = true;
_selectedIndex = 1; _selectedIndex = 1;
}); });
} else { } else {
setState(() { setState(() {
businessUserSwitch = false;
_selectedIndex = 0; _selectedIndex = 0;
}); });
} }
}, },
icon: const Icon(
Icons.swap_horizontal_circle_outlined,
size: 35,
),
), ),
], ],
), ),
),
Text( Text(
getHeading(_selectedIndex), getHeading(_selectedIndex),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 35.0, fontSize: 35.0,
color: color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
), ),
), ),
Expanded( Expanded(
child: GridView.builder( child: GridView.builder(
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(width / 6, height / 35, width / 6,
width / 6,
height / 35,
width / 6,
0), //EdgeInsets.symmetric(horizontal: width / 6), 0), //EdgeInsets.symmetric(horizontal: width / 6),
itemCount: apps[_selectedIndex].length, itemCount: pbswitch[_selectedIndex].length,
gridDelegate: gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200), maxCrossAxisExtent: 200),
//const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), //const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
itemBuilder: (context, index) { itemBuilder: (context, index) {
var tile = apps[_selectedIndex][index]; var tile = pbswitch[_selectedIndex][index];
//setState(() {}); //setState(() {});
return buildtile(tile); return buildtile(tile);
}, },
), ),
), ),
], ],
);
}
return const Mihloadingcircle();
},
), ),
// bottomNavigationBar: Visibility( // bottomNavigationBar: Visibility(
// visible: isBusinessUser(widget.signedInUser), // visible: isBusinessUser(widget.signedInUser),
// child: Padding( // child: Padding(