From b9b4b48168ad4b69704761c0126e63cde53088d5 Mon Sep 17 00:00:00 2001 From: Yaswanth Mitta Date: Mon, 2 Oct 2023 22:59:57 +0530 Subject: [PATCH] Added Sponsor Screen --- android/app/src/main/AndroidManifest.xml | 7 + ios/Runner/Info.plist | 5 + lib/Screens/OmUI/main_screen.dart | 9 + lib/Screens/OmUI/sponsors_page.dart | 257 ++++++++++++++++++ lib/main.dart | 4 + linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 75 ++++- pubspec.yaml | 19 +- .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 12 files changed, 369 insertions(+), 18 deletions(-) create mode 100644 lib/Screens/OmUI/sponsors_page.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 0152341..2605b86 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -24,6 +24,13 @@ + + + + + + + + LSApplicationQueriesSchemes + + sms + tel + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName diff --git a/lib/Screens/OmUI/main_screen.dart b/lib/Screens/OmUI/main_screen.dart index 4fa7546..8ee9634 100644 --- a/lib/Screens/OmUI/main_screen.dart +++ b/lib/Screens/OmUI/main_screen.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:gdsc_ui_design/Screens/OmUI/HomePage.dart'; import 'package:gdsc_ui_design/Screens/OmUI/MembersPage.dart'; import 'package:gdsc_ui_design/Screens/OmUI/RegisteredPage.dart'; +import 'package:gdsc_ui_design/Screens/OmUI/sponsors_page.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'; @@ -53,6 +54,14 @@ class _MainScreenState extends State { selectedStyle: kRalewayMedium), PrizePage(), ), + ScreenHiddenDrawer( + ItemHiddenMenu( + name: 'Sponsors', + baseStyle: kRalewayMedium, + colorLineSelected: kBlue, + selectedStyle: kRalewayMedium), + SponserPage(), + ), ]; } diff --git a/lib/Screens/OmUI/sponsors_page.dart b/lib/Screens/OmUI/sponsors_page.dart new file mode 100644 index 0000000..7c56274 --- /dev/null +++ b/lib/Screens/OmUI/sponsors_page.dart @@ -0,0 +1,257 @@ +import 'package:flutter/material.dart'; +import 'package:gdsc_ui_design/utils/app_styles.dart'; +// import 'package:url_launcher/url_launcher.dart'; + +import 'package:http/http.dart' as http; +import 'dart:convert'; + +import '../../utils/size_config.dart'; + +class Sponsor { + final String name; + final String description; + final String logoUrl; + final String website; + final List rewards; + + Sponsor({ + required this.name, + required this.description, + required this.logoUrl, + required this.website, + required this.rewards, + }); +} + +class SponserPage extends StatefulWidget { + const SponserPage({super.key}); + + @override + State createState() => _SponserPageState(); +} + +class _SponserPageState extends State { + Future> fetchData() async { + final response = await http.get( + Uri.parse('https://du-hacks-apis.vercel.app/api/v2/sponsors'), + ); + + if (response.statusCode == 200) { + final jsonData = json.decode(response.body); + final dataList = jsonData['data']; + + return dataList + .map((data) => Sponsor( + name: data['name'], + description: data['description'], + logoUrl: data['logoUrl'], + website: data['website'], + rewards: List.from(data['rewards']), + )) + .toList(); + } else { + throw Exception('Failed to load sponsors: ${response.statusCode}'); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: FutureBuilder>( + future: fetchData(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center( + child: CircularProgressIndicator(), // Show a loading indicator + ); + } else if (snapshot.hasError) { + return Center( + child: Text('Error: ${snapshot.error}'), + ); + } else { + final sponsors = snapshot.data; + + return ListView.builder( + itemCount: sponsors!.length, + itemBuilder: (context, index) { + final sponsor = sponsors[index]; + + return SponsorCard(sponsor: sponsor); + }, + ); + } + }, + ), + ); + } +} + +class SponsorCard extends StatefulWidget { + const SponsorCard({super.key, required this.sponsor}); + final Sponsor sponsor; + + @override + State createState() => _SponsorCardState(); +} + +class _SponsorCardState extends State { + bool isExpanded = false; + + @override + Widget build(BuildContext context) { + return Card( + elevation: 5, + margin: const EdgeInsets.all(16.0), + child: ClipRRect( + borderRadius: BorderRadius.circular(10.0), + child: InkWell( + onTap: () { + setState(() { + isExpanded = !isExpanded; + }); + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + // color: Color.fromARGB(255, 138, 167, 243), + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: + Alignment.topCenter, // Align the gradient from the top + end: Alignment.bottomCenter, // To the bottom + colors: [ + Color.fromARGB(255, 254, 254, 255), + Color.fromARGB(255, 94, 139, 252), + ], // Add your two desired colors + ), + ), + padding: const EdgeInsets.all(16.0), + child: Row( + children: [ + const CircleAvatar( + backgroundImage: NetworkImage( + // widget.sponsor.logoUrl + "https://altcoinsbox.com/wp-content/uploads/2023/03/matic-logo-350x350.webp", + ), + radius: 50, // Increased image size + ), + const SizedBox(width: 16.0), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.sponsor.name, + style: kRalewaySemibold.copyWith( + fontSize: SizeConfig.blockSizeHorizontal! * 7, + ), + ), + const SizedBox(height: 8.0), + Text( + widget.sponsor.description, + style: kRalewaySemibold.copyWith( + fontSize: SizeConfig.blockSizeHorizontal! * 4, + ), + ), + ], + ), + ), + ], + ), + ), + AnimatedContainer( + duration: const Duration(milliseconds: 500), + height: isExpanded ? null : 0, + child: isExpanded + ? Container( + width: double.infinity, + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment + .topCenter, // Align the gradient from the top + end: Alignment.bottomCenter, // To the bottom + colors: [ + Color.fromARGB(255, 99, 142, 250), + Color.fromARGB(255, 94, 138, 248), + Color.fromARGB(255, 94, 138, 248), + Color.fromARGB(255, 89, 135, 251), + Color.fromARGB(255, 55, 111, 253), + ], + ), + ), + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'Rewards:', + style: TextStyle( + fontSize: 22, // Increased font size + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: widget.sponsor.rewards + .map((reward) => Text( + reward, + textAlign: TextAlign.left, + style: kRalewaySemibold.copyWith( + fontSize: + SizeConfig.blockSizeHorizontal! * + 4.5, + ), + )) + .toList(), + ), + const SizedBox(height: 20), + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: + const Color.fromARGB(255, 7, 47, 125)), + onPressed: () { + print(widget.sponsor.website); + _launchURL(widget.sponsor.website); + }, + // onPressed: _launchURL(widget.sponsor.website), + child: Text( + 'Visit Website', + style: kRalewaySemibold.copyWith( + fontSize: + SizeConfig.blockSizeHorizontal! * 3.5, + ), + ), + ), + ], + ), + ) + : null, + ), + ], + ), + ), + ), + ); + } + + // Future _launchURL(String url) async { + // print(url); + // // ADD Launcher Code Here + // if (await canLaunchUrl(uri!)) { + // await launchUrl(Uri.parse(url)); + // } else { + // throw 'Could not launch $url'; + // } + + // } + Future _launchURL(String url) async { + // final Uri? uri = Uri.tryParse(url); + // print(uri); + // if (!await launchUrl(uri!)) { + // throw Exception('Could not launch $uri'); + // } + } +} diff --git a/lib/main.dart b/lib/main.dart index ef48d72..da952a3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,4 +18,8 @@ void main() { debugShowCheckedModeBanner: false, home: SplaceScreen(), )); + + + + } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index e71a16d..f6f23bf 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 2e1de87..f16b4c3 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index e777c67..a1cdfd0 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,7 +6,9 @@ import FlutterMacOS import Foundation import path_provider_foundation +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 2ec4ad9..28f4ab7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -91,6 +91,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" google_fonts: dependency: "direct main" description: @@ -108,7 +113,7 @@ packages: source: hosted version: "3.0.1" http: - dependency: transitive + dependency: "direct main" description: name: http sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" @@ -288,6 +293,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27" + url: "https://pub.dev" + source: hosted + version: "6.1.14" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: b04af59516ab45762b2ca6da40fa830d72d0f6045cd97744450b73493fa76330 + url: "https://pub.dev" + source: hosted + version: "6.1.0" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "7c65021d5dee51813d652357bc65b8dd4a6177082a9966bc8ba6ee477baa795f" + url: "https://pub.dev" + source: hosted + version: "6.1.5" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: b651aad005e0cb06a01dbd84b428a301916dc75f0e7ea6165f80057fee2d8e8e + url: "https://pub.dev" + source: hosted + version: "3.0.6" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: b55486791f666e62e0e8ff825e58a023fd6b1f71c49926483f1128d3bbd8fe88 + url: "https://pub.dev" + source: hosted + version: "3.0.7" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "95465b39f83bfe95fcb9d174829d6476216f2d548b79c38ab2506e0458787618" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "2942294a500b4fa0b918685aff406773ba0a4cd34b7f42198742a94083020ce5" + url: "https://pub.dev" + source: hosted + version: "2.0.20" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "95fef3129dc7cfaba2bc3d5ba2e16063bb561fc6d78e63eee16162bc70029069" + url: "https://pub.dev" + source: hosted + version: "3.0.8" vector_math: dependency: transitive description: @@ -321,5 +390,5 @@ packages: source: hosted version: "1.0.3" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=3.7.0" + dart: ">=3.1.0 <4.0.0" + flutter: ">=3.13.0" diff --git a/pubspec.yaml b/pubspec.yaml index d77308e..79decd1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,29 +28,21 @@ environment: # the latest version available on pub.dev. To see which dependencies have newer # versions available, run `flutter pub outdated`. dependencies: + cupertino_icons: ^1.0.2 flutter: sdk: flutter - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 google_fonts: ^5.1.0 hidden_drawer_menu: ^3.0.1 + http: ^1.1.0 + url_launcher: ^6.1.14 dev_dependencies: + flutter_lints: ^2.0.0 flutter_test: sdk: flutter - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. - flutter_lints: ^2.0.0 - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec - # The following section is specific to Flutter packages. flutter: # The following line ensures that the Material Icons font is @@ -66,13 +58,10 @@ flutter: - assets/images/third-prize-trophy.jpg # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg - # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware - # For details regarding adding assets from package dependencies, see # https://flutter.dev/assets-and-images/#from-packages - # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a # "family" key with the font family name, and a "fonts" key with a diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..4f78848 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..88b22e5 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST