From 4f17ed7ecfba6e9cf163be27ae17b4b06608bebd Mon Sep 17 00:00:00 2001 From: rishabh7923 Date: Thu, 31 Oct 2024 20:03:09 +0530 Subject: [PATCH 1/3] Fixed Open summer of code Grid View Height Issue --- lib/programs screen/open_summer_of_code.dart | 248 ++++++++----------- 1 file changed, 98 insertions(+), 150 deletions(-) diff --git a/lib/programs screen/open_summer_of_code.dart b/lib/programs screen/open_summer_of_code.dart index 0d55830..92b1322 100644 --- a/lib/programs screen/open_summer_of_code.dart +++ b/lib/programs screen/open_summer_of_code.dart @@ -2,13 +2,11 @@ import 'dart:convert'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:opso/modals/osoc_modal.dart'; import 'package:opso/widgets/osoc_widget.dart'; import 'package:opso/widgets/year_button.dart'; import 'package:opso/programs_info_pages/osoc_info.dart'; import '../modals/book_mark_model.dart'; -import '../widgets/SearchandFilterWidget.dart'; class OpenSummerOfCode extends StatefulWidget { const OpenSummerOfCode({super.key}); @@ -124,60 +122,57 @@ class _OpenSummerOfCodeState extends State { return RefreshIndicator( onRefresh: _refresh, child: Scaffold( - appBar: - AppBar( - leading: IconButton( - icon: const Icon(Icons.arrow_back_ios), - - onPressed: () => Navigator.of(context).pop(), - ), - centerTitle: true, - title: const Text('Open Summer of Code'), actions: [ - IconButton( - icon: (isBookmarked) - ? const Icon(Icons.bookmark_add_rounded) - : const Icon(Icons.bookmark_add_outlined), - onPressed: () { - setState(() { - isBookmarked = !isBookmarked; - }); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - isBookmarked ? 'Bookmark added' : 'Bookmark removed'), - duration: const Duration( - seconds: 2), // Adjust the duration as needed - ), - ); - if (isBookmarked) { - print("Adding"); - HandleBookmark.addBookmark(currentProject, currectPage); - } else { - print("Deleting"); - HandleBookmark.deleteBookmark(currentProject); - } - }, - ), - IconButton( - icon: const Icon(Icons.info_outline), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => const OSOCInfo()), - ); - }, - ), - ]), + appBar: AppBar( + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios), + onPressed: () => Navigator.of(context).pop(), + ), + centerTitle: true, + title: const Text('Open Summer of Code'), + actions: [ + IconButton( + icon: (isBookmarked) + ? const Icon(Icons.bookmark_add_rounded) + : const Icon(Icons.bookmark_add_outlined), + onPressed: () { + setState(() { + isBookmarked = !isBookmarked; + }); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + isBookmarked ? 'Bookmark added' : 'Bookmark removed'), + duration: const Duration( + seconds: 2), // Adjust the duration as needed + ), + ); + if (isBookmarked) { + print("Adding"); + HandleBookmark.addBookmark(currentProject, currectPage); + } else { + print("Deleting"); + HandleBookmark.deleteBookmark(currentProject); + } + }, + ), + IconButton( + icon: const Icon(Icons.info_outline), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const OSOCInfo()), + ); + }, + ), + ]), body: FutureBuilder( future: getProjectFunction, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); } else if (snapshot.connectionState == ConnectionState.done) { - return Padding( - padding: EdgeInsets.symmetric( - horizontal: ScreenUtil().setWidth(46), - vertical: ScreenUtil().setHeight(16)), + return SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 46, vertical: 6), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -224,107 +219,60 @@ class _OpenSummerOfCodeState extends State { }, ), SizedBox(height: ScreenUtil().setHeight(20)), - SizedBox( - height: height * 0.1, - width: width, - child: GridView( - physics: const NeverScrollableScrollPhysics(), - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - childAspectRatio: 1.5 / 0.6, - crossAxisSpacing: 15, - mainAxisSpacing: 15, - ), - children: [ - YearButton( - year: "2021", - isEnabled: selectedYear == 2021 ? true : false, - onTap: () { - setState(() { - projectList = osoc2021; - selectedYear = 2021; - }); - }, - backgroundColor: selectedYear == 2021 - ? Colors.white - : const Color.fromRGBO(255, 183, 77, 1), - ), - YearButton( - year: "2022", - isEnabled: selectedYear == 2022 ? true : false, - onTap: () { - setState(() { - projectList = osoc2022; - selectedYear = 2022; - }); - }, - backgroundColor: selectedYear == 2022 - ? Colors.white - : const Color.fromRGBO(255, 183, 77, 1), - ), - ], - ), - ), - - // Row( - // crossAxisAlignment: CrossAxisAlignment.center, - // mainAxisAlignment: MainAxisAlignment.spaceEvenly, - // children: [ - // const Text( - // 'Filter by Org:', - // style: TextStyle(fontWeight: FontWeight.w400), - // ), - // Padding( - // padding: EdgeInsets.all(ScreenUtil().setHeight(8)), - // child: Row( - // crossAxisAlignment: CrossAxisAlignment.center, - // mainAxisAlignment: MainAxisAlignment.spaceEvenly, - // children: [ - // DropdownWidget( - // items: languages, - // hintText: 'Org', - // onChanged: (newValue) { - // setState(() { - // switch (selectedYear) { - // case 2021: - // projectList = sob2021; - // break; - // case 2022: - // projectList = sob2022; - // break; - // case 2023: - // projectList = sob2023; - // break; - // } - // searchTag(newValue); - // }); - // // Perform filtering based on selectedLanguage - // }, - // ), - // ], - // ), - // ) - // ], - // ), - // SizedBox( - // height: ScreenUtil().setHeight(20), - // ), - Expanded( - // width: width, - child: ListView.builder( - itemCount: projectList.length, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: OsocWidget( - modal: projectList[index], - height: ScreenUtil().screenHeight * 0.2, - width: ScreenUtil().screenWidth, + LayoutBuilder( + builder: (context, constraints) { + return Wrap( + spacing: 15, + runSpacing: 15, + alignment: WrapAlignment.spaceBetween, + children: [ + YearButton( + year: "2021", + isEnabled: selectedYear == 2021 ? true : false, + onTap: () { + setState(() { + projectList = osoc2021; + selectedYear = 2021; + }); + }, + backgroundColor: selectedYear == 2021 + ? Colors.white + : const Color.fromRGBO(255, 183, 77, 1), + ), - ); - }, - ), + YearButton( + year: "2022", + isEnabled: selectedYear == 2022 ? true : false, + onTap: () { + setState(() { + projectList = osoc2022; + selectedYear = 2022; + }); + }, + backgroundColor: selectedYear == 2022 + ? Colors.white + : const Color.fromRGBO(255, 183, 77, 1), + + ), + ], + ); + }, + ), + SizedBox(height: ScreenUtil().setHeight(20)), + ListView.builder( + itemCount: projectList.length, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: OsocWidget( + modal: projectList[index], + height: ScreenUtil().screenHeight * 0.2, + width: ScreenUtil().screenWidth, + ), + ); + }, ), ], ), From ebbe14cbb8e87f9fe2af260685f84038bb75c7ed Mon Sep 17 00:00:00 2001 From: rishabh7923 Date: Fri, 1 Nov 2024 17:46:40 +0530 Subject: [PATCH 2/3] Added Projects Section For Certain Org --- .../google_summer_of_code_screen.dart | 16 +- lib/widgets/gsoc/GsocProjectWidget.dart | 225 +++++++++++++----- 2 files changed, 174 insertions(+), 67 deletions(-) diff --git a/lib/programs screen/google_summer_of_code_screen.dart b/lib/programs screen/google_summer_of_code_screen.dart index f08d6aa..bd0a7a7 100644 --- a/lib/programs screen/google_summer_of_code_screen.dart +++ b/lib/programs screen/google_summer_of_code_screen.dart @@ -339,11 +339,16 @@ class _GoogleSummerOfCodeScreenState extends State { ), ], ), - child: GsocProjectWidget( - index: index + 1, - modal: orgList[index], - height: height * 0.2, - width: width, + child: Column( + children: [ + GsocProjectWidget( + index: index + 1, + modal: orgList[index], + height: height * 0.2, + width: width, + ), + + ], ), ), ); @@ -360,6 +365,7 @@ class _GoogleSummerOfCodeScreenState extends State { ); } + Widget _buildMultiSelectField({ required List items, required List selectedValues, diff --git a/lib/widgets/gsoc/GsocProjectWidget.dart b/lib/widgets/gsoc/GsocProjectWidget.dart index 8345941..905ebf9 100644 --- a/lib/widgets/gsoc/GsocProjectWidget.dart +++ b/lib/widgets/gsoc/GsocProjectWidget.dart @@ -20,6 +20,7 @@ class GsocProjectWidget extends StatelessWidget { throw 'Could not launch $url'; } } + @override Widget build(BuildContext context) { final isDarkMode = Theme.of(context).brightness == Brightness.dark; @@ -54,70 +55,37 @@ class GsocProjectWidget extends StatelessWidget { fontWeight: FontWeight.bold, ), ), - Padding( - padding: const EdgeInsets.only(top: 10.0), - child: Text( - "By ${modal.description}", - style: TextStyle( - color: textColor, - ), + Text( + modal.description, + style: TextStyle( + color: textColor, ), ), - Padding( - padding: const EdgeInsets.only(top: 20.0), - child: Wrap( - spacing: 10, - runSpacing: 10, - children: [ - if (modal.contactEmail.isNotEmpty) - ElevatedButton.icon( - onPressed: () { - _launchUrl('mailto:${modal.contactEmail}'); - }, - icon: Icon(Icons.email, color: Colors.white), - label: Text("Email"), - style: ElevatedButton.styleFrom( - foregroundColor: Colors.white, backgroundColor: Colors.orange, - ), - ), - if (modal.blogUrl.isNotEmpty) - ElevatedButton.icon( - onPressed: () { - _launchUrl(modal.blogUrl); - }, - icon: Icon(Icons.web, color: Colors.white), - label: Text("Blog"), - style: ElevatedButton.styleFrom( - foregroundColor: Colors.white, backgroundColor: Colors.orange, - ), - ), - ], - ), + SizedBox( + height: 10, ), - Padding( - padding: const EdgeInsets.only(top: 20.0), - child: Wrap( - alignment: WrapAlignment.start, - runSpacing: 10, - children: List.generate( - modal.technologies.length, - (index) => Container( - margin: const EdgeInsets.only(right: 10), - decoration: BoxDecoration( - color: const Color.fromARGB(255, 249, 241, 226), - borderRadius: BorderRadius.circular(20), - ), - child: IntrinsicWidth( - stepWidth: 30, - child: Padding( - padding: const EdgeInsets.all(10.0), - child: Center( - child: Text( - modal.technologies[index], - style: TextStyle( - color: Colors.orange, - fontWeight: FontWeight.bold, - ), + Wrap( + alignment: WrapAlignment.start, + runSpacing: 10, + children: List.generate( + modal.technologies.length, + (index) => Container( + margin: const EdgeInsets.only(right: 5), + decoration: BoxDecoration( + color: const Color.fromARGB(255, 249, 241, 226), + borderRadius: BorderRadius.circular(20), + ), + child: IntrinsicWidth( + stepWidth: 30, + child: Padding( + padding: const EdgeInsets.all(5.0), + child: Center( + child: Text( + modal.technologies[index], + style: TextStyle( + color: Colors.orange, + fontSize: 10, + fontWeight: FontWeight.w500, ), ), ), @@ -126,10 +94,143 @@ class GsocProjectWidget extends StatelessWidget { ), ), ), + SizedBox( + height: 10, + ), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () { + showModalBottomSheet( + backgroundColor: Colors.white, + showDragHandle: true, + context: context, + isScrollControlled: true, + useSafeArea: true, + builder: (BuildContext context) { + return SingleChildScrollView( + child: Padding( + padding: + const EdgeInsets.fromLTRB(16, 16, 16, 16), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.all(20), + color: Colors.grey[100], + child: Center( + child: Image.network( + modal.imageUrl, + width: 80, + height: 80, + ), + ), + ), + SizedBox( + height: 10, + ), + Text(modal.description), + Divider( + thickness: 2, + color: Colors.grey[200], + ), + ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: modal.projects.length, + itemBuilder: (context, projectIndex) { + return _buildProjectCard( + modal.projects[projectIndex]); + }, + ) + ]), + ), + ); + }, + ); + }, + style: ButtonStyle( + backgroundColor: + WidgetStateProperty.all(Colors.orange), + foregroundColor: + WidgetStateProperty.all(Colors.white)), + child: Text('View Projects'))) ], ), ), ), ); } -} \ No newline at end of file + + Widget _buildProjectCard(Project project) { + return Card( + color: Colors.grey[100], + elevation: 0, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + project.title, + style: TextStyle(fontWeight: FontWeight.w600), + ), + SizedBox( + height: 10, + ), + Text(project.shortDescription, + style: TextStyle(color: Colors.grey[700])), + SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: ElevatedButton( + onPressed: () async { + await _launchUrl(project.projectUrl); + }, + style: ButtonStyle( + backgroundColor: WidgetStateProperty.all(Colors.orange), + foregroundColor: WidgetStateProperty.all(Colors.white), + shape: WidgetStateProperty.all(RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8))), + padding: WidgetStateProperty.all( + EdgeInsets.symmetric(vertical: 8, horizontal: 16)), + ), + child: Text('View Project Details'), + ), + ), + SizedBox(width: 8), + SizedBox( + width: 100, // Reduced width of the button + child: OutlinedButton( + onPressed: () async { + await _launchUrl(project.codeUrl); + }, + style: ButtonStyle( + side: WidgetStateProperty.all( + BorderSide( + color: Colors.orange, + width: 1), // Outline color and width + ), + foregroundColor: WidgetStateProperty.all(Colors.orange), + shape: WidgetStateProperty.all(RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8))), + padding: WidgetStateProperty.all( + EdgeInsets.symmetric(vertical: 8, horizontal: 8)), + ), + child: Text('View Code'), + ), + ), + ], + ), + ], + ), + ), + ); + } +} From 2715f29f49da9e8ee6027ab8a00e618633da4eb6 Mon Sep 17 00:00:00 2001 From: rishabh7923 Date: Fri, 1 Nov 2024 18:26:19 +0530 Subject: [PATCH 3/3] Revert "Added Projects Section For Certain Org" This reverts commit ebbe14cbb8e87f9fe2af260685f84038bb75c7ed. --- .../google_summer_of_code_screen.dart | 16 +- lib/widgets/gsoc/GsocProjectWidget.dart | 225 +++++------------- 2 files changed, 67 insertions(+), 174 deletions(-) diff --git a/lib/programs screen/google_summer_of_code_screen.dart b/lib/programs screen/google_summer_of_code_screen.dart index bd0a7a7..f08d6aa 100644 --- a/lib/programs screen/google_summer_of_code_screen.dart +++ b/lib/programs screen/google_summer_of_code_screen.dart @@ -339,16 +339,11 @@ class _GoogleSummerOfCodeScreenState extends State { ), ], ), - child: Column( - children: [ - GsocProjectWidget( - index: index + 1, - modal: orgList[index], - height: height * 0.2, - width: width, - ), - - ], + child: GsocProjectWidget( + index: index + 1, + modal: orgList[index], + height: height * 0.2, + width: width, ), ), ); @@ -365,7 +360,6 @@ class _GoogleSummerOfCodeScreenState extends State { ); } - Widget _buildMultiSelectField({ required List items, required List selectedValues, diff --git a/lib/widgets/gsoc/GsocProjectWidget.dart b/lib/widgets/gsoc/GsocProjectWidget.dart index 905ebf9..8345941 100644 --- a/lib/widgets/gsoc/GsocProjectWidget.dart +++ b/lib/widgets/gsoc/GsocProjectWidget.dart @@ -20,7 +20,6 @@ class GsocProjectWidget extends StatelessWidget { throw 'Could not launch $url'; } } - @override Widget build(BuildContext context) { final isDarkMode = Theme.of(context).brightness == Brightness.dark; @@ -55,37 +54,70 @@ class GsocProjectWidget extends StatelessWidget { fontWeight: FontWeight.bold, ), ), - Text( - modal.description, - style: TextStyle( - color: textColor, + Padding( + padding: const EdgeInsets.only(top: 10.0), + child: Text( + "By ${modal.description}", + style: TextStyle( + color: textColor, + ), ), ), - SizedBox( - height: 10, + Padding( + padding: const EdgeInsets.only(top: 20.0), + child: Wrap( + spacing: 10, + runSpacing: 10, + children: [ + if (modal.contactEmail.isNotEmpty) + ElevatedButton.icon( + onPressed: () { + _launchUrl('mailto:${modal.contactEmail}'); + }, + icon: Icon(Icons.email, color: Colors.white), + label: Text("Email"), + style: ElevatedButton.styleFrom( + foregroundColor: Colors.white, backgroundColor: Colors.orange, + ), + ), + if (modal.blogUrl.isNotEmpty) + ElevatedButton.icon( + onPressed: () { + _launchUrl(modal.blogUrl); + }, + icon: Icon(Icons.web, color: Colors.white), + label: Text("Blog"), + style: ElevatedButton.styleFrom( + foregroundColor: Colors.white, backgroundColor: Colors.orange, + ), + ), + ], + ), ), - Wrap( - alignment: WrapAlignment.start, - runSpacing: 10, - children: List.generate( - modal.technologies.length, - (index) => Container( - margin: const EdgeInsets.only(right: 5), - decoration: BoxDecoration( - color: const Color.fromARGB(255, 249, 241, 226), - borderRadius: BorderRadius.circular(20), - ), - child: IntrinsicWidth( - stepWidth: 30, - child: Padding( - padding: const EdgeInsets.all(5.0), - child: Center( - child: Text( - modal.technologies[index], - style: TextStyle( - color: Colors.orange, - fontSize: 10, - fontWeight: FontWeight.w500, + Padding( + padding: const EdgeInsets.only(top: 20.0), + child: Wrap( + alignment: WrapAlignment.start, + runSpacing: 10, + children: List.generate( + modal.technologies.length, + (index) => Container( + margin: const EdgeInsets.only(right: 10), + decoration: BoxDecoration( + color: const Color.fromARGB(255, 249, 241, 226), + borderRadius: BorderRadius.circular(20), + ), + child: IntrinsicWidth( + stepWidth: 30, + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Center( + child: Text( + modal.technologies[index], + style: TextStyle( + color: Colors.orange, + fontWeight: FontWeight.bold, + ), ), ), ), @@ -94,143 +126,10 @@ class GsocProjectWidget extends StatelessWidget { ), ), ), - SizedBox( - height: 10, - ), - SizedBox( - width: double.infinity, - child: ElevatedButton( - onPressed: () { - showModalBottomSheet( - backgroundColor: Colors.white, - showDragHandle: true, - context: context, - isScrollControlled: true, - useSafeArea: true, - builder: (BuildContext context) { - return SingleChildScrollView( - child: Padding( - padding: - const EdgeInsets.fromLTRB(16, 16, 16, 16), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.all(20), - color: Colors.grey[100], - child: Center( - child: Image.network( - modal.imageUrl, - width: 80, - height: 80, - ), - ), - ), - SizedBox( - height: 10, - ), - Text(modal.description), - Divider( - thickness: 2, - color: Colors.grey[200], - ), - ListView.builder( - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: modal.projects.length, - itemBuilder: (context, projectIndex) { - return _buildProjectCard( - modal.projects[projectIndex]); - }, - ) - ]), - ), - ); - }, - ); - }, - style: ButtonStyle( - backgroundColor: - WidgetStateProperty.all(Colors.orange), - foregroundColor: - WidgetStateProperty.all(Colors.white)), - child: Text('View Projects'))) ], ), ), ), ); } - - Widget _buildProjectCard(Project project) { - return Card( - color: Colors.grey[100], - elevation: 0, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - project.title, - style: TextStyle(fontWeight: FontWeight.w600), - ), - SizedBox( - height: 10, - ), - Text(project.shortDescription, - style: TextStyle(color: Colors.grey[700])), - SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: ElevatedButton( - onPressed: () async { - await _launchUrl(project.projectUrl); - }, - style: ButtonStyle( - backgroundColor: WidgetStateProperty.all(Colors.orange), - foregroundColor: WidgetStateProperty.all(Colors.white), - shape: WidgetStateProperty.all(RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8))), - padding: WidgetStateProperty.all( - EdgeInsets.symmetric(vertical: 8, horizontal: 16)), - ), - child: Text('View Project Details'), - ), - ), - SizedBox(width: 8), - SizedBox( - width: 100, // Reduced width of the button - child: OutlinedButton( - onPressed: () async { - await _launchUrl(project.codeUrl); - }, - style: ButtonStyle( - side: WidgetStateProperty.all( - BorderSide( - color: Colors.orange, - width: 1), // Outline color and width - ), - foregroundColor: WidgetStateProperty.all(Colors.orange), - shape: WidgetStateProperty.all(RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8))), - padding: WidgetStateProperty.all( - EdgeInsets.symmetric(vertical: 8, horizontal: 8)), - ), - child: Text('View Code'), - ), - ), - ], - ), - ], - ), - ), - ); - } -} +} \ No newline at end of file