From a17dc3543fcea465465594fc27f5d06cdf508b5e Mon Sep 17 00:00:00 2001 From: prabhav-pandya Date: Sun, 10 Oct 2021 19:50:50 +0530 Subject: [PATCH 1/2] updated sorting interface --- .../home_page/components/sort_options.dart | 155 +++++++++++------- src/pubspec.lock | 14 +- 2 files changed, 101 insertions(+), 68 deletions(-) diff --git a/src/lib/home_page/components/sort_options.dart b/src/lib/home_page/components/sort_options.dart index 4440d2f..63fcd66 100644 --- a/src/lib/home_page/components/sort_options.dart +++ b/src/lib/home_page/components/sort_options.dart @@ -6,80 +6,113 @@ import 'package:junior/settings_page/body.dart'; // ignore: always_use_package_imports import '../../theme.dart'; -class SortOptions extends StatelessWidget { +class SortOptions extends StatefulWidget { final Function(String option) sortBy; final String sortOption; - // ignore: sort_constructors_first, use_key_in_widget_constructors + // ignore: use_key_in_widget_constructors, sort_constructors_first const SortOptions({this.sortBy, this.sortOption}); + @override + _SortOptions createState() { + // ignore: no_logic_in_create_state + return _SortOptions(sortBy: this.sortBy, sortOption: this.sortOption); + } +} + +class _SortOptions extends State { + final Function(String option) sortBy; + final String sortOption; + + // ignore: sort_constructors_first, use_key_in_widget_constructors + _SortOptions({this.sortBy, this.sortOption}); + + var isSortListVisible = false; + @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - DropdownButton( - icon: Container(), - hint: Row( - children: [ - Icon( + padding: const EdgeInsets.symmetric(horizontal: 15.0), + child: Column(children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + TextButton.icon( + icon: Icon( Icons.sort, color: linkColor, size: 20, ), - const SizedBox(width: 10), - Text( - sortOption, - style: TextStyle( - color: textColor, - fontSize: 16, - ), - ), - ], - ), - elevation: 0, - style: TextStyle(color: textColor), - dropdownColor: tileColor.withAlpha(255), - isDense: true, - underline: Container(), - onChanged: (String newValue) { - saveSortOption(newValue); - sortBy(newValue); - }, - items: [ - 'Alphabetical', - 'Most Recent', - 'Rating', - 'Ongoing', - 'Complete', - 'To Read' - ].map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - ), - IconButton( - icon: Icon( - Icons.settings, - color: linkColor, - size: 20, - ), - onPressed: () { - Navigator.pop(context); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const SettingsPage(), + label: Text(sortOption, + style: const TextStyle(color: Colors.white)), + onPressed: () { + setState(() { + isSortListVisible = !isSortListVisible; + }); + }, + ), + IconButton( + icon: Icon( + Icons.settings, + color: linkColor, + size: 20, ), - ); - }, + onPressed: () { + Navigator.pop(context); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const SettingsPage(), + ), + ); + }, + ), + ], ), - ], - ), - ); + Visibility( + visible: isSortListVisible, + child: SortHorizontalTiles(sortBy: sortBy)) + ])); + } +} + +// ignore: must_be_immutable +class SortHorizontalTiles extends StatelessWidget { + final Function(String option) sortBy; + + // ignore: sort_constructors_first, use_key_in_widget_constructors + SortHorizontalTiles({this.sortBy}); + + List sortingOptions = [ + 'Alphabetical', + 'Most Recent', + 'Rating', + 'Ongoing', + 'Complete', + 'To Read' + ]; + + @override + Widget build(BuildContext context) { + return SizedBox( + height: 50, + child: Padding( + padding: const EdgeInsets.only(left: 10, right: 10), + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: sortingOptions.length, + itemBuilder: (BuildContext context, int index) { + return TextButton( + onPressed: () { + saveSortOption(sortingOptions[index]); + sortBy(sortingOptions[index]); + }, + child: Text(sortingOptions[index]), + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all( + Colors.white.withAlpha(170)), + ), + ); + }))); } } diff --git a/src/pubspec.lock b/src/pubspec.lock index 49b3de6..745bf49 100644 --- a/src/pubspec.lock +++ b/src/pubspec.lock @@ -21,7 +21,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.1" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -42,7 +42,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.3.1" + version: "1.2.0" clock: dependency: transitive description: @@ -91,7 +91,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.2" + version: "6.1.0" file_picker: dependency: "direct main" description: @@ -191,7 +191,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.3.0" path: dependency: transitive description: @@ -275,7 +275,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.3" + version: "4.2.1" settings_ui: dependency: "direct main" description: @@ -378,7 +378,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.3.0" typed_data: dependency: transitive description: @@ -441,7 +441,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "7.1.1" + version: "6.2.0" webdriver: dependency: transitive description: From 3420b68279613c977921b0c2dac970447a95d403 Mon Sep 17 00:00:00 2001 From: Prabhav Pandya <62668380+prabhav-pandya@users.noreply.github.com> Date: Thu, 14 Oct 2021 14:09:55 +0530 Subject: [PATCH 2/2] updated bug report & feature request links --- src/lib/settings_page/body.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/settings_page/body.dart b/src/lib/settings_page/body.dart index 83db675..d1bda6a 100644 --- a/src/lib/settings_page/body.dart +++ b/src/lib/settings_page/body.dart @@ -222,7 +222,7 @@ class _SettingsPageState extends State { ), onPressed: (context) { launch( - 'https://github.com/OverPoweredDev/Junior/issues/new?assignees=&labels=&template=bug_report.md&title='); + 'https://gitreports.com/issue/OverPoweredDev/Junior'); }, ), SettingsTile( @@ -234,7 +234,7 @@ class _SettingsPageState extends State { ), onPressed: (context) { launch( - 'https://github.com/OverPoweredDev/Junior/issues/new?assignees=&labels=&template=feature_request.md&title='); + 'https://gitreports.com/issue/OverPoweredDev/Junior'); }, ), SettingsTile(