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 'package:flutter/material.dart';
import '../pages/conversations_page.dart'; import '../pages/conversations_page.dart';
import '../pages/home_page.dart';
import '../pages/liked_users_page.dart'; import '../pages/liked_users_page.dart';
import '../pages/user_data_page.dart'; import '../pages/user_data_page.dart';
import '../pages/settings_page.dart'; import '../pages/settings_page.dart';
@ -45,13 +44,13 @@ class MyDrawer extends StatelessWidget {
onTap: () { onTap: () {
// pop the drawer // pop the drawer
Navigator.pop(context); Navigator.pop(context);
// Navigate to HomePage? // Optional: Navigate to HomePage
Navigator.push( /* Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) => HomePage(), builder: (BuildContext context) => HomePage(),
), ),
); );*/
}, },
), ),
), ),

View File

@ -15,7 +15,7 @@ class ConversationsPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Your Chat Contacts'), title: const Text('My Chat Contacts'),
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
), ),
body: _buildUserMatchesList(), body: _buildUserMatchesList(),

View File

@ -1,11 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../components/my_drawer.dart'; import '../components/my_drawer.dart';
import '../components/user_tile.dart';
import '../constants.dart';
import '../services/auth/auth_service.dart'; import '../services/auth/auth_service.dart';
import '../services/user_service.dart';
import 'chat_page.dart';
class HomePage extends StatelessWidget { class HomePage extends StatelessWidget {
HomePage({super.key}); HomePage({super.key});
@ -23,10 +19,7 @@ class HomePage extends StatelessWidget {
drawer: const MyDrawer(), drawer: const MyDrawer(),
// body: _buildUserList(), // body: _buildUserList(),
body: Center( body: Center(
child: SingleChildScrollView( child: AspectRatio(
child: Column(
children: [
AspectRatio(
aspectRatio: 1, aspectRatio: 1,
child: LayoutBuilder( child: LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
@ -51,7 +44,7 @@ class HomePage extends StatelessWidget {
_buildTile( _buildTile(
context, context,
'View Profiles', 'View Profiles',
Icons.star, Icons.supervised_user_circle,
Colors.teal.shade300, Colors.teal.shade300,
'/favorites', '/favorites',
size, size,
@ -67,7 +60,7 @@ class HomePage extends StatelessWidget {
_buildTile( _buildTile(
context, context,
'My Profile', 'My Profile',
Icons.person, Icons.edit_note,
Colors.blueGrey.shade300, Colors.blueGrey.shade300,
'/profile', '/profile',
size, size,
@ -77,13 +70,6 @@ class HomePage extends StatelessWidget {
}, },
), ),
), ),
Container(
height: 400, // Adjust this height as needed
child: _buildUserList(),
),
],
),
),
), ),
); );
} }
@ -95,8 +81,6 @@ class HomePage extends StatelessWidget {
Navigator.pushNamed(context, route); Navigator.pushNamed(context, route);
}, },
child: Container( child: Container(
width: size,
height: size,
decoration: BoxDecoration( decoration: BoxDecoration(
color: color, color: color,
borderRadius: BorderRadius.circular(16.0), borderRadius: BorderRadius.circular(16.0),
@ -110,64 +94,13 @@ class HomePage extends StatelessWidget {
color: Colors.white, color: Colors.white,
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
Text(title, Text(
style: const TextStyle(color: Colors.white, fontSize: 20)), 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) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Favorite people'), title: const Text('My favored profiles'),
), ),
body: Column( body: Column(
children: [ children: [

View File

@ -193,7 +193,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('User Profile'), title: const Text('My Profile Information'),
), ),
body: isLoading body: isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())