Skip to content

Commit

Permalink
Database refactor and feature re-implementation (#27)
Browse files Browse the repository at this point in the history
* Firebase service update

* linked to page

* display timespans of all sessions

* display image by url

* enable GPS check-in, fix bugs on calendar page

* add sticker

remove firebase_service.dart

* add stickers to users' collection while checking in

* upload check_in photo

* complete photo upload check-in

* fix bug on profile page

adjust sticker image size

* adjust points earned by users

* remove unused classes

* rename classes

* add savedUsers to Event

---------

Co-authored-by: heyadi <[email protected]>
  • Loading branch information
ToErUs and Tuffy-X authored Nov 6, 2024
1 parent c2252c1 commit 18b5d56
Show file tree
Hide file tree
Showing 28 changed files with 990 additions and 147 deletions.
3 changes: 3 additions & 0 deletions bu_passport/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<application
android:label="bu_passport"
android:name="${applicationName}"
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bu_passport/assets/images/stickers/art.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bu_passport/assets/images/stickers/drama.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bu_passport/assets/images/stickers/frame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bu_passport/assets/images/stickers/free.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bu_passport/assets/images/stickers/live.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bu_passport/assets/images/stickers/music.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions bu_passport/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to provide this feature</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>We need your location to provide this feature</string>

<key>NSCameraUsageDescription</key>
<string>This app requires camera access to allow users to take and upload photos for their profile.</string>
<key>NSPhotoLibraryUsageDescription</key>
Expand Down
55 changes: 51 additions & 4 deletions bu_passport/lib/classes/event.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:bu_passport/classes/session.dart';
import 'package:bu_passport/classes/sticker.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

class Event {
Expand All @@ -7,21 +9,66 @@ class Event {
final String eventLocation;
final String eventDescription;
final String eventURL;
final DateTime eventStartTime;
final DateTime eventEndTime;
final int eventPoints;
final List<String> savedUsers;
final List<Session> eventSessions;
final List<Sticker> eventStickers;

Event({
required this.eventID,
required this.eventTitle,
required this.eventPhoto,
required this.eventLocation,
required this.eventStartTime,
required this.eventEndTime,
required this.eventDescription,
required this.eventPoints,
required this.eventURL,
required this.savedUsers,
required this.eventSessions,
required this.eventStickers,
});

@override
String toString() {
return 'NewEvent\n'
'(ID: $eventID,\n'
' Title: $eventTitle, \n'
'Photo URL: $eventPhoto, \n'
'Location: $eventLocation, \n'
//'Description: $eventDescription, \n'
'Points: $eventPoints, \n'
'Event URL: $eventURL, \n'
'Sessions: [\n${eventSessions.map((session) => ' ${session.toString()}').join(',\n')}\n])';
}

bool hasSessionOnDay(DateTime date) {
return eventSessions.any((session) {
final startOfDay = DateTime(date.year, date.month, date.day);
final endOfDay = startOfDay.add(Duration(days: 1));

return (session.sessionStartTime.isAfter(startOfDay) &&
session.sessionStartTime.isBefore(endOfDay)) ||
(session.sessionEndTime.isAfter(startOfDay) &&
session.sessionEndTime.isBefore(endOfDay));
});
}

bool hasUpcomingSessions(DateTime time) {

// Check if there are any sessions that haven't ended
for (var session in eventSessions) {
if (session.sessionEndTime.isAfter(time)) {
return true; // There's at least one active session
}
}
return false; // No active sessions
}
bool isEventHappening() {
DateTime now = DateTime.now();
for (var session in eventSessions) {
if (session.sessionStartTime.isBefore(now) && session.sessionEndTime.isAfter(now)) {
return true; // Event is happening
}
}
return false; // Event is not happening
}
}
25 changes: 25 additions & 0 deletions bu_passport/lib/classes/session.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:cloud_firestore/cloud_firestore.dart';

class Session {
final String sessionID;
final DateTime sessionStartTime;
final DateTime sessionEndTime;
final List<String> savedUsers;

Session({
required this.sessionID,
required this.sessionStartTime,
required this.sessionEndTime,
required this.savedUsers,

});
@override
String toString() {
return 'Session('
'ID: $sessionID, '
'Start Time: $sessionStartTime, '
'End Time: $sessionEndTime, '
'Saved Users: $savedUsers'
')';
}
}
15 changes: 15 additions & 0 deletions bu_passport/lib/classes/sticker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Sticker {
final String name;

Sticker({
required this.name,
});
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is Sticker && other.name == name;
}

@override
int get hashCode => name.hashCode;
}
4 changes: 4 additions & 0 deletions bu_passport/lib/classes/user.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:bu_passport/classes/sticker.dart';

class Users {
final String firstName;
final String lastName;
Expand All @@ -10,6 +12,7 @@ class Users {
final String userProfileURL;
final Map<String, dynamic> userSavedEvents;
final bool admin;
final Map<Sticker, bool> userStickerCollection;

Users({
required this.firstName,
Expand All @@ -23,5 +26,6 @@ class Users {
required this.userPoints,
required this.userProfileURL,
required this.admin,
required this.userStickerCollection,
});
}
22 changes: 22 additions & 0 deletions bu_passport/lib/components/checkin_options_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class CheckInOptionsDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text("Check-in Options"),
content: Text("Would you like to check in with a photo?"),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: Text("No"),
),
TextButton(
onPressed: () => Navigator.of(context).pop(true),
child: Text("Yes"),
),
],
);
}
}
81 changes: 81 additions & 0 deletions bu_passport/lib/components/checkin_success_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import 'dart:io';
import 'package:bu_passport/components/sticker_painters.dart';
import 'package:flutter/material.dart';
import 'postmark_widget.dart';
import 'dart:ui' as ui;




