diff --git a/assets/images/first-prize-trophy.jpg b/assets/images/first-prize-trophy.jpg new file mode 100644 index 0000000..0efb3b4 Binary files /dev/null and b/assets/images/first-prize-trophy.jpg differ diff --git a/assets/images/second-prize-trophy.jpg b/assets/images/second-prize-trophy.jpg new file mode 100644 index 0000000..44fed0d Binary files /dev/null and b/assets/images/second-prize-trophy.jpg differ diff --git a/assets/images/third-prize-trophy.jpg b/assets/images/third-prize-trophy.jpg new file mode 100644 index 0000000..3a1c4cd Binary files /dev/null and b/assets/images/third-prize-trophy.jpg differ diff --git a/lib/Screens/OmUI/PricesScreen.dart b/lib/Screens/OmUI/PricesScreen.dart new file mode 100644 index 0000000..42ab87f --- /dev/null +++ b/lib/Screens/OmUI/PricesScreen.dart @@ -0,0 +1,155 @@ +import 'package:flutter/material.dart'; +import 'package:gdsc_ui_design/utils/app_styles.dart'; +import 'package:gdsc_ui_design/utils/size_config.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert'; + + +class PrizePage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + body: FutureBuilder>( + future: fetchPrizes(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else if (snapshot.hasData) { + List prizes = snapshot.data!; + return PrizeCardList(prizes: prizes); + } else { + return Text('No data available.'); + } + }, + ), + ); + } +} + +class Prize { + final String title; + final List rewards; + + Prize({required this.title, required this.rewards}); + + factory Prize.fromJson(Map json) { + return Prize( + title: json['title'], + rewards: List.from(json['rewards']), + ); + } +} + +Future> fetchPrizes() async { + final response = await http.get(Uri.parse('https://du-hacks-apis.vercel.app/api/v2/prizes/')); + + if (response.statusCode == 200) { + List data = jsonDecode(response.body)['data']; + + if (data is List) { + List prizes = data.map((json) => Prize.fromJson(json)).toList(); + return prizes; + } else { + throw Exception('API response data is not a list.'); + } + } else { + throw Exception('Failed to fetch prizes'); + } +} + +class PrizeCardList extends StatelessWidget { + final List prizes; + + PrizeCardList({required this.prizes}); + + static const List trophy = [ + 'assets/images/first-prize-trophy.jpg', + 'assets/images/second-prize-trophy.jpg', + 'assets/images/third-prize-trophy.jpg' + ]; + + @override + Widget build(BuildContext context) { + return ListView.builder( + itemCount: prizes.length, + itemBuilder: (context, index) { + return PrizeCard( + title: prizes[index].title, + rewards: prizes[index].rewards, + glowColor: prizes[index].title == "First Prize" + ? Color(0xFFFFD700) + : (prizes[index].title == "Second Prize" ? Color(0xFFC0C0C0) : Color(0xFFCD7F32)), + trophyImage: prizes[index].title == "First Prize" + ? trophy[0] + : (prizes[index].title == "Second Prize" ? trophy[1] : trophy[2]), + ); + }, + ); + } +} + +class PrizeCard extends StatelessWidget { + final String title; + final List rewards; + final Color glowColor; + final String trophyImage; + + PrizeCard({ + required this.title, + required this.rewards, + required this.glowColor, + required this.trophyImage, + }); + + @override + Widget build(BuildContext context) { + return Container( + width: 300, + margin: EdgeInsets.all(kPadding16), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20.0), + boxShadow: [ + BoxShadow( + color: glowColor.withOpacity(0.4), + blurRadius: 10, + spreadRadius: 5, + ), + ], + color: glowColor, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Container( + padding: EdgeInsets.all(16.0), + child: Text( + title, + textAlign: TextAlign.center, + style: kRalewaySemibold.copyWith( + fontSize: SizeConfig.blockSizeHorizontal! * 5, + ), + ), + ), + Image.asset( + trophyImage, + height: 100, + width: 100, + ), + for (String reward in rewards) + Container( + padding: EdgeInsets.all(kPadding8), + child: Text( + reward, + style: kRalewaySemibold.copyWith( + fontSize: SizeConfig.blockSizeHorizontal! * 3.5, + ), + textAlign: TextAlign.center, + ), + ), + ], + ), + ); + } +} diff --git a/lib/Screens/OmUI/main_screen.dart b/lib/Screens/OmUI/main_screen.dart index b1021dc..4fa7546 100644 --- a/lib/Screens/OmUI/main_screen.dart +++ b/lib/Screens/OmUI/main_screen.dart @@ -5,6 +5,7 @@ import 'package:gdsc_ui_design/Screens/OmUI/RegisteredPage.dart'; import 'package:gdsc_ui_design/utils/app_styles.dart'; import 'package:gdsc_ui_design/utils/size_config.dart'; import 'package:hidden_drawer_menu/hidden_drawer_menu.dart'; +import 'package:gdsc_ui_design/Screens/OmUI/PricesScreen.dart'; class MainScreen extends StatefulWidget { const MainScreen({super.key}); @@ -44,6 +45,14 @@ class _MainScreenState extends State { selectedStyle: kRalewayMedium), MembersPage(), ), + ScreenHiddenDrawer( + ItemHiddenMenu( + name: 'Prize Information', + baseStyle: kRalewayMedium, + colorLineSelected: kBlue, + selectedStyle: kRalewayMedium), + PrizePage(), + ), ]; } diff --git a/pubspec.yaml b/pubspec.yaml index 8ee0e02..d77308e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -61,6 +61,9 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - assets/images/ + - assets/images/first-prize-trophy.jpg + - assets/images/second-prize-trophy.jpg + - assets/images/third-prize-trophy.jpg # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg