Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passport -- in progress #30

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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.
54 changes: 54 additions & 0 deletions bu_passport/lib/classes/passport.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'dart:math';

class Passport {
static const int maxStickersPerPage = 6;
List<List<Sticker>> pages = [[]];

void addSticker(Sticker sticker) {
List<Sticker> currentPage = pages.last;
if (currentPage.length >= maxStickersPerPage) {
currentPage = [];
pages.add(currentPage);
}
currentPage.add(sticker);
}
}

class Sticker {
final int id;
late final String imagePath;

Sticker({required this.id}) {
imagePath = _getImagePathById(id);
}

String _getImagePathById(int id) {
// Map of id to image paths
const Map<int, String> imagePaths = {
0: 'assets/images/passport/empty_sticker.png',
1: 'assets/images/passport/music_sticker.png',
2: 'assets/images/passport/paintbrush_sticker.png',
3: 'assets/images/passport/theater_sticker.png',
// Add more mappings as needed
};

return imagePaths[id] ?? 'assets/images/passport/empty_sticker.png';
}
}

class StickerRepository {
final List<Sticker> allStickers = [
Sticker(id: 1),
Sticker(id: 2),
Sticker(id: 3),
Sticker(id: 4),
];

Sticker getRandomSticker() {
if (allStickers.isEmpty) {
throw Exception('No stickers available');
}
final randomIndex = Random().nextInt(allStickers.length);
return allStickers[randomIndex];
}
}
13 changes: 13 additions & 0 deletions bu_passport/lib/classes/passport_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:bu_passport/classes/passport.dart';

class PassportModel with ChangeNotifier {
Passport passport = Passport();
StickerRepository stickerRepository = StickerRepository();

void addStickerFromCheckIn() {
Sticker newSticker = stickerRepository.getRandomSticker();
passport.addSticker(newSticker);
notifyListeners();
}
}
10 changes: 8 additions & 2 deletions bu_passport/lib/classes/user.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:cloud_firestore/cloud_firestore.dart';

class Users {
final String firstName;
final String lastName;
Expand All @@ -9,7 +11,9 @@ class Users {
final int userPoints;
final String userProfileURL;
final Map<String, dynamic> userSavedEvents;
final bool admin;
final Map<int, bool> userCollectedStickers;
final List<String> userPhotos;
final Timestamp userCreatedAt;

Users({
required this.firstName,
Expand All @@ -22,6 +26,8 @@ class Users {
required this.userSavedEvents,
required this.userPoints,
required this.userProfileURL,
required this.admin,
required this.userCollectedStickers,
required this.userPhotos,
required this.userCreatedAt,
});
}
75 changes: 75 additions & 0 deletions bu_passport/lib/components/passport_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:bu_passport/classes/passport_model.dart';
import 'package:bu_passport/classes/passport.dart';

class PassportBookWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final passportModel = Provider.of<PassportModel>(context);
return Center(
child: Container(
padding: const EdgeInsets.all(8.0),
width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height * 0.5,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0xFFF2EFE7).withOpacity(0.2),
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 3),
),
],
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
// Left Page
Expanded(
child: Container(
decoration: ShapeDecoration(
color: Color(0x59F4E2AF),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(9.21),
side: BorderSide(color: Color.fromARGB(88, 165, 151, 111), width: 2.0),
),
),
child: buildPageContent(passportModel.passport.pages.length > 0 ? passportModel.passport.pages[0] : []),
),
),
// Right Page
Expanded(
child: Container(
decoration: ShapeDecoration(
color: Color(0x59F4E2AF),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(9.21),
side: BorderSide(color: Color.fromARGB(88, 165, 151, 111), width: 2.0),
),
),
child: buildPageContent(passportModel.passport.pages.length > 1 ? passportModel.passport.pages[1] : []),
),
),
],
),
),
);
}

Widget buildPageContent(List<Sticker> stickers) {
return GridView.builder(
padding: EdgeInsets.all(16),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
itemCount: stickers.length,
itemBuilder: (context, index) {
return Image.asset(stickers[index].imagePath, fit: BoxFit.cover);
},
);
}
}
68 changes: 68 additions & 0 deletions bu_passport/lib/components/sticker_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import 'package:bu_passport/classes/passport.dart';

