diff --git a/lib/programs screen/outreachy.dart b/lib/programs screen/outreachy.dart index 618a74a..30635e8 100644 --- a/lib/programs screen/outreachy.dart +++ b/lib/programs screen/outreachy.dart @@ -90,7 +90,7 @@ class _OutreachyScreenState extends State { } } - void filterProjects() { + void filterProjects([String query = ""]) { projectList = _getProjectsByYear(); if (!selectedSkills.contains('All')) { @@ -100,6 +100,13 @@ class _OutreachyScreenState extends State { .toList(); } + if (query.isNotEmpty) { + projectList = projectList + .where((project) => + project.name.toLowerCase().contains(query.toLowerCase())) + .toList(); + } + setState(() {}); } @@ -139,45 +146,45 @@ class _OutreachyScreenState extends State { 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('Outreachy'), 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), - ), - ); - if (isBookmarked) { - HandleBookmark.addBookmark(currentProject, currentPage); - } else { - HandleBookmark.deleteBookmark(currentProject); - } - }, - ), - IconButton( - icon: Icon(Icons.info_outline), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => OUTREACHYInfo()), - ); - }, - ), - ]), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios), + onPressed: () => Navigator.of(context).pop(), + ), + centerTitle: true, + title: const Text('Outreachy'), + 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), + ), + ); + if (isBookmarked) { + HandleBookmark.addBookmark(currentProject, currentPage); + } else { + HandleBookmark.deleteBookmark(currentProject); + } + }, + ), + IconButton( + icon: Icon(Icons.info_outline), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => OUTREACHYInfo()), + ); + }, + ), + ]), body: FutureBuilder( future: getProjectFunction, builder: (context, snapshot) { @@ -191,6 +198,8 @@ class _OutreachyScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + _buildSearchBar(), + const SizedBox(height: 20), _buildYearButtons(), const SizedBox(height: 20), _buildMultiSelectField( @@ -221,6 +230,42 @@ class _OutreachyScreenState extends State { ); } + Widget _buildSearchBar() { + return TextFormField( + decoration: InputDecoration( + filled: true, + hintText: 'Search', + suffixIcon: const Icon(Icons.search), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide(color: Color(0xFFEEEEEE)), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide(color: Color(0xFFEEEEEE)), + ), + disabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide(color: Color(0xFFEEEEEE)), + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide(color: Color(0xFFEEEEEE)), + ), + contentPadding: + const EdgeInsets.symmetric(vertical: 12.0, horizontal: 20.0), + ), + onFieldSubmitted: (value) { + filterProjects(value); + }, + onChanged: (value) { + if (value.isEmpty) { + filterProjects(value); + } + }, + ); + } + Widget _buildYearButtons() { return SizedBox( height: MediaQuery.of(context).size.height * 0.2,