Create app drawer on home screen

This commit is contained in:
2024-07-10 10:41:29 +02:00
parent 162e37f740
commit c1493012c9
2 changed files with 154 additions and 81 deletions

View File

@@ -1,9 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:patient_manager/theme/mihTheme.dart'; import 'package:patient_manager/theme/mihTheme.dart';
class HomeTile extends StatelessWidget { class HomeTile extends StatefulWidget {
final String tileName; final String tileName;
final String tileDescription; //final String tileDescription;
final IconData tileIcon;
final void Function() onTap; final void Function() onTap;
// final Widget tileIcon; // final Widget tileIcon;
@@ -11,54 +12,116 @@ class HomeTile extends StatelessWidget {
super.key, super.key,
required this.onTap, required this.onTap,
required this.tileName, required this.tileName,
required this.tileDescription, //required this.tileDescription,
required this.tileIcon,
}); });
@override @override
Widget build(BuildContext context) { State<HomeTile> createState() => _HomeTileState();
return GestureDetector( }
onTap: onTap,
child: Card( class _HomeTileState extends State<HomeTile> {
color: MyTheme().secondaryColor(), late Color mainC;
elevation: 20, late Color secondC;
@override
void initState() {
mainC = MyTheme().secondaryColor();
secondC = MyTheme().primaryColor();
super.initState();
}
Widget displayTile() {
return FittedBox(
child: Column( child: Column(
//mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: ListTile(
leading: Icon(
Icons.abc,
color: MyTheme().primaryColor(),
),
title: Text(
tileName,
style: TextStyle(
fontWeight: FontWeight.bold,
color: MyTheme().primaryColor(),
),
),
subtitle: Text(
tileDescription,
style: TextStyle(color: MyTheme().primaryColor()),
)),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Padding( GestureDetector(
padding: const EdgeInsets.symmetric(horizontal: 10), onTap: widget.onTap,
onTapDown: (_) {
setState(() {
mainC = MyTheme().primaryColor();
secondC = MyTheme().secondaryColor();
});
},
onTapUp: (_) {
setState(() {
mainC = MyTheme().secondaryColor();
secondC = MyTheme().primaryColor();
});
},
child: Container(
padding: const EdgeInsets.all(3.0),
decoration: BoxDecoration(
color: mainC,
borderRadius: BorderRadius.circular(10.0),
//border: Border.all(color: MyTheme().secondaryColor(), width: 1.0),
),
child: Icon( child: Icon(
Icons.arrow_forward, widget.tileIcon,
color: secondC,
),
),
),
const SizedBox(height: 1),
Text(
widget.tileName,
textAlign: TextAlign.center,
style: TextStyle(
color: MyTheme().secondaryColor(), color: MyTheme().secondaryColor(),
), fontSize: 5.0,
), fontWeight: FontWeight.bold,
],
), ),
) )
], ],
), ),
),
); );
} }
@override
Widget build(BuildContext context) {
return displayTile();
// child: Card(
// color: MyTheme().secondaryColor(),
// elevation: 20,
// child: Column(
// //mainAxisSize: MainAxisSize.min,
// children: [
// Expanded(
// child: ListTile(
// leading: Icon(
// widget.tileIcon,
// color: MyTheme().primaryColor(),
// ),
// title: Text(
// widget.tileName,
// style: TextStyle(
// fontWeight: FontWeight.bold,
// color: MyTheme().primaryColor(),
// ),
// ),
// subtitle: Text(
// widget.tileDescription,
// style: TextStyle(color: MyTheme().primaryColor()),
// )),
// ),
// Expanded(
// child: Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 10),
// child: Icon(
// Icons.arrow_forward,
// color: MyTheme().secondaryColor(),
// ),
// ),
// ],
// ),
// )
// ],
// ),
// ),
}
} }

View File

@@ -1,47 +1,57 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:patient_manager/components/homeTile.dart'; import 'package:patient_manager/components/homeTile.dart';
class HomeTileGrid extends StatelessWidget { class HomeTileGrid extends StatefulWidget {
final String userEmail; final String userEmail;
const HomeTileGrid({super.key, required this.userEmail}); const HomeTileGrid({super.key, required this.userEmail});
@override
State<HomeTileGrid> createState() => _HomeTileGridState();
}
class _HomeTileGridState extends State<HomeTileGrid> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Center( var size = MediaQuery.of(context).size;
child: SizedBox(
width: 1000, double width = size.width;
child: GridView.count( double height = size.height;
padding: const EdgeInsets.all(20), // final double itemHeight = (size.height - kToolbarHeight - 24) / 2;
crossAxisSpacing: 10, // final double itemWidth = size.width / 5;
mainAxisSpacing: 10, List<List<dynamic>> tileList = [
childAspectRatio: MediaQuery.of(context).size.width / 600, [
crossAxisCount: 3, Icons.medication,
children: [ "Patient Manager",
HomeTile( () {
onTap: () {
//print("Home Tiles: $userEmail");
Navigator.of(context) Navigator.of(context)
.pushNamed('/patient-manager', arguments: userEmail); .pushNamed('/patient-manager', arguments: widget.userEmail);
}, }
tileName: "Patient Manager",
tileDescription:
"This is a digital solution for doctors Offices to manage their patients",
),
HomeTile(
onTap: () {},
tileName: "Test",
tileDescription:
"This is a digital solution for doctors Offices to manage their patients",
),
HomeTile(
onTap: () {},
tileName: "Test 1",
tileDescription:
"This is a digital solution for doctors Offices to manage their patients",
),
], ],
[Icons.abc, "Test 1", () {}],
[Icons.abc, "Test 2", () {}],
[Icons.abc, "Test 3", () {}],
[Icons.abc, "Test 4", () {}],
[Icons.abc, "Test 5", () {}],
[Icons.abc, "Test 6", () {}],
];
return GridView.builder(
padding: EdgeInsets.fromLTRB(width / 6, height / 16, width / 6,
0), //EdgeInsets.symmetric(horizontal: width / 6),
itemCount: tileList.length,
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200),
//const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.all(10),
child: HomeTile(
onTap: tileList[index][2],
tileIcon: tileList[index][0],
tileName: tileList[index][1],
), ),
), );
},
); );
} }
} }