homepage: navigation tiles

master
Rafael 2024-06-07 16:58:29 +02:00
parent a4aa0ed18f
commit 896db0125b
7 changed files with 111 additions and 8 deletions

View File

@ -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<ThemeProvider>(context).themeData,
home: const AuthGate(),
routes: {
'/discover': (context) => const UserMatchingPage(),
'/favorites': (context) => const LikedUsersPage(),
'/chats': (context) => ConversationsPage(),
'/profile': (context) => const UserProfilePage(),
},
);
}
}

View File

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

View File

@ -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<Widget>(
(userData) => _buildUserListItem(userData, context))

View File

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

View File

@ -269,7 +269,7 @@ class UserMatchingPageState extends State<UserMatchingPage> {
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),

View File

@ -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;
}
}

View File

@ -86,7 +86,7 @@ class ChatService {
timestamp = lastMessageDoc[Constants.dbFieldMessageTimestamp];
}
} catch (e) {
debugPrint(e.toString());
debugPrint('DebugPrint: getLastMessage -> ${e.toString()}');
return null;
}