From 15a6556ac08f90696df5e8ea1542f60ee16fdc16 Mon Sep 17 00:00:00 2001 From: Rafael <1024481@stud.hs-mannheim.de> Date: Fri, 7 Jun 2024 18:55:33 +0200 Subject: [PATCH] homepage: removed placeholder user listing --- lib/components/my_drawer.dart | 7 +- lib/pages/conversations_page.dart | 2 +- lib/pages/home_page.dart | 175 +++++++++--------------------- lib/pages/liked_users_page.dart | 2 +- lib/pages/user_profile_page.dart | 2 +- 5 files changed, 60 insertions(+), 128 deletions(-) diff --git a/lib/components/my_drawer.dart b/lib/components/my_drawer.dart index aecc90f..cb49d6b 100644 --- a/lib/components/my_drawer.dart +++ b/lib/components/my_drawer.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import '../pages/conversations_page.dart'; -import '../pages/home_page.dart'; import '../pages/liked_users_page.dart'; import '../pages/user_data_page.dart'; import '../pages/settings_page.dart'; @@ -45,13 +44,13 @@ class MyDrawer extends StatelessWidget { onTap: () { // pop the drawer Navigator.pop(context); - // Navigate to HomePage? - Navigator.push( + // Optional: Navigate to HomePage +/* Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => HomePage(), ), - ); + );*/ }, ), ), diff --git a/lib/pages/conversations_page.dart b/lib/pages/conversations_page.dart index f2cb6c2..dea45dd 100644 --- a/lib/pages/conversations_page.dart +++ b/lib/pages/conversations_page.dart @@ -15,7 +15,7 @@ class ConversationsPage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text('Your Chat Contacts'), + title: const Text('My Chat Contacts'), backgroundColor: Colors.transparent, ), body: _buildUserMatchesList(), diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 552f91e..760bca8 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -1,11 +1,7 @@ import 'package:flutter/material.dart'; import '../components/my_drawer.dart'; -import '../components/user_tile.dart'; -import '../constants.dart'; import '../services/auth/auth_service.dart'; -import '../services/user_service.dart'; -import 'chat_page.dart'; class HomePage extends StatelessWidget { HomePage({super.key}); @@ -23,68 +19,58 @@ class HomePage extends StatelessWidget { drawer: const MyDrawer(), // 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(), - ), - ], + 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, + 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.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, + ), + ], + ); + }, + ), ), ), - ), ); } @@ -95,8 +81,6 @@ class HomePage extends StatelessWidget { Navigator.pushNamed(context, route); }, child: Container( - width: size, - height: size, decoration: BoxDecoration( color: color, borderRadius: BorderRadius.circular(16.0), @@ -110,64 +94,13 @@ class HomePage extends StatelessWidget { color: Colors.white, ), const SizedBox(height: 10), - Text(title, - style: const TextStyle(color: Colors.white, fontSize: 20)), + Text( + title, + style: const TextStyle(color: Colors.white, fontSize: 20), + ), ], ), ), ); } - - // build a list of users except for the current logged in user - Widget _buildUserList() { - return StreamBuilder( - stream: UserService.getUsersStream(), - builder: (context, snapshot) { - // error - if (snapshot.hasError) { - return Text('Error: ${snapshot.error.toString()}'); - } - - //loading - if (snapshot.connectionState == ConnectionState.waiting) { - return const Text('Loading..'); - } - - // return list view - return ListView( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - children: snapshot.data! - .map( - (userData) => _buildUserListItem(userData, context)) - .toList(), - ); - }); - } - - // build individual user list item - Widget _buildUserListItem( - Map userData, BuildContext context) { - // display all users except current user - if (userData[Constants.dbFieldUsersEmail] != - _authService.getCurrentUser()!.email) { - return UserTile( - text: userData[Constants.dbFieldUsersEmail], - onTap: () { - // tapped on a user -> go to chat page - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ChatPage( - receiverEmail: userData[Constants.dbFieldUsersEmail], - receiverID: userData[Constants.dbFieldUsersID], - ), - ), - ); - }, - ); - } else { - return Container(); - } - } } diff --git a/lib/pages/liked_users_page.dart b/lib/pages/liked_users_page.dart index e7d9935..a40bada 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('Favorite people'), + title: const Text('My favored profiles'), ), body: Column( children: [ diff --git a/lib/pages/user_profile_page.dart b/lib/pages/user_profile_page.dart index 1e7f886..f0db8e7 100644 --- a/lib/pages/user_profile_page.dart +++ b/lib/pages/user_profile_page.dart @@ -193,7 +193,7 @@ class _UserProfilePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text('User Profile'), + title: const Text('My Profile Information'), ), body: isLoading ? const Center(child: CircularProgressIndicator())