Added MyAboutDialog. Swipes left will be hidden for 24 hours.

master
Rafael 2024-05-26 17:33:28 +02:00
parent f38493fc79
commit ed8f1b810b
4 changed files with 145 additions and 31 deletions

View File

@ -0,0 +1,79 @@
import 'package:flutter/material.dart';
import '../constants.dart';
class MyAboutDialog extends StatelessWidget {
const MyAboutDialog({super.key});
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Row(
children: [
Icon(Icons.info),
SizedBox(width: 10),
Text('About the app', style: TextStyle(fontSize: 18)),
],
),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
const Row(
children: [
Icon(Icons.apps, size: 50),
SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
Constants.appTitle,
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
Text(
'Version ${Constants.appVersion} (${Constants.appCompilationDate})'),
],
),
],
),
const SizedBox(height: 20),
const Text(
'© 2024 Team ${Constants.appTitle}. All rights reserved.'),
const SizedBox(height: 20),
GestureDetector(
onTap: () => {},
child: const Text(
'https://www.no-website.yet',
style: TextStyle(
color: Colors.blue,
decoration: TextDecoration.underline,
),
),
),
const SizedBox(height: 20),
const Text(
'${Constants.appTitle} helps entrepreneurs find the right co-founders who complement their skills and also share their interests and business goals. '
'Whether you are looking for a tech expert, a marketing guru, or a visionary partner. This app aims to help you finding a perfect co-founder to bring your startup ideas to life.',
),
],
),
),
actions: [
TextButton(
onPressed: () {
showLicensePage(context: context);
},
child: const Text('View licenses'),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Close'),
),
],
);
}
}

View File

@ -5,6 +5,7 @@ import '../pages/settings_page.dart';
import '../pages/user_profile_page.dart'; import '../pages/user_profile_page.dart';
import '../services/auth/auth_service.dart'; import '../services/auth/auth_service.dart';
import 'feedback_dialog.dart'; import 'feedback_dialog.dart';
import 'my_about_dialog.dart';
class MyDrawer extends StatelessWidget { class MyDrawer extends StatelessWidget {
const MyDrawer({super.key}); const MyDrawer({super.key});
@ -137,7 +138,12 @@ class MyDrawer extends StatelessWidget {
child: ListTile( child: ListTile(
title: const Text("About the app"), title: const Text("About the app"),
leading: const Icon(Icons.perm_device_info), leading: const Icon(Icons.perm_device_info),
onTap: () {}, // TODO onTap: () {
Navigator.pop(context);
showDialog(
context: context,
builder: (context) => const MyAboutDialog());
},
), ),
), ),

View File

@ -2,7 +2,9 @@ class Constants {
Constants._(); Constants._();
/// Title of the app /// Title of the app
static const String appTitle = "Cofounderella"; static const String appTitle = 'Cofounderella';
static const String appVersion = '1.0.0';
static const String appCompilationDate = '2024-05-26';
static const String dbCollectionFeedbacks = 'feedbacks'; static const String dbCollectionFeedbacks = 'feedbacks';
static const String dbCollectionUsers = 'Users'; static const String dbCollectionUsers = 'Users';

View File

@ -19,14 +19,14 @@ class UserProfilePage extends StatefulWidget {
} }
class UserProfilePageState extends State<UserProfilePage> { class UserProfilePageState extends State<UserProfilePage> {
/// List with [all] user profiles
List<UserProfile> userProfiles = [];
/// The current's user profile /// The current's user profile
UserProfile? currentUserProfile; UserProfile? currentUserProfile;
/// Other users that yet did either not receive a swipe status /// List with [all] user profiles
List<UserProfile> potentialUserProfiles = []; // potential users for matching List<UserProfile> userProfiles = [];
/// List of user profiles to show.
List<UserProfile> potentialUserProfiles = [];
late final SwipableStackController _controller; late final SwipableStackController _controller;
@ -52,10 +52,13 @@ class UserProfilePageState extends State<UserProfilePage> {
} }
Future<void> _fetchUserProfiles() async { Future<void> _fetchUserProfiles() async {
final String currentUserId = _authService.getCurrentUser()!.uid;
List<UserProfile> allUsers = [];
List<UserProfile> showProfiles = [];
final usersSnapshot = await FirebaseFirestore.instance final usersSnapshot = await FirebaseFirestore.instance
.collection(Constants.dbCollectionUsers) .collection(Constants.dbCollectionUsers)
.get(); .get();
final String currentUserId = _authService.getCurrentUser()!.uid;
// Fetch the list of profiles the current user has already swiped // Fetch the list of profiles the current user has already swiped
final QuerySnapshot swipesSnapshot = await FirebaseFirestore.instance final QuerySnapshot swipesSnapshot = await FirebaseFirestore.instance
@ -63,13 +66,20 @@ class UserProfilePageState extends State<UserProfilePage> {
.doc(currentUserId) .doc(currentUserId)
.collection(Constants.dbCollectionSwipes) .collection(Constants.dbCollectionSwipes)
.get(); .get();
final Set<String> likedUserIds = swipesSnapshot.docs final Set<String> likedUserIds = swipesSnapshot.docs
.where((doc) => doc['liked'] == true) .where((doc) => doc['liked'] == true)
.map((doc) => doc.id) .map((doc) => doc.id)
.toSet(); .toSet();
List<UserProfile> allUsers = []; final DateTime thresholdDate =
List<UserProfile> showProfiles = []; DateTime.now().subtract(const Duration(hours: 24));
final Set<String> dislikedUserIds = swipesSnapshot.docs
.where((doc) =>
doc['liked'] == false &&
(doc['timestamp'] as Timestamp).toDate().isAfter(thresholdDate))
.map((doc) => doc.id)
.toSet();
for (var userDoc in usersSnapshot.docs) { for (var userDoc in usersSnapshot.docs) {
final languagesSnapshot = await userDoc.reference final languagesSnapshot = await userDoc.reference
@ -119,18 +129,21 @@ class UserProfilePageState extends State<UserProfilePage> {
// add profiles accordingly // add profiles accordingly
allUsers.add(userProfile); allUsers.add(userProfile);
// Exclude the current user's profile and the already liked profiles // Exclude (1) the current user's profile, (2) the already liked profiles
if (userDoc.id != currentUserId && !likedUserIds.contains(userDoc.id)) { // and (3) users that were disliked less than 24 hours ago
if (userDoc.id != currentUserId &&
!likedUserIds.contains(userDoc.id) &&
!dislikedUserIds.contains(userDoc.id)) {
showProfiles.add(userProfile); showProfiles.add(userProfile);
} }
} // end for
setState(() { setState(() {
userProfiles = allUsers; userProfiles = allUsers;
potentialUserProfiles = showProfiles; potentialUserProfiles = showProfiles;
currentUserProfile = currentUserProfile =
allUsers.firstWhereOrNull((x) => x.uid == currentUserId); allUsers.firstWhereOrNull((x) => x.uid == currentUserId);
}); });
}
} }
MyLocation? _createLocationFromDoc(Map<String, dynamic>? data) { MyLocation? _createLocationFromDoc(Map<String, dynamic>? data) {
@ -269,17 +282,31 @@ class UserProfilePageState extends State<UserProfilePage> {
children: [ children: [
const Icon(Icons.person_search, size: 64), const Icon(Icons.person_search, size: 64),
const SizedBox(height: 20), const SizedBox(height: 20),
Text( // Loading...
'${userProfiles.length > 1 ? 'No new' : 'No'} profiles available at the moment.', if (userProfiles.isEmpty) ...[
style: const TextStyle( const CircularProgressIndicator(),
fontWeight: FontWeight.bold, fontSize: 18), const SizedBox(height: 20),
), const Text(
const SizedBox(height: 60), 'Loading data, please wait...',
const Text( style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
'Please check back later, perhaps tomorrow.', ),
textAlign: TextAlign.center, ] else ...[
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), Text(
), userProfiles.length > 1
? 'No new profiles available yet.'
: 'No profiles available at the moment.',
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
const SizedBox(height: 60),
const Text(
'Please check back later, perhaps tomorrow.',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
),
],
], ],
), ),
), ),
@ -288,7 +315,7 @@ class UserProfilePageState extends State<UserProfilePage> {
} }
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('User Profiles')), appBar: AppBar(title: const Text('Find your Match')),
body: SafeArea( body: SafeArea(
top: false, top: false,
child: Stack( child: Stack(