Skip to content

Commit

Permalink
Added Sponsor Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaswanth-Mitta committed Oct 2, 2023
1 parent 572999c commit b9b4b48
Show file tree
Hide file tree
Showing 12 changed files with 369 additions and 18 deletions.
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- For using url Launcher -->
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
Expand Down
5 changes: 5 additions & 0 deletions 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>LSApplicationQueriesSchemes</key>
<array>
<string>sms</string>
<string>tel</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand Down
9 changes: 9 additions & 0 deletions lib/Screens/OmUI/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -53,6 +54,14 @@ class _MainScreenState extends State<MainScreen> {
selectedStyle: kRalewayMedium),
PrizePage(),
),
ScreenHiddenDrawer(
ItemHiddenMenu(
name: 'Sponsors',
baseStyle: kRalewayMedium,
colorLineSelected: kBlue,
selectedStyle: kRalewayMedium),
SponserPage(),
),
];
}

Expand Down
257 changes: 257 additions & 0 deletions lib/Screens/OmUI/sponsors_page.dart
Original file line number Diff line number Diff line change
@@ -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<String> 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<SponserPage> createState() => _SponserPageState();
}

class _SponserPageState extends State<SponserPage> {
Future<List<Sponsor>> 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<Sponsor>((data) => Sponsor(
name: data['name'],
description: data['description'],
logoUrl: data['logoUrl'],
website: data['website'],
rewards: List<String>.from(data['rewards']),
))
.toList();
} else {
throw Exception('Failed to load sponsors: ${response.statusCode}');
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: FutureBuilder<List<Sponsor>>(
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<SponsorCard> createState() => _SponsorCardState();
}

class _SponsorCardState extends State<SponsorCard> {
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<void> _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<void> _launchURL(String url) async {
// final Uri? uri = Uri.tryParse(url);
// print(uri);
// if (!await launchUrl(uri!)) {
// throw Exception('Could not launch $uri');
// }
}
}
4 changes: 4 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ void main() {
debugShowCheckedModeBanner: false,
home: SplaceScreen(),
));




}
4 changes: 4 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#include "generated_plugin_registrant.h"

#include <url_launcher_linux/url_launcher_plugin.h>

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);
}
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_linux
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Loading

0 comments on commit b9b4b48

Please sign in to comment.