From 896db0125b91a2f035e56147fa29fb047ea4af0a Mon Sep 17 00:00:00 2001 From: Rafael <1024481@stud.hs-mannheim.de> Date: Fri, 7 Jun 2024 16:58:29 +0200 Subject: [PATCH] homepage: navigation tiles --- lib/main.dart | 10 +++ lib/pages/conversations_page.dart | 2 - lib/pages/home_page.dart | 97 ++++++++++++++++++++++++++++- lib/pages/liked_users_page.dart | 2 +- lib/pages/user_matching_page.dart | 2 +- lib/services/auth/auth_gate.dart | 4 +- lib/services/chat/chat_service.dart | 2 +- 7 files changed, 111 insertions(+), 8 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index f00f363..aebd4e6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,6 +5,10 @@ import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:provider/provider.dart'; import 'firebase_options.dart'; +import 'pages/conversations_page.dart'; +import 'pages/liked_users_page.dart'; +import 'pages/user_matching_page.dart'; +import 'pages/user_profile_page.dart'; void main() async { // Firebase stuff @@ -32,6 +36,12 @@ class MyApp extends StatelessWidget { title: Constants.appTitle, theme: Provider.of(context).themeData, home: const AuthGate(), + routes: { + '/discover': (context) => const UserMatchingPage(), + '/favorites': (context) => const LikedUsersPage(), + '/chats': (context) => ConversationsPage(), + '/profile': (context) => const UserProfilePage(), + }, ); } } diff --git a/lib/pages/conversations_page.dart b/lib/pages/conversations_page.dart index 0001703..f2cb6c2 100644 --- a/lib/pages/conversations_page.dart +++ b/lib/pages/conversations_page.dart @@ -17,8 +17,6 @@ class ConversationsPage extends StatelessWidget { appBar: AppBar( title: const Text('Your Chat Contacts'), backgroundColor: Colors.transparent, - foregroundColor: Colors.grey.shade800, - elevation: 0, ), body: _buildUserMatchesList(), ); diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 3f5c8b9..552f91e 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -21,7 +21,100 @@ class HomePage extends StatelessWidget { backgroundColor: Colors.transparent, ), drawer: const MyDrawer(), - body: _buildUserList(), + // body: _buildUserList(), + body: Center( + child: SingleChildScrollView( + child: Column( + children: [ + 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, + crossAxisSpacing: 16.0, + mainAxisSpacing: 16.0, + 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.star, + Colors.teal.shade300, + '/favorites', + size, + ), + _buildTile( + context, + 'Chat', + Icons.chat, + Colors.indigo.shade300, + '/chats', + size, + ), + _buildTile( + context, + 'My Profile', + Icons.person, + Colors.blueGrey.shade300, + '/profile', + size, + ), + ], + ); + }, + ), + ), + Container( + height: 400, // Adjust this height as needed + child: _buildUserList(), + ), + ], + ), + ), + ), + ); + } + + Widget _buildTile(BuildContext context, String title, IconData icon, + Color color, String route, double size) { + return InkWell( + onTap: () { + Navigator.pushNamed(context, route); + }, + child: Container( + width: size, + height: size, + 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), + Text(title, + style: const TextStyle(color: Colors.white, fontSize: 20)), + ], + ), + ), ); } @@ -42,6 +135,8 @@ class HomePage extends StatelessWidget { // return list view return ListView( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), children: snapshot.data! .map( (userData) => _buildUserListItem(userData, context)) diff --git a/lib/pages/liked_users_page.dart b/lib/pages/liked_users_page.dart index 3acbcd9..e7d9935 100644 --- a/lib/pages/liked_users_page.dart +++ b/lib/pages/liked_users_page.dart @@ -232,7 +232,7 @@ class LikedUsersPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text('Liked Users'), + title: const Text('Favorite people'), ), body: Column( children: [ diff --git a/lib/pages/user_matching_page.dart b/lib/pages/user_matching_page.dart index 6d8bf7f..79d2474 100644 --- a/lib/pages/user_matching_page.dart +++ b/lib/pages/user_matching_page.dart @@ -269,7 +269,7 @@ class UserMatchingPageState extends State { Widget build(BuildContext context) { if (potentialUserProfiles.isEmpty) { return Scaffold( - appBar: AppBar(title: const Text('User Profiles')), + appBar: AppBar(title: const Text('Find your Match')), body: Center( child: Padding( padding: const EdgeInsets.all(16.0), diff --git a/lib/services/auth/auth_gate.dart b/lib/services/auth/auth_gate.dart index ca32542..412a137 100644 --- a/lib/services/auth/auth_gate.dart +++ b/lib/services/auth/auth_gate.dart @@ -105,7 +105,7 @@ class AuthGate extends StatelessWidget { await _checkUsersCollectionExists(Constants.dbCollectionLocations); return languagesExist && locationsExist; } catch (e) { - debugPrint(e.toString()); + debugPrint('DebugPrint: checkCollectionsExist -> ${e.toString()}'); return false; } } @@ -120,7 +120,7 @@ class AuthGate extends StatelessWidget { final snapshot = await collection.limit(1).get(); return snapshot.docs.isNotEmpty; } catch (e) { - debugPrint(e.toString()); + debugPrint('DebugPrint: checkUsersCollectionExists -> ${e.toString()}'); return false; } } diff --git a/lib/services/chat/chat_service.dart b/lib/services/chat/chat_service.dart index f896074..1fac1ce 100644 --- a/lib/services/chat/chat_service.dart +++ b/lib/services/chat/chat_service.dart @@ -86,7 +86,7 @@ class ChatService { timestamp = lastMessageDoc[Constants.dbFieldMessageTimestamp]; } } catch (e) { - debugPrint(e.toString()); + debugPrint('DebugPrint: getLastMessage -> ${e.toString()}'); return null; }