Added MyAboutDialog. Swipes left will be hidden for 24 hours.
parent
f38493fc79
commit
ed8f1b810b
|
@ -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'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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());
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
|
@ -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';
|
||||||
|
|
|
@ -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,10 +129,14 @@ 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;
|
||||||
|
@ -131,7 +145,6 @@ class UserProfilePageState extends State<UserProfilePage> {
|
||||||
allUsers.firstWhereOrNull((x) => x.uid == currentUserId);
|
allUsers.firstWhereOrNull((x) => x.uid == currentUserId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
MyLocation? _createLocationFromDoc(Map<String, dynamic>? data) {
|
MyLocation? _createLocationFromDoc(Map<String, dynamic>? data) {
|
||||||
if (data == null || data.isEmpty) return null;
|
if (data == null || data.isEmpty) return null;
|
||||||
|
@ -269,10 +282,23 @@ 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),
|
||||||
|
// Loading...
|
||||||
|
if (userProfiles.isEmpty) ...[
|
||||||
|
const CircularProgressIndicator(),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
const Text(
|
||||||
|
'Loading data, please wait...',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
||||||
|
),
|
||||||
|
] else ...[
|
||||||
Text(
|
Text(
|
||||||
'${userProfiles.length > 1 ? 'No new' : 'No'} profiles available at the moment.',
|
userProfiles.length > 1
|
||||||
|
? 'No new profiles available yet.'
|
||||||
|
: 'No profiles available at the moment.',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold, fontSize: 18),
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 60),
|
const SizedBox(height: 60),
|
||||||
const Text(
|
const Text(
|
||||||
|
@ -281,6 +307,7 @@ class UserProfilePageState extends State<UserProfilePage> {
|
||||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
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(
|
||||||
|
|
Loading…
Reference in New Issue