Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show sort icon in header/settings #718

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading