-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,047 additions
and
405 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as functions from 'firebase-functions'; | ||
import * as admin from 'firebase-admin'; | ||
|
||
admin.initializeApp(); | ||
|
||
export const updateAttendeesCount = functions.firestore | ||
.document('event/{eventId}/attendees/{attendeeId}') | ||
.onWrite(async (change, context) => { | ||
const eventId = context.params.eventId; | ||
const eventRef = admin.firestore().collection('event').doc(eventId); | ||
|
||
const attendeesSnapshot = await eventRef.collection('attendees').get(); | ||
const attendeesCount = attendeesSnapshot.size; | ||
|
||
return eventRef.update({ attendees: attendeesCount }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class AppAssets { | ||
static const _imagesPath = 'assets/images'; | ||
static const banner = '$_imagesPath/banner.jpeg'; | ||
static const calendar = '$_imagesPath/calendar.png'; | ||
static const location = '$_imagesPath/location.png'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:flutter/painting.dart'; | ||
|
||
class AppColors { | ||
static const iconBackground = Color(0x195669FF); | ||
static const primary = Color(0xFF5669FF); | ||
static const primaryFont = Color(0xFF3F38DD); | ||
static const flutterNavy = Color(0xFF042B59); | ||
|
||
static const cancel = Color(0xFF042B59); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,49 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:firebase_auth/firebase_auth.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter_community_ibague/src/data/events_repository.dart'; | ||
import 'package:flutter_community_ibague/src/models/event.dart'; | ||
|
||
class EventNotifier extends ChangeNotifier { | ||
final EventsRepository _eventsRepository; | ||
final FirebaseAuth _auth; | ||
|
||
final String eventId; | ||
Event event; | ||
bool get attending => event.attendees.any((uid) => uid == _user?.uid); | ||
late final StreamSubscription _eventSubscription; | ||
User? get _user => _auth.currentUser; | ||
|
||
EventNotifier({ | ||
required this.eventId, | ||
required this.event, | ||
EventsRepository? eventsRepository, | ||
}) : _eventsRepository = eventsRepository ?? EventsRepository(); | ||
FirebaseAuth? auth, | ||
}) : _eventsRepository = eventsRepository ?? EventsRepository(), | ||
_auth = auth ?? FirebaseAuth.instance { | ||
print('listen to event'); | ||
_eventSubscription = | ||
_eventsRepository.eventStream(id: event.id).listen((event) { | ||
print(event); | ||
event = event; | ||
notifyListeners(); | ||
}); | ||
} | ||
|
||
void attendEvent() { | ||
if (_user != null) { | ||
_eventsRepository.attendToEvent(event.id, _user!.uid); | ||
} | ||
} | ||
|
||
void attendEvent( | ||
String uid, | ||
) { | ||
_eventsRepository.attendToEvent(eventId, uid); | ||
void notAttendEvent() { | ||
if (_user != null) { | ||
_eventsRepository.notAttendToEvent(event.id, _user!.uid); | ||
} | ||
} | ||
|
||
void notAttendEvent( | ||
String uid, | ||
) { | ||
_eventsRepository.notAttendToEvent(eventId, uid); | ||
@override | ||
void dispose() { | ||
_eventSubscription.cancel(); | ||
super.dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.