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

Add customizable feed card divider #1230

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 2 additions & 9 deletions lib/community/widgets/post_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:thunder/core/auth/bloc/auth_bloc.dart';
import 'package:thunder/core/enums/swipe_action.dart';
import 'package:thunder/core/models/post_view_media.dart';
import 'package:thunder/feed/bloc/feed_bloc.dart';
import 'package:thunder/feed/widgets/widgets.dart';
import 'package:thunder/post/enums/post_action.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';
import 'package:thunder/post/utils/navigate_post.dart';
Expand Down Expand Up @@ -132,15 +133,6 @@ class _PostCardState extends State<PostCard> {
},
child: Column(
children: [
Divider(
height: 1.0,
thickness: 4.0,
color: ElevationOverlay.applySurfaceTint(
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.surfaceTint,
10,
),
),
Dismissible(
direction: isOverridingSwipeGestureAction == true ? DismissDirection.none : determinePostSwipeDirection(isUserLoggedIn, state),
key: ObjectKey(widget.postViewMedia.postView.post.id),
Expand Down Expand Up @@ -244,6 +236,7 @@ class _PostCardState extends State<PostCard> {
},
),
),
const FeedCardDivider(),
],
),
);
Expand Down
16 changes: 16 additions & 0 deletions lib/core/enums/feed_card_divider_thickness.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
enum FeedCardDividerThickness {
compact,
standard,
comfortable;

double get value {
switch (this) {
case FeedCardDividerThickness.compact:
return 2.0;
case FeedCardDividerThickness.standard:
return 6.0;
case FeedCardDividerThickness.comfortable:
return 10.0;
}
}
}
6 changes: 6 additions & 0 deletions lib/core/enums/local_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ enum LocalSettings {
cardPostCardMetadataItems(name: 'setting_card_post_card_metadata_items', key: 'cardPostCardMetadataItems', category: LocalSettingsCategories.posts, subCategory: LocalSettingsSubCategories.posts),
showFullPostDate(name: 'setting_general_show_full_post_date', key: 'showFullPostDate', category: LocalSettingsCategories.posts, subCategory: LocalSettingsSubCategories.posts),
dateFormat(name: 'setting_general_date_format', key: 'dateFormat', category: LocalSettingsCategories.posts, subCategory: LocalSettingsSubCategories.posts),
// This setting exists purely for the searching function
dividerAppearance(name: '', key: 'dividerAppearance', category: LocalSettingsCategories.posts, subCategory: LocalSettingsSubCategories.posts),
feedCardDividerThickness(
name: 'setting_feed_card_divider_thickness', key: 'feedCardDividerThickness', category: LocalSettingsCategories.posts, subCategory: LocalSettingsSubCategories.posts, searchable: false),
feedCardDividerColor(name: 'setting_feed_card_divider_color', key: 'feedCardDividerColor', category: LocalSettingsCategories.posts, subCategory: LocalSettingsSubCategories.posts, searchable: false),

// Advanced Settings
userFormat(name: 'user_format', key: 'userFormat', category: LocalSettingsCategories.general, subCategory: LocalSettingsSubCategories.advanced),
Expand Down Expand Up @@ -314,6 +319,7 @@ extension LocalizationExt on AppLocalizations {
'dimReadPosts': dimReadPosts,
'showFullPostDate': showFullDate,
'dateFormat': dateFormat,
'dividerAppearance': dividerAppearance,
'showCrossPosts': showCrossPosts,
'keywordFilters': keywordFilters,
'hideTopBarOnScroll': hideTopBarOnScroll,
Expand Down
44 changes: 25 additions & 19 deletions lib/feed/view/feed_comment_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lemmy_api_client/v3.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:thunder/core/auth/bloc/auth_bloc.dart';
import 'package:thunder/feed/feed.dart';

import 'package:thunder/shared/comment_reference.dart';

Expand All @@ -27,25 +28,30 @@ class FeedCommentList extends StatelessWidget {
crossAxisSpacing: 40,
mainAxisSpacing: 0,
itemBuilder: (BuildContext context, int index) {
return CommentReference(
comment: commentViews[index],
now: DateTime.now(),
onVoteAction: (int commentId, int voteType) => {
// TODO: Implement action
},
onSaveAction: (int commentId, bool save) => {
// TODO: Implement action
},
onDeleteAction: (int commentId, bool deleted) => {
// TODO: Implement action
},
onReportAction: (int commentId) {
// TODO: Implement action
},
onReplyEditAction: (CommentView commentView, bool isEdit) {
// TODO: Implement action
},
isOwnComment: commentViews[index].comment.creatorId == state.account?.userId,
return Column(
children: [
CommentReference(
comment: commentViews[index],
now: DateTime.now(),
onVoteAction: (int commentId, int voteType) => {
// TODO: Implement action
},
onSaveAction: (int commentId, bool save) => {
// TODO: Implement action
},
onDeleteAction: (int commentId, bool deleted) => {
// TODO: Implement action
},
onReportAction: (int commentId) {
// TODO: Implement action
},
onReplyEditAction: (CommentView commentView, bool isEdit) {
// TODO: Implement action
},
isOwnComment: commentViews[index].comment.creatorId == state.account?.userId,
),
const FeedCardDivider(),
],
);
},
childCount: commentViews.length,
Expand Down
24 changes: 24 additions & 0 deletions lib/feed/widgets/feed_card_divider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';

class FeedCardDivider extends StatelessWidget {
const FeedCardDivider({super.key});

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final state = context.watch<ThunderBloc>().state;

final feedCardDividerThickness = state.feedCardDividerThickness;
final feedCardDividerColor = state.feedCardDividerColor;

return Divider(
height: feedCardDividerThickness.value,
thickness: feedCardDividerThickness.value,
color: feedCardDividerColor == Colors.transparent
? ElevationOverlay.applySurfaceTint(theme.colorScheme.surface, theme.colorScheme.surfaceTint, 10)
: Color.alphaBlend(theme.colorScheme.primaryContainer.withOpacity(0.6), feedCardDividerColor).withOpacity(0.2),
);
}
}
1 change: 1 addition & 0 deletions lib/feed/widgets/widgets.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export 'feed_page_app_bar.dart';
export 'feed_card_divider.dart';
28 changes: 28 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"@collapseSpoiler": {
"description": "Label for collapsing spoiler"
},
"color": "Color",
"@color": {
"description": "Describes a color"
},
"colorizeCommunityName": "Colorize Community Name",
"@colorizeCommunityName": {
"description": "Setting for colorizing community name"
Expand All @@ -235,6 +239,10 @@
"@combineNavAndFab": {},
"combineNavAndFabDescription": "Floating Action Button will be shown between navigation buttons.",
"@combineNavAndFabDescription": {},
"comfortable": "Comfortable",
"@comfortable": {
"description": "Describes a comfortable visual density"
},
"comment": "Comment",
"@comment": {},
"commentBehaviourSettings": "Comments",
Expand Down Expand Up @@ -287,6 +295,10 @@
"@communityStyle": {
"description": "Heading for community style setting"
},
"compact": "Compact",
"@compact": {
"description": "Describes a compact visual density"
},
"compactPostCardMetadataItems": "Compact View Metadata",
"@compactPostCardMetadataItems": {
"description": "Name of setting for compact post card metadata items"
Expand Down Expand Up @@ -455,6 +467,10 @@
"@displayUserScore": {
"description": "Option for displaying user scores or karma."
},
"dividerAppearance": "Divider Appearance",
"@dividerAppearance": {
"description": "Divider appearance category"
},
"doNotShowAgain": "Do Not Show Again",
"@doNotShowAgain": {
"description": "Action for hiding something permanently"
Expand Down Expand Up @@ -569,6 +585,10 @@
"@feedBehaviourSettings": {
"description": "Subcategory in Setting -> General"
},
"feedSettings": "Feed Settings",
"@feedSettings": {
"description": "Feed settings category."
},
"feedTypeAndSorts": "Default Feed Type and Sorting",
"@feedTypeAndSorts": {
"description": "Subcategory in Setting -> General"
Expand Down Expand Up @@ -1521,6 +1541,10 @@
"@spoiler": {
"description": "Placeholder label for spoiler"
},
"standard": "Standard",
"@standard": {
"description": "Describes a standard visual density"
},
"submit": "Submit",
"@submit": {},
"subscribe": "Subscribe",
Expand Down Expand Up @@ -1581,6 +1605,10 @@
"@theming": {
"description": "Title of Theming in Settings -> Appearance -> Theming"
},
"thickness": "Thickness",
"@thickness": {
"description": "Describes a thickness (e.g., divider)"
},
"thunderHasBeenUpdated": "Thunder updated to {version}!",
"@thunderHasBeenUpdated": {
"description": "Heading for changelog when Thunder has been updated"
Expand Down
10 changes: 5 additions & 5 deletions lib/modlog/widgets/modlog_filter_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,28 @@ class _ModlogActionTypePickerState extends State<ModlogActionTypePicker> {
title: AppLocalizations.of(GlobalContext.context)!.posts,
items: postModlogActionTypeItems,
onNavigateBack: () => setState(() => category = ModlogActionTypeFilterCategory.all),
onSelect: (item) => widget.onSelect(item),
onSelect: (item) => widget.onSelect?.call(item),
previouslySelectedItem: widget.previouslySelected,
),
ModlogActionTypeFilterCategory.comment => ModlogSubFilterPicker(
title: AppLocalizations.of(GlobalContext.context)!.comments,
items: commentModlogActionTypeItems,
onNavigateBack: () => setState(() => category = ModlogActionTypeFilterCategory.all),
onSelect: (item) => widget.onSelect(item),
onSelect: (item) => widget.onSelect?.call(item),
previouslySelectedItem: widget.previouslySelected,
),
ModlogActionTypeFilterCategory.community => ModlogSubFilterPicker(
title: AppLocalizations.of(GlobalContext.context)!.community,
items: communityModlogActionTypeItems,
onNavigateBack: () => setState(() => category = ModlogActionTypeFilterCategory.all),
onSelect: (item) => widget.onSelect(item),
onSelect: (item) => widget.onSelect?.call(item),
previouslySelectedItem: widget.previouslySelected,
),
ModlogActionTypeFilterCategory.instance => ModlogSubFilterPicker(
title: AppLocalizations.of(GlobalContext.context)!.instance(1),
items: instanceModlogActionTypeItems,
onNavigateBack: () => setState(() => category = ModlogActionTypeFilterCategory.all),
onSelect: (item) => widget.onSelect(item),
onSelect: (item) => widget.onSelect?.call(item),
previouslySelectedItem: widget.previouslySelected,
),
},
Expand Down Expand Up @@ -168,7 +168,7 @@ class _ModlogActionTypePickerState extends State<ModlogActionTypePicker> {
onSelected: () {
HapticFeedback.mediumImpact();
Navigator.of(context).pop();
widget.onSelect(item);
widget.onSelect?.call(item);
},
isSelected: widget.previouslySelected == item.payload,
),
Expand Down
Loading
Loading