class StickerWidget extends StatelessWidget {
final List<Sticker> stickers;

StickerWidget({required this.stickers});

@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: GridView.builder(
padding: EdgeInsets.all(8),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, // 3x3 grid
crossAxisSpacing: 4,
mainAxisSpacing: 4,
childAspectRatio: 1, // Ensure the grid cells are square
),
itemCount: 9, // Always show 9 items
itemBuilder: (context, index) {
if (index < stickers.length) {
return Draggable<Sticker>(
data: stickers[index],
feedback: Container(
width: 60,
height: 60,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(stickers[index].imagePath),
fit: BoxFit.cover,
),
border: Border.all(color: Colors.transparent, width: 0),
),
),
childWhenDragging: Container(
width: 60,
height: 60,
color: Colors.white,
),
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(stickers[index].imagePath),
fit: BoxFit.cover,
),
border: Border.all(color: Colors.transparent, width: 0),
),
),
);
} else {
return Container(
margin: EdgeInsets.all(16),
decoration: BoxDecoration(
image: const DecorationImage(
image: AssetImage('assets/images/passport/empty_sticker.png'),
fit: BoxFit.cover,
),
border: Border.all(color: Colors.transparent, width: 0), // Remove grid lines
),
);
}
},
)
);
}
}
67 changes: 49 additions & 18 deletions bu_passport/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import 'package:bu_passport/pages/login_page.dart';
import 'package:bu_passport/pages/profile_page.dart';
import 'package:bu_passport/pages/signup_page.dart';
import 'package:bu_passport/pages/onboarding_page.dart';
import 'package:bu_passport/pages/passport_page.dart';
import 'package:bu_passport/classes/passport_model.dart';

import 'package:timezone/timezone.dart' as tz;
import 'package:timezone/data/latest.dart' as tz;

import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'auth/auth_gate.dart';
import 'package:provider/provider.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -29,28 +32,56 @@ void main() async {

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,

// Define the default brightness and colors.
colorScheme: ColorScheme.fromSeed(
seedColor: Color(0xFFCC0000),
brightness: Brightness.light,
return ChangeNotifierProvider(
create: (_) => PassportModel(),
child: MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: Color(0xFFCC0000),
brightness: Brightness.light,
),
),
home: const AuthGate(),
routes: {
'/onboarding': (context) => const OnboardingPage(),
'/login': (context) => const LoginPage(),
'/signup': (context) => const SignUpPage(),
'/home': (context) => const AuthGate(),
'/explore_page': (context) => const ExplorePage(),
'/passport_page': (context) => const PassportPage(),
'/profile_page': (context) => const ProfilePage(),
},
),
home: const AuthGate(),
routes: {
'/onboarding': (context) => const OnboardingPage(),
'/login': (context) => const LoginPage(),
'/signup': (context) => const SignUpPage(),
'/home': (context) => const AuthGate(),
'/explore_page': (context) => const ExplorePage(),
'/profile_page': (context) => const ProfilePage(),
},
);
}
}
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// debugShowCheckedModeBanner: false,
// theme: ThemeData(
// useMaterial3: true,

// // Define the default brightness and colors.
// colorScheme: ColorScheme.fromSeed(
// seedColor: Color(0xFFCC0000),
// brightness: Brightness.light,
// ),
// ),
// home: const AuthGate(),
// routes: {
// '/onboarding': (context) => const OnboardingPage(),
// '/login': (context) => const LoginPage(),
// '/signup': (context) => const SignUpPage(),
// '/home': (context) => const AuthGate(),
// '/explore_page': (context) => const ExplorePage(),
// '/profile_page': (context) => const ProfilePage(),
// },
// );
// }
// }
11 changes: 10 additions & 1 deletion bu_passport/lib/pages/calendar_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ class _CalendarPageState extends State<CalendarPage> {

return Scaffold(
appBar: AppBar(
title: Text('Calendar'),
title: const Text('Calendar',
style: TextStyle(
color: Colors.black,
fontSize: 30,
fontFamily: 'Inter',
fontWeight: FontWeight.w500,
height: 0.5,
letterSpacing: -0.33,
)
),
),
body: FutureBuilder<List<Event>>(
future: _allEventsFuture,
Expand Down
11 changes: 10 additions & 1 deletion bu_passport/lib/pages/explore_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ class _HomePageState extends State<ExplorePage> {

return Scaffold(
appBar: AppBar(
title: Text('Events'),
title: const Text('Events',
style: TextStyle(
color: Colors.black,
fontSize: 30,
fontFamily: 'Inter',
fontWeight: FontWeight.w500,
height: 0.5,
letterSpacing: -0.33,
)
),
),
body: Center(
child: ListView(
Expand Down
11 changes: 10 additions & 1 deletion bu_passport/lib/pages/leaderboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,16 @@ class LeaderboardPageState extends State<LeaderboardPage> {

return Scaffold(
appBar: AppBar(
title: Text("Leaderboard"),
title: const Text("Leaderboard",
style: TextStyle(
color: Colors.black,
fontSize: 30,
fontFamily: 'Inter',
fontWeight: FontWeight.w500,
height: 0.5,
letterSpacing: -0.33,
)
),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
Loading