Skip to content

Commit

Permalink
Re-organizing settings page and addition of post/comment previews (#890)
Browse files Browse the repository at this point in the history
* moved posts appearance options into its own page, and added post previews

* added comments appearance page

* added some more details to the post previews

* cleaned up comments appearance page

* cleaned up posts appearance page

* cleaned up general settings page, added more localization strings

* refactored settings page to use localization strings and slivers

* changed sliver app bars to normal and pinned

* updated changelog

* refactored debug settings page to use new layouts and localization strings

* fixed issue with post previews dont show up properly when NSFW posts are off
  • Loading branch information
hjiangsu committed Nov 29, 2023
1 parent 1d65101 commit 2e0d572
Show file tree
Hide file tree
Showing 14 changed files with 2,016 additions and 941 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Added ability to collapse post in post page
- Added ability to change app language in settings
- Added ability to show/hide read posts in user settings
- Added post and comment previews to settings, and reorganized settings page

## 0.2.6 - 2023-11-22
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion lib/core/enums/local_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ enum LocalSettings {
/// -------------------------- Feed Related Settings --------------------------
// Default Listing/Sort Settings
defaultFeedListingType(name: 'setting_general_default_listing_type', label: 'Default Feed Type'),
defaultFeedSortType(name: 'setting_general_default_sort_type', label: 'Default Sort Type'),
defaultFeedSortType(name: 'setting_general_default_sort_type', label: 'Default Feed Sort Type'),

// NSFW Settings
hideNsfwPosts(name: 'setting_general_hide_nsfw_posts', label: 'Hide NSFW Posts from Feed'),
Expand Down
87 changes: 87 additions & 0 deletions lib/feed/utils/post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,90 @@ Future<PostView> createPost({required int communityId, required String name, Str

return postResponse.postView;
}

/// Creates a placeholder post from the given parameters. This is mainly used to display a preview of the post
/// with the applied settings on Settings -> Appearance -> Posts page.
Future<PostViewMedia?> createExamplePost({
String? postTitle,
String? postUrl,
String? postBody,
String? postThumbnailUrl,
bool? locked,
bool? nsfw,
bool? pinned,
String? personName,
String? personDisplayName,
String? communityName,
String? instanceUrl,
int? commentCount,
int? scoreCount,
bool? saved,
bool? read,
}) async {
PostView postView = PostView(
post: Post(
id: 1,
name: postTitle ?? 'Example Title',
url: postUrl,
body: postBody,
thumbnailUrl: postThumbnailUrl,
creatorId: 1,
communityId: 1,
removed: false,
locked: locked ?? false,
published: DateTime.now(),
deleted: false,
nsfw: nsfw ?? false,
apId: '',
local: false,
languageId: 0,
featuredCommunity: pinned ?? false,
featuredLocal: false,
),
creator: Person(
id: 1,
name: personName ?? 'Example Username',
displayName: personDisplayName ?? 'Example Name',
banned: false,
published: DateTime.now(),
actorId: '',
local: false,
deleted: false,
botAccount: false,
instanceId: 1,
),
community: Community(
id: 1,
name: communityName ?? 'Example Community',
title: '',
removed: false,
published: DateTime.now(),
deleted: false,
nsfw: false,
actorId: instanceUrl ?? 'https://thunder.lemmy',
local: false,
hidden: false,
postingRestrictedToMods: false,
instanceId: 1,
),
creatorBannedFromCommunity: false,
counts: PostAggregates(
id: 1,
postId: 1,
comments: commentCount ?? 0,
score: scoreCount ?? 0,
upvotes: 0,
downvotes: 0,
published: DateTime.now(),
),
subscribed: SubscribedType.notSubscribed,
saved: saved ?? false,
read: read ?? false,
creatorBlocked: false,
unreadComments: 0,
);

List<PostViewMedia> postViewMedias = await parsePostViews([postView]);

return Future.value(postViewMedias.firstOrNull);
}
Loading

0 comments on commit 2e0d572

Please sign in to comment.