Skip to content

Commit

Permalink
Merge pull request #39 from Dune-Global:feature/main/explore
Browse files Browse the repository at this point in the history
feat: Saved event page
  • Loading branch information
yasithranusha authored Apr 11, 2024
2 parents 6f4ba2f + 42874f1 commit 3fa8200
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 314 deletions.
Binary file added flutter_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 30 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -834,13 +834,20 @@ PODS:
- Firebase/Firestore (10.22.0):
- Firebase/CoreOnly
- FirebaseFirestore (~> 10.22.0)
- Firebase/Storage (10.22.0):
- Firebase/CoreOnly
- FirebaseStorage (~> 10.22.0)
- firebase_auth (4.19.0):
- Firebase/Auth (= 10.22.0)
- firebase_core
- Flutter
- firebase_core (2.28.0):
- firebase_core (2.29.0):
- Firebase/CoreOnly (= 10.22.0)
- Flutter
- firebase_storage (11.7.1):
- Firebase/Storage (= 10.22.0)
- firebase_core
- Flutter
- FirebaseAppCheckInterop (10.23.0)
- FirebaseAuth (10.22.0):
- FirebaseAppCheckInterop (~> 10.17)
Expand All @@ -849,6 +856,7 @@ PODS:
- GoogleUtilities/Environment (~> 7.8)
- GTMSessionFetcher/Core (< 4.0, >= 2.1)
- RecaptchaInterop (~> 100.0)
- FirebaseAuthInterop (10.24.0)
- FirebaseCore (10.22.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.12)
Expand Down Expand Up @@ -878,6 +886,12 @@ PODS:
- leveldb-library (~> 1.22)
- nanopb (< 2.30911.0, >= 2.30908.0)
- FirebaseSharedSwift (10.23.0)
- FirebaseStorage (10.22.0):
- FirebaseAppCheckInterop (~> 10.0)
- FirebaseAuthInterop (~> 10.0)
- FirebaseCore (~> 10.0)
- FirebaseCoreExtension (~> 10.0)
- GTMSessionFetcher/Core (< 4.0, >= 2.1)
- Flutter (1.0.0)
- flutter_native_splash (0.0.1):
- Flutter
Expand Down Expand Up @@ -982,6 +996,8 @@ PODS:
- gRPC-Core/Interface (1.62.1)
- gRPC-Core/Privacy (1.62.1)
- GTMSessionFetcher/Core (3.3.2)
- image_picker_ios (0.0.1):
- Flutter
- leveldb-library (1.22.4)
- nanopb (2.30909.1):
- nanopb/decode (= 2.30909.1)
Expand All @@ -1000,8 +1016,10 @@ DEPENDENCIES:
- cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_storage (from `.symlinks/plugins/firebase_storage/ios`)
- Flutter (from `Flutter`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

Expand All @@ -1012,12 +1030,14 @@ SPEC REPOS:
- Firebase
- FirebaseAppCheckInterop
- FirebaseAuth
- FirebaseAuthInterop
- FirebaseCore
- FirebaseCoreExtension
- FirebaseCoreInternal
- FirebaseFirestore
- FirebaseFirestoreInternal
- FirebaseSharedSwift
- FirebaseStorage
- GoogleUtilities
- "gRPC-C++"
- gRPC-Core
Expand All @@ -1034,10 +1054,14 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/firebase_auth/ios"
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
firebase_storage:
:path: ".symlinks/plugins/firebase_storage/ios"
Flutter:
:path: Flutter
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
url_launcher_ios:
Expand All @@ -1049,21 +1073,25 @@ SPEC CHECKSUMS:
cloud_firestore: 4991f9c366cc8446171deec57a905c572c964fc1
Firebase: 797fd7297b7e1be954432743a0b3f90038e45a71
firebase_auth: bd4ebe97d1e836aa5692b75c8f13412ed4381871
firebase_core: d955499180c3c8ef355adf46b8752c4c01d09e0a
firebase_core: aaadbddb3cb2ee3792b9804f9dbb63e5f6f7b55c
firebase_storage: 8d42f27f702499161335b5075aa67bf6f2d821fb
FirebaseAppCheckInterop: a1955ce8c30f38f87e7d091630e871e91154d65d
FirebaseAuth: bbe4c68f958504ba9e54aee181adbdf5b664fbc6
FirebaseAuthInterop: 29336ab84df12fc0f340ba5fe58d3e5811a4192d
FirebaseCore: 0326ec9b05fbed8f8716cddbf0e36894a13837f7
FirebaseCoreExtension: cb88851781a24e031d1b58e0bd01eb1f46b044b5
FirebaseCoreInternal: 6a292e6f0bece1243a737e81556e56e5e19282e3
FirebaseFirestore: 16cb8a85fc29da272deaed22a101e24703251da9
FirebaseFirestoreInternal: 627b23f682c1c2aad38ba1345ed3ca6574c5a89c
FirebaseSharedSwift: c92645b392db3c41a83a0aa967de16f8bad25568
FirebaseStorage: bc7bddc743548a89cfb896843a77cf4bdde2c231
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778
GoogleUtilities: d053d902a8edaa9904e1bd00c37535385b8ed152
"gRPC-C++": 12f33a422dcab88dcd0c53e52cd549a929f0f244
gRPC-Core: 6ec9002832e1e22c5bb8c54994b050b0ee4205c6
GTMSessionFetcher: 0e876eea9782ec6462e91ab872711c357322c94f
image_picker_ios: b545a5f16c0fa88e3ecbbce3ed4de45567a8ec18
leveldb-library: 06a69cc7582d64b29424a63e085e683cc188230a
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
Expand Down
21 changes: 21 additions & 0 deletions lib/data/repositories/user/user_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:uni_junction/data/repositories/authentication/authentication_repository.dart';
import 'package:uni_junction/features/event/models/event/event_model.dart';
import 'package:uni_junction/features/personalization/models/user_model.dart';
import 'package:uni_junction/utils/exceptions/firebase_exceptions.dart';
import 'package:uni_junction/utils/exceptions/format_exceptions.dart';
Expand Down Expand Up @@ -101,7 +102,27 @@ class UserRepository extends GetxController {
throw e;
}
}
// Get user liked events
Future<List<EventModel>> getUserLikedEvents() async {
try {
final user = await fetchUserDetails();
final likedEventIds = user.likedEvents;

// Print likedEventIds
print('Liked event ids: $likedEventIds');

final List<EventModel> likedEvents = [];
for (var eventId in likedEventIds) {
final doc = await _db.collection("Events").doc(eventId).get();
if (doc.exists) {
likedEvents.add(EventModel.fromSnapshot(doc));
}
}
return likedEvents;
} catch (e) {
throw e;
}
}
//update user
Future<void> updateUser(UserModel user) async {
try {
Expand Down
22 changes: 20 additions & 2 deletions lib/features/event/controllers/event/event_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:uni_junction/utils/constants/image_strings.dart';
import 'package:uni_junction/utils/popup/full_screen_loader.dart';
import 'package:uni_junction/data/services/university/universities.dart';
import 'package:uni_junction/data/services/event_category/event_category_list.dart';
import 'dart:convert';

class EventController extends GetxController {
static EventController get instance => Get.find();
Expand All @@ -37,6 +38,8 @@ class EventController extends GetxController {
final selectedEventCategory = 'Select a category'.obs;
final eventCategoryList = eventCategoryLists.obs;

final userLikedEvents = <EventModel>[].obs;

// Variables
final startDate = TextEditingController();
final endDate = TextEditingController();
Expand Down Expand Up @@ -101,6 +104,21 @@ class EventController extends GetxController {
}
}

Future<void> fetchUserLikedEvents() async {
try {
final userRepository = Get.put(UserRepository());
final events = await userRepository.getUserLikedEvents();
userLikedEvents.assignAll(events);

// Convert each event to JSON and print it
for (var event in events) {
print(jsonEncode(event.toJson()));
}
} catch (e) {
print(e.toString());
}
}

Future<void> selectDate(BuildContext context) async {
DateTime? picked = await showDatePicker(
context: context,
Expand Down Expand Up @@ -273,8 +291,8 @@ class EventController extends GetxController {

// Check if user is attending the event
Future<bool> isUserAttendingEvent(String eventId) async {
final eventRepository = Get.put(EventRepository());
return eventRepository.isUserAttending(eventId);
final eventRepository = Get.put(EventRepository());
return eventRepository.isUserAttending(eventId);
}

Future<void> pickImage() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TCategoryEvents extends StatelessWidget {
),
Text(
style: TextStyle(fontSize: 17),
textAlign: TextAlign.center,
textAlign: TextAlign.center,
"Sorry, there are no events currently for this category"),
],
),
Expand Down
58 changes: 30 additions & 28 deletions lib/features/event/screens/saved/saved.dart
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get_connect/http/src/utils/utils.dart';
import 'package:uni_junction/common/widgets/appbar/appbar.dart';
import 'package:uni_junction/common/widgets/custom_shapes/containers/primary_header_container.dart';
import 'package:uni_junction/features/event/screens/create_event/widgets/create_event_appbar.dart';
import 'package:uni_junction/features/event/screens/create_event/widgets/create_event_form.dart';
import 'package:uni_junction/features/event/screens/home/widgets/this_month_event_all.dart';
import 'package:uni_junction/features/event/controllers/event/event_controller.dart';
import 'package:uni_junction/features/event/screens/saved/widgets/saved_appbar.dart';
import 'package:uni_junction/features/event/screens/saved/widgets/saved_event_.dart';
import 'package:uni_junction/features/event/screens/saved/widgets/saved_events.dart';
import 'package:uni_junction/utils/constants/colors.dart';
import 'package:uni_junction/utils/constants/text_strings.dart';
import 'package:get/get.dart';

class SavedScreen extends StatelessWidget {
const SavedScreen({super.key});

@override
Widget build(BuildContext context) {
// final Save = Get.put(SaveController());
return const Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
TPrimaryHeaderContainer(
height: 150,
backgroundColor: TColors.primary,
child: Column(
children: [
// Home AppBar
TSavedEventAppBar(),
SizedBox(height: 20),
],
),
final eventController = Get.put(EventController());

return Scaffold(
body: RefreshIndicator(
onRefresh: () async {
PaintingBinding.instance.imageCache.clear();
await eventController.fetchUserLikedEvents();
await Future.delayed(const Duration(seconds: 1));
},
child: SingleChildScrollView(
child: Column(
children: [
TPrimaryHeaderContainer(
height: 150,
backgroundColor: TColors.primary,
child: Column(
children: [
TSavedEventAppBar(),
SizedBox(height: 20),
],
),
),
SizedBox(height: 20),
TSavedEvents(),
],
),
// TCreateEventForm(controller: Save,),
// TThisMonthEventCards(),
SizedBox(height: 20),
// TSavedEventCards(),
],
),
),
));
);
}
}
Empty file.
48 changes: 0 additions & 48 deletions lib/features/event/screens/saved/widgets/saved_event_.dart

This file was deleted.

Loading

0 comments on commit 3fa8200

Please sign in to comment.