Skip to content

Commit

Permalink
Merge pull request #30 from BU-Spark/passport
Browse files Browse the repository at this point in the history
Passport -- in progress
  • Loading branch information
jaimeyfrank authored Dec 3, 2024
2 parents 2dd7c99 + 4360f19 commit 5ca2548
Show file tree
Hide file tree
Showing 18 changed files with 575 additions and 102 deletions.
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();
}
}
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 @@ -60,7 +60,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 @@ -46,7 +46,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
9 changes: 9 additions & 0 deletions bu_passport/lib/pages/navigation_page.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:bu_passport/pages/explore_page.dart';
import 'package:bu_passport/pages/leaderboard_page.dart'; // Uncomment this line
import 'package:bu_passport/pages/calendar_page.dart';
import 'package:bu_passport/pages/passport_page.dart';
import 'package:bu_passport/pages/profile_page.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';

// NavigationPage is a StatelessWidget that constructs the main navigation structure.
class NavigationPage extends StatelessWidget {
Expand Down Expand Up @@ -34,6 +36,7 @@ class _NavigationPageContentState extends State<NavigationPageContent> {
ExplorePage(), // Page for exploring events.
CalendarPage(), // Calendar page.
LeaderboardPage(), // Leaderboard page.
PassportPage(), // User passport page.
ProfilePage(), // User profile page.
];

Expand Down Expand Up @@ -72,6 +75,12 @@ class _NavigationPageContentState extends State<NavigationPageContent> {
label: 'Leaderboard', // Label for the leaderboard page.
),

// Passport icon
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.book_fill),
label: 'Passport', // Label for the passport page.
),

// Profile icon
BottomNavigationBarItem(
icon: Icon(Icons.person),
Expand Down
Loading

0 comments on commit 5ca2548

Please sign in to comment.