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

New Feature: Introduce Upcoming page to Mihon #420

Merged
merged 41 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3e762e5
Work in progress upcoming feature
sirlag Feb 16, 2024
980585c
Checkpointing WIP upcoming feature
sirlag Feb 18, 2024
c813861
Functional Upcoming Screen
sirlag Feb 18, 2024
9d26a10
Rename UpdateCalendar to UpdateUpcoming
sirlag Feb 18, 2024
d210b07
Converted Strings to resources
sirlag Feb 18, 2024
0096618
Cleanup
sirlag Feb 18, 2024
e78ab8e
Fixed detekt issues
sirlag Feb 18, 2024
c8c3739
Removed Link icon per @AntsyLich's suggestion.
sirlag Feb 18, 2024
27cad52
Detekt
sirlag Feb 18, 2024
361bc4f
Fixed Calendar display on wide form factor devices
sirlag Feb 18, 2024
30ccce4
Added Key to upcoming lazycolumn
sirlag Feb 18, 2024
3789e13
Updated tablet mode UI to support two column view
sirlag Feb 19, 2024
20a7db6
Updated header creation logic
sirlag Feb 24, 2024
c561f9d
Updated header creation logic... again
sirlag Feb 24, 2024
1de161b
Moved stray string to resources
sirlag Mar 22, 2024
2e800f9
Fixed PR Comments and query refactor
sirlag Mar 22, 2024
e392d10
Merge branch 'main' into update-calendar
sirlag Mar 22, 2024
41c04f9
Tweaks to query, refactored to flow, comments on calendar
sirlag Mar 23, 2024
376dcdc
Merge branch 'update-calendar' of https://github.com/sirlag/mihon int…
sirlag Mar 23, 2024
8b7b53b
Switched to Date Formatter
sirlag Mar 23, 2024
61afdbb
Cleaned up date formatter
sirlag Mar 23, 2024
b8e48f5
More Refactor work
sirlag Mar 23, 2024
ae6d535
Updated Calendar to support localized week formats
sirlag Mar 25, 2024
8a63325
Fixed year format
sirlag Mar 25, 2024
22a0270
Refactored Header animation
sirlag Mar 26, 2024
9e245f1
Moved upcoming FAQ
sirlag Mar 26, 2024
acaa12a
Completed YearMonth Migration
sirlag Mar 26, 2024
272d3af
Replaced currentYearMonth with delegate
sirlag Mar 26, 2024
c47829c
Even more cleanup
sirlag Mar 26, 2024
254d800
cleaned up alignment modifiers
sirlag Mar 26, 2024
7a543e5
Click Handler and other refactors
sirlag Mar 26, 2024
d4a8c23
Removed Wrapped Content Height/Size/extra clips
sirlag Mar 26, 2024
202e156
Huge Refactor for CalendarDay
sirlag Mar 26, 2024
6003b9c
Merge remote-tracking branch 'origin/update-calendar' into update-cal…
sirlag Mar 26, 2024
248eeb8
Another cleanup attempt
sirlag Mar 26, 2024
08f55d2
Migrated to new mihon.feature.* module pattern
sirlag Mar 27, 2024
366a22e
Merge branch 'main' into update-calendar
sirlag Mar 27, 2024
38770d2
changed access modifier
sirlag Mar 27, 2024
1024cbd
A Bunch of changes from the next round of reviews
sirlag Mar 28, 2024
1b408b1
Cleanups
AntsyLich Mar 28, 2024
3ca646f
Cleanup 2
AntsyLich Mar 28, 2024
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
2 changes: 2 additions & 0 deletions app/src/main/java/eu/kanade/domain/DomainModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import mihon.domain.extensionrepo.interactor.ReplaceExtensionRepo
import mihon.domain.extensionrepo.interactor.UpdateExtensionRepo
import mihon.domain.extensionrepo.repository.ExtensionRepoRepository
import mihon.domain.extensionrepo.service.ExtensionRepoService
import mihon.domain.manga.interactor.GetUpcomingManga
import tachiyomi.data.category.CategoryRepositoryImpl
import tachiyomi.data.chapter.ChapterRepositoryImpl
import tachiyomi.data.history.HistoryRepositoryImpl
Expand Down Expand Up @@ -117,6 +118,7 @@ class DomainModule : InjektModule {
addFactory { GetMangaByUrlAndSourceId(get()) }
addFactory { GetManga(get()) }
addFactory { GetNextChapters(get(), get(), get()) }
addFactory { GetUpcomingManga(get()) }
addFactory { ResetViewerFlags(get()) }
addFactory { SetMangaChapterFlags(get()) }
addFactory { FetchInterval(get()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.CalendarMonth
import androidx.compose.material.icons.outlined.FlipToBack
import androidx.compose.material.icons.outlined.Refresh
import androidx.compose.material.icons.outlined.SelectAll
Expand Down Expand Up @@ -47,6 +48,7 @@ fun UpdateScreen(
onClickCover: (UpdatesItem) -> Unit,
onSelectAll: (Boolean) -> Unit,
onInvertSelection: () -> Unit,
onCalendarClicked: () -> Unit,
onUpdateLibrary: () -> Boolean,
onDownloadChapter: (List<UpdatesItem>, ChapterDownloadAction) -> Unit,
onMultiBookmarkClicked: (List<UpdatesItem>, bookmark: Boolean) -> Unit,
Expand All @@ -60,6 +62,7 @@ fun UpdateScreen(
Scaffold(
topBar = { scrollBehavior ->
UpdatesAppBar(
onCalendarClicked = { onCalendarClicked() },
onUpdateLibrary = { onUpdateLibrary() },
actionModeCounter = state.selected.size,
onSelectAll = { onSelectAll(true) },
Expand Down Expand Up @@ -126,6 +129,7 @@ fun UpdateScreen(

@Composable
private fun UpdatesAppBar(
onCalendarClicked: () -> Unit,
onUpdateLibrary: () -> Unit,
// For action mode
actionModeCounter: Int,
Expand All @@ -141,6 +145,11 @@ private fun UpdatesAppBar(
actions = {
AppBarActions(
persistentListOf(
AppBar.Action(
title = stringResource(MR.strings.action_view_upcoming),
icon = Icons.Outlined.CalendarMonth,
onClick = onCalendarClicked,
),
AppBar.Action(
title = stringResource(MR.strings.action_update_library),
icon = Icons.Outlined.Refresh,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import eu.kanade.tachiyomi.ui.manga.MangaScreen
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.updates.UpdatesScreenModel.Event
import kotlinx.coroutines.flow.collectLatest
import mihon.feature.upcoming.UpcomingScreen
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
Expand Down Expand Up @@ -72,6 +73,7 @@ object UpdatesTab : Tab {
val intent = ReaderActivity.newIntent(context, it.update.mangaId, it.update.chapterId)
context.startActivity(intent)
},
onCalendarClicked = { navigator.push(UpcomingScreen()) },
)

val onDismissDialog = { screenModel.setDialog(null) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ fun Long.toLocalDate(): LocalDate {
return LocalDate.ofInstant(Instant.ofEpochMilli(this), ZoneId.systemDefault())
}

fun Instant.toLocalDate(zoneId: ZoneId = ZoneId.systemDefault()): LocalDate {
return LocalDate.ofInstant(this, zoneId)
}

fun LocalDate.toRelativeString(
context: Context,
relative: Boolean = true,
Expand All @@ -56,14 +60,12 @@ fun LocalDate.toRelativeString(
difference.toInt().absoluteValue,
difference.toInt().absoluteValue,
)

difference < 1 -> context.stringResource(MR.strings.relative_time_today)
difference < 7 -> context.pluralStringResource(
MR.plurals.relative_time,
difference.toInt(),
difference.toInt(),
)

else -> dateFormat.format(this)
}
}
26 changes: 26 additions & 0 deletions app/src/main/java/mihon/feature/upcoming/UpcomingScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package mihon.feature.upcoming

import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import cafe.adriel.voyager.core.model.rememberScreenModel
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.ui.manga.MangaScreen

class UpcomingScreen : Screen() {

@Composable
override fun Content() {
val navigator = LocalNavigator.currentOrThrow

val screenModel = rememberScreenModel { UpcomingScreenModel() }
val state by screenModel.state.collectAsState()

UpcomingScreenContent(
state = state,
onClickUpcoming = { navigator.push(MangaScreen(it.id)) },
)
}
}
Loading