Skip to content

Commit

Permalink
Improve feed empty screen. Add mark all read button - Fix #310
Browse files Browse the repository at this point in the history
  • Loading branch information
prof18 committed Jan 4, 2025
1 parent 81d5b33 commit 9b5e32f
Show file tree
Hide file tree
Showing 21 changed files with 381 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal fun FeedWithContentView(
onCommentClick: (FeedItemUrlInfo) -> Unit,
requestMoreItems: () -> Unit,
onRefresh: () -> Unit,
markAllAsRead: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
Expand Down Expand Up @@ -80,6 +81,7 @@ internal fun FeedWithContentView(
updateReadStatus(index)
},
requestMoreItems = requestMoreItems,
markAllAsRead = markAllAsRead,
)
}
}
Expand All @@ -100,6 +102,7 @@ private fun FeedWithContentViewPreview() {
onCommentClick = {},
requestMoreItems = {},
onRefresh = {},
markAllAsRead = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ internal fun HomeScaffold(
onAddFeedClick = onAddFeedClick,
requestMoreItems = requestNewData,
onBackToTimelineClick = onBackToTimelineClick,
markAllAsRead = markAllRead,
onOpenDrawerClick = onDrawerMenuClick,
isDrawerVisible = showDrawerMenu,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ internal fun HomeScreenContent(
feedState: ImmutableList<FeedItem>,
listState: LazyListState,
currentFeedFilter: FeedFilter,
isDrawerVisible: Boolean,
updateReadStatus: (Int) -> Unit,
onFeedItemClick: (FeedItemUrlInfo) -> Unit,
onBookmarkClick: (FeedItemId, Boolean) -> Unit,
Expand All @@ -38,6 +39,8 @@ internal fun HomeScreenContent(
onAddFeedClick: () -> Unit,
requestMoreItems: () -> Unit,
onBackToTimelineClick: () -> Unit,
markAllAsRead: () -> Unit,
onOpenDrawerClick: () -> Unit,
onRefresh: () -> Unit = {},
) {
when {
Expand All @@ -58,6 +61,8 @@ internal fun HomeScreenContent(
currentFeedFilter = currentFeedFilter,
onReloadClick = onRefresh,
onBackToTimelineClick = onBackToTimelineClick,
onOpenDrawerClick = onOpenDrawerClick,
isDrawerVisible = isDrawerVisible,
)
}

Expand All @@ -75,6 +80,7 @@ internal fun HomeScreenContent(
onReadStatusClick = onReadStatusClick,
onCommentClick = onCommentClick,
onRefresh = onRefresh,
markAllAsRead = markAllAsRead,
)
}
}
Expand All @@ -92,6 +98,7 @@ private fun HomeScreeContentLoadingPreview() {
feedState = feedItemsForPreview,
listState = rememberLazyListState(),
currentFeedFilter = FeedFilter.Timeline,
isDrawerVisible = true,
updateReadStatus = {},
onFeedItemClick = {},
onAddFeedClick = {},
Expand All @@ -101,6 +108,8 @@ private fun HomeScreeContentLoadingPreview() {
onBookmarkClick = { _, _ -> },
onReadStatusClick = { _, _ -> },
onBackToTimelineClick = {},
markAllAsRead = {},
onOpenDrawerClick = {},
)
}
}
Expand All @@ -115,6 +124,7 @@ private fun HomeScreeContentLoadedPreview() {
feedState = feedItemsForPreview,
listState = rememberLazyListState(),
currentFeedFilter = FeedFilter.Timeline,
isDrawerVisible = true,
updateReadStatus = {},
onFeedItemClick = {},
onAddFeedClick = {},
Expand All @@ -123,6 +133,8 @@ private fun HomeScreeContentLoadedPreview() {
onBookmarkClick = { _, _ -> },
onReadStatusClick = { _, _ -> },
onBackToTimelineClick = {},
markAllAsRead = {},
onOpenDrawerClick = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ internal fun HomeScreen(
onDeleteFeedSourceClick = { feedSource ->
homeViewModel.deleteFeedSource(feedSource)
},
markAllAsRead = {
homeViewModel.markAllRead()
},
)
}

Expand Down Expand Up @@ -179,6 +182,9 @@ internal fun HomeScreen(
onDeleteFeedSourceClick = { feedSource ->
homeViewModel.deleteFeedSource(feedSource)
},
markAllAsRead = {
homeViewModel.markAllRead()
},
)
}

Expand Down Expand Up @@ -229,6 +235,9 @@ internal fun HomeScreen(
onDeleteFeedSourceClick = { feedSource ->
homeViewModel.deleteFeedSource(feedSource)
},
markAllAsRead = {
homeViewModel.markAllRead()
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ internal fun CompactView(
onSearchClick: () -> Unit,
openUrl: (FeedItemUrlInfo) -> Unit,
onDeleteFeedSourceClick: (FeedSource) -> Unit,
markAllAsRead: () -> Unit,
) {
val scope = rememberCoroutineScope()
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
Expand Down Expand Up @@ -113,6 +114,7 @@ internal fun CompactView(
onReadStatusClick = onReadStatusClick,
onBackToTimelineClick = onBackToTimelineClick,
onSearchClick = onSearchClick,
markAllAsRead = markAllAsRead
)
}
}
Expand Down Expand Up @@ -141,6 +143,7 @@ private fun CompactViewPreview() {
onSearchClick = {},
openUrl = {},
onDeleteFeedSourceClick = {},
markAllAsRead = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal fun ExpandedView(
onSearchClick: () -> Unit,
openUrl: (FeedItemUrlInfo) -> Unit,
onDeleteFeedSourceClick: (FeedSource) -> Unit,
markAllAsRead: () -> Unit,
) {
val scope = rememberCoroutineScope()
val navigator = LocalNavigator.currentOrThrow
Expand Down Expand Up @@ -107,6 +108,7 @@ internal fun ExpandedView(
onReadStatusClick = onReadStatusClick,
onBackToTimelineClick = onBackToTimelineClick,
onSearchClick = onSearchClick,
markAllAsRead = markAllAsRead
)
}
}
Expand Down Expand Up @@ -135,6 +137,7 @@ private fun ExpandedViewPreview() {
onSearchClick = {},
openUrl = {},
onDeleteFeedSourceClick = {},
markAllAsRead = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ internal fun MediumView(
onSearchClick: () -> Unit,
openUrl: (FeedItemUrlInfo) -> Unit,
onDeleteFeedSourceClick: (FeedSource) -> Unit,
markAllAsRead: () -> Unit,
) {
var isDrawerMenuFullVisible by remember {
mutableStateOf(true)
Expand Down Expand Up @@ -122,6 +123,7 @@ internal fun MediumView(
onReadStatusClick = onReadStatusClick,
onBackToTimelineClick = onBackToTimelineClick,
onSearchClick = onSearchClick,
markAllAsRead = markAllAsRead,
)
}
}
Expand Down Expand Up @@ -150,6 +152,7 @@ private fun MediumViewPreview() {
onSearchClick = {},
openUrl = {},
onDeleteFeedSourceClick = {},
markAllAsRead = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ internal fun FeedWithContentView(
onReadStatusClick: (FeedItemId, Boolean) -> Unit,
onCommentClick: (FeedItemUrlInfo) -> Unit,
requestMoreItems: () -> Unit,
markAllAsRead: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
Expand All @@ -68,6 +69,7 @@ internal fun FeedWithContentView(
updateReadStatus = { index ->
updateReadStatus(index)
},
markAllAsRead = markAllAsRead,
)

VerticalScrollbar(
Expand Down Expand Up @@ -112,6 +114,7 @@ private fun FeedWithContentViewPreview() {
onCommentClick = { },
requestMoreItems = { },
paddingValues = PaddingValues(),
markAllAsRead = { },
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal fun HomeScreenContent(
requestMoreItems: () -> Unit,
onBackToTimelineClick: () -> Unit,
onSearchClick: () -> Unit,
markAllAsRead: () -> Unit,
modifier: Modifier = Modifier,
showDrawerMenu: Boolean = false,
isDrawerMenuOpen: Boolean = false,
Expand Down Expand Up @@ -65,6 +66,8 @@ internal fun HomeScreenContent(
currentFeedFilter = currentFeedFilter,
onReloadClick = onRefresh,
onBackToTimelineClick = onBackToTimelineClick,
onOpenDrawerClick = onDrawerMenuClick,
isDrawerVisible = showDrawerMenu,
)

else -> FeedWithContentView(
Expand All @@ -78,6 +81,7 @@ internal fun HomeScreenContent(
onReadStatusClick = onReadStatusClick,
onCommentClick = onCommentClick,
requestMoreItems = requestMoreItems,
markAllAsRead = markAllAsRead,
)
}
}
Expand All @@ -104,6 +108,7 @@ private fun HomeScreenContentPreview() {
onCommentClick = {},
onBackToTimelineClick = {},
onSearchClick = {},
markAllAsRead = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ expect fun String.format(vararg args: Any): String

@Suppress("UnusedPrivateProperty")
// This is a trick to be sure that KSP re-generates the strings when there's no code updates
private const val StringsVersion = 59
private const val StringsVersion = 60
1 change: 1 addition & 0 deletions i18n/src/commonMain/resources/locale/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@
<string name="edit_feed">Edit feed</string>
<string name="feed_name">Feed name</string>
<string name="feed_edited_message">Feed "%s" updated</string>
<string name="open_another_feed">Open another feed</string>
</resources>
6 changes: 5 additions & 1 deletion iosApp/Source/App/CompactView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ struct CompactView: View {
toggleListScroll: $scrollUpTrigger,
showSettings: .constant(false),
selectedDrawerItem: $selectedDrawerItem,
homeViewModel: homeViewModel
columnVisibility: .constant(.automatic),
homeViewModel: homeViewModel,
openDrawer: {
// Handle by the view for the compact view
}
)
.environment(indexHolder)
}
Expand Down
10 changes: 8 additions & 2 deletions iosApp/Source/App/RegularView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ struct RegularView: View {
@State private var showEditFeedSheet = false
@State private var feedSourceToEdit: FeedSource?

@State private var columnVisibility: NavigationSplitViewVisibility = .automatic

var body: some View {
NavigationSplitView {
NavigationSplitView(columnVisibility: $columnVisibility) {
SidebarDrawer(
selectedDrawerItem: $selectedDrawerItem,
navDrawerState: navDrawerState,
Expand Down Expand Up @@ -93,7 +95,11 @@ struct RegularView: View {
toggleListScroll: $scrollUpTrigger,
showSettings: $showSettings,
selectedDrawerItem: $selectedDrawerItem,
homeViewModel: homeViewModel
columnVisibility: $columnVisibility,
homeViewModel: homeViewModel,
openDrawer: {
columnVisibility = .all
}
)
.environment(indexHolder)
}
Expand Down
Loading

0 comments on commit 9b5e32f

Please sign in to comment.