2024-04-29 13:58:27 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2024-06-02 16:32:19 +02:00
|
|
|
import '../components/my_drawer.dart';
|
2024-04-29 13:58:27 +02:00
|
|
|
|
2024-04-30 19:25:16 +02:00
|
|
|
class HomePage extends StatelessWidget {
|
2024-06-09 00:04:13 +02:00
|
|
|
const HomePage({super.key});
|
2024-04-29 13:58:27 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2024-06-02 16:32:19 +02:00
|
|
|
title: const Text('Home'),
|
2024-06-07 02:18:20 +02:00
|
|
|
// different appbar style for homepage
|
2024-04-30 19:25:16 +02:00
|
|
|
backgroundColor: Colors.transparent,
|
2024-04-29 13:58:27 +02:00
|
|
|
),
|
2024-04-29 17:11:35 +02:00
|
|
|
drawer: const MyDrawer(),
|
2024-06-07 16:58:29 +02:00
|
|
|
body: Center(
|
2024-06-09 00:04:13 +02:00
|
|
|
child: AspectRatio(
|
|
|
|
aspectRatio: 1,
|
|
|
|
child: LayoutBuilder(
|
|
|
|
builder: (context, constraints) {
|
|
|
|
// Calculation of the tile size based on the spacing
|
|
|
|
double size = constraints.biggest.shortestSide / 2 - 16;
|
|
|
|
return GridView.count(
|
|
|
|
crossAxisCount: 2,
|
2024-06-14 14:15:11 +02:00
|
|
|
crossAxisSpacing: 6.0,
|
|
|
|
mainAxisSpacing: 6.0,
|
2024-06-09 00:04:13 +02:00
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
shrinkWrap: true,
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
children: [
|
|
|
|
_buildTile(
|
|
|
|
context,
|
|
|
|
'Discover',
|
|
|
|
Icons.explore,
|
|
|
|
Colors.lightBlue.shade300,
|
|
|
|
'/discover',
|
|
|
|
size,
|
|
|
|
),
|
|
|
|
_buildTile(
|
|
|
|
context,
|
|
|
|
'View Profiles',
|
|
|
|
Icons.supervised_user_circle,
|
|
|
|
Colors.teal.shade300,
|
|
|
|
'/favorites',
|
|
|
|
size,
|
|
|
|
),
|
|
|
|
_buildTile(
|
|
|
|
context,
|
|
|
|
'Chat',
|
|
|
|
Icons.chat,
|
|
|
|
Colors.indigo.shade300,
|
|
|
|
'/chats',
|
|
|
|
size,
|
|
|
|
),
|
|
|
|
_buildTile(
|
|
|
|
context,
|
|
|
|
'My Profile',
|
|
|
|
Icons.edit_note,
|
|
|
|
Colors.blueGrey.shade300,
|
|
|
|
'/profile',
|
|
|
|
size,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
2024-06-07 16:58:29 +02:00
|
|
|
),
|
|
|
|
),
|
2024-06-09 00:04:13 +02:00
|
|
|
),
|
2024-06-07 16:58:29 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildTile(BuildContext context, String title, IconData icon,
|
|
|
|
Color color, String route, double size) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pushNamed(context, route);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: color,
|
|
|
|
borderRadius: BorderRadius.circular(16.0),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Icon(
|
|
|
|
icon,
|
|
|
|
size: 50,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
2024-06-07 18:55:33 +02:00
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: const TextStyle(color: Colors.white, fontSize: 20),
|
|
|
|
),
|
2024-06-07 16:58:29 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2024-04-29 13:58:27 +02:00
|
|
|
);
|
|
|
|
}
|
2024-04-29 17:11:35 +02:00
|
|
|
}
|