Skip to content

Commit

Permalink
Merge pull request #718 from micahmo/feature/sort-type-icon-revival
Browse files Browse the repository at this point in the history
Show sort icon in header/settings
  • Loading branch information
hjiangsu committed Sep 11, 2023
2 parents faee905 + 1f121b4 commit c08110a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Added setting to import and export settings
- Added liveness and latency indicators for instances in profile switcher - contribution from @micahmo
- Add option to disabling graying out read posts - contribution from @micahmo
- Show sort type icon - contribution from @micahmo
- Downvote actions will be disabled when instances have downvotes disabled
- Automatically save drafts for posts and comments - contribution from @micahmo

Expand Down
16 changes: 15 additions & 1 deletion lib/community/pages/community_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ class _CommunityPageState extends State<CommunityPage> with AutomaticKeepAliveCl
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(getSortName(state)),
subtitle: Row(
children: [
Icon(getSortIcon(state), size: 13),
const SizedBox(width: 4),
Text(getSortName(state)),
],
),
contentPadding: const EdgeInsets.symmetric(horizontal: 0),
),
centerTitle: false,
Expand Down Expand Up @@ -494,6 +500,14 @@ class _CommunityPageState extends State<CommunityPage> with AutomaticKeepAliveCl
return sortTypeLabel ?? '';
}

IconData? getSortIcon(CommunityState state) {
if (state.status == CommunityStatus.initial || state.status == CommunityStatus.loading) {
return null;
}

return sortTypeIcon;
}

FutureOr<bool> _handleBack(bool stopDefaultButtonEvent, RouteInfo info) async {
if (context.read<ThunderBloc>().state.isFabOpen) {
context.read<ThunderBloc>().add(const OnFabToggle(false));
Expand Down
9 changes: 8 additions & 1 deletion lib/post/pages/post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ class _PostPageState extends State<PostPage> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(sortTypeLabel ?? ''),
subtitle: Row(
children: [
Icon(sortTypeIcon, size: 13),
const SizedBox(width: 4),
Text(sortTypeLabel ?? ''),
],
),
contentPadding: const EdgeInsets.symmetric(horizontal: 0),
),
flexibleSpace: GestureDetector(
Expand Down Expand Up @@ -459,6 +465,7 @@ class _PostPageState extends State<PostPage> {
onSelect: (selected) {
setState(() {
sortType = selected.payload;
sortTypeLabel = selected.label;
sortTypeIcon = selected.icon;
});
context.read<PostBloc>().add(
Expand Down
20 changes: 20 additions & 0 deletions lib/settings/pages/general_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
},
previouslySelected: defaultSortType,
),
valueDisplay: Row(
children: [
Icon(allSortTypeItems.firstWhere((sortTypeItem) => sortTypeItem.payload == defaultSortType).icon, size: 13),
const SizedBox(width: 4),
Text(
allSortTypeItems.firstWhere((sortTypeItem) => sortTypeItem.payload == defaultSortType).label,
style: theme.textTheme.titleSmall,
),
],
),
),
],
),
Expand Down Expand Up @@ -603,6 +613,16 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
},
previouslySelected: defaultCommentSortType,
),
valueDisplay: Row(
children: [
Icon(commentSortTypeItems.firstWhere((sortTypeItem) => sortTypeItem.payload == defaultCommentSortType).icon, size: 13),
const SizedBox(width: 4),
Text(
commentSortTypeItems.firstWhere((sortTypeItem) => sortTypeItem.payload == defaultCommentSortType).label,
style: theme.textTheme.titleSmall,
),
],
),
),
ListOption(
description: LocalSettings.nestedCommentIndicatorStyle.label,
Expand Down

0 comments on commit c08110a

Please sign in to comment.