class SuccessDialog extends StatelessWidget {
final String eventTitle;
final int points;
final ui.Image? image;
final ui.Image? logo;
final ui.Image? frame;
final ui.Image? sticker1;
final ui.Image? sticker2;
static const double STAMP_SIZE=100;
static const double POSTMARK_SIZE=100;

const SuccessDialog({
Key? key,
required this.eventTitle,
required this.points,
this.image, this.frame, this.sticker1, this.sticker2, this.logo,
}) : super(key: key);



@override
Widget build(BuildContext context) {
return Dialog(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
'SUCCESS!',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Color(0xFFCC0000),
fontFamily: 'Inter',
),
textAlign: TextAlign.center,
),
const SizedBox(height: 16),

if (image != null)
CustomPaint(
size: Size(STAMP_SIZE,STAMP_SIZE),
painter: ImagePainter(image,frame,sticker1,sticker2),
),
if(image==null)
CustomPaint(
size: const Size(STAMP_SIZE, STAMP_SIZE),
painter: LogoPainter(logo,sticker1,sticker2),
),
const SizedBox(height: 16),
Text(
eventTitle,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
CustomPaint(
size: Size(POSTMARK_SIZE,POSTMARK_SIZE),
painter: PostmarkPainter(points: points),// points
),
],
),
),
);
}
}
17 changes: 7 additions & 10 deletions bu_passport/lib/components/event_widget.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import 'package:bu_passport/classes/event.dart';
import 'package:bu_passport/components/time_span.dart';
import 'package:bu_passport/pages/event_page.dart';
import 'package:bu_passport/services/firebase_service.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:intl/intl.dart';

import '../services/firebase_service.dart';
import '../services/web_image_service.dart';

class EventWidget extends StatefulWidget {
final Event event;
final Function onUpdateEventPage;
Expand Down Expand Up @@ -97,7 +100,7 @@ class _EventWidgetState extends State<EventWidget> {
borderRadius: BorderRadius.circular(10.0),
border: Border.all(color: Colors.grey),
image: DecorationImage(
image: AssetImage(widget.event.eventPhoto),
image: WebImageService.buildImageProvider(widget.event.eventPhoto),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.3), BlendMode.multiply),
Expand Down Expand Up @@ -139,14 +142,8 @@ class _EventWidgetState extends State<EventWidget> {
),
),
SizedBox(height: sizedBoxHeight * 0.5),
Text(
DateFormat.yMMMd()
.format(widget.event.eventStartTime),
style: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w500,
color: Colors.white,
),
EventDateRangeDisplay(
sessions: widget.event.eventSessions,
),
],
),
Expand Down
Loading

0 comments on commit 18b5d56

Please sign in to comment.