homepage: removed placeholder user listing

master
Rafael 2024-06-07 18:55:33 +02:00
parent 896db0125b
commit 15a6556ac0
5 changed files with 60 additions and 128 deletions

View File

@ -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(),
),
);
);*/
},
),
),

View File

@ -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(),

View File

@ -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<Widget>(
(userData) => _buildUserListItem(userData, context))
.toList(),
);
});
}
// build individual user list item
Widget _buildUserListItem(
Map<String, dynamic> 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();
}
}
}

View File

@ -232,7 +232,7 @@ class LikedUsersPageState extends State<LikedUsersPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Favorite people'),
title: const Text('My favored profiles'),
),
body: Column(
children: [

View File

@ -193,7 +193,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
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())