From f10528d79ed77b19a34720d1c6bf3e14dc3f761e Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Fri, 1 Mar 2024 15:33:00 +0530 Subject: [PATCH] Extract out presenter factories in `AppPresenter` to appropriate files --- .../rss/reader/about/AboutPresenter.kt | 6 ++ .../sasikanth/rss/reader/app/AppPresenter.kt | 67 +++---------------- .../reader/bookmarks/BookmarksPresenter.kt | 7 ++ .../rss/reader/feed/FeedPresenter.kt | 7 ++ .../rss/reader/home/HomePresenter.kt | 10 +++ .../rss/reader/reader/ReaderPresenter.kt | 7 ++ .../rss/reader/search/SearchPresenter.kt | 7 ++ .../rss/reader/settings/SettingsPresenter.kt | 7 ++ 8 files changed, 59 insertions(+), 59 deletions(-) diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/about/AboutPresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/about/AboutPresenter.kt index 382f6776c..deeeb6c01 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/about/AboutPresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/about/AboutPresenter.kt @@ -20,6 +20,12 @@ import com.arkivanov.decompose.ComponentContext import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject +internal typealias AboutPresenterFactory = + ( + ComponentContext, + goBack: () -> Unit, + ) -> AboutPresenter + @Inject class AboutPresenter( @Assisted componentContext: ComponentContext, diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/app/AppPresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/app/AppPresenter.kt index cd5c8bc03..c3420ca77 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/app/AppPresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/app/AppPresenter.kt @@ -31,18 +31,18 @@ import com.arkivanov.essenty.instancekeeper.InstanceKeeper import com.arkivanov.essenty.instancekeeper.getOrCreate import com.arkivanov.essenty.lifecycle.coroutines.coroutineScope import com.arkivanov.essenty.lifecycle.doOnStart -import dev.sasikanth.rss.reader.about.AboutPresenter -import dev.sasikanth.rss.reader.bookmarks.BookmarksPresenter +import dev.sasikanth.rss.reader.about.AboutPresenterFactory +import dev.sasikanth.rss.reader.bookmarks.BookmarksPresenterFactory import dev.sasikanth.rss.reader.di.scopes.ActivityScope -import dev.sasikanth.rss.reader.feed.FeedPresenter -import dev.sasikanth.rss.reader.home.HomePresenter +import dev.sasikanth.rss.reader.feed.FeedPresenterFactory +import dev.sasikanth.rss.reader.home.HomePresenterFactory import dev.sasikanth.rss.reader.platform.LinkHandler -import dev.sasikanth.rss.reader.reader.ReaderPresenter +import dev.sasikanth.rss.reader.reader.ReaderPresenterFactory import dev.sasikanth.rss.reader.refresh.LastUpdatedAt import dev.sasikanth.rss.reader.repository.RssRepository import dev.sasikanth.rss.reader.repository.SettingsRepository -import dev.sasikanth.rss.reader.search.SearchPresenter -import dev.sasikanth.rss.reader.settings.SettingsPresenter +import dev.sasikanth.rss.reader.search.SearchPresentFactory +import dev.sasikanth.rss.reader.settings.SettingsPresenterFactory import dev.sasikanth.rss.reader.util.DispatchersProvider import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob @@ -53,57 +53,6 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.Serializable import me.tatarka.inject.annotations.Inject -private typealias HomePresenterFactory = - ( - ComponentContext, - openSearch: () -> Unit, - openBookmarks: () -> Unit, - openSettings: () -> Unit, - openPost: (String) -> Unit, - openFeedInfo: (String) -> Unit, - ) -> HomePresenter - -private typealias SearchPresentFactory = - ( - ComponentContext, - goBack: () -> Unit, - openPost: (String) -> Unit, - ) -> SearchPresenter - -private typealias BookmarkPresenterFactory = - ( - ComponentContext, - goBack: () -> Unit, - openReaderView: (String) -> Unit, - ) -> BookmarksPresenter - -private typealias SettingsPresenterFactory = - ( - ComponentContext, - goBack: () -> Unit, - openAbout: () -> Unit, - ) -> SettingsPresenter - -private typealias AboutPresenterFactory = - ( - ComponentContext, - goBack: () -> Unit, - ) -> AboutPresenter - -private typealias ReaderPresenterFactory = - ( - postLink: String, - ComponentContext, - goBack: () -> Unit, - ) -> ReaderPresenter - -private typealias FeedPresenterFactory = - ( - feedLink: String, - ComponentContext, - dismiss: () -> Unit, - ) -> FeedPresenter - @Inject @ActivityScope class AppPresenter( @@ -111,7 +60,7 @@ class AppPresenter( private val dispatchersProvider: DispatchersProvider, private val homePresenter: HomePresenterFactory, private val searchPresenter: SearchPresentFactory, - private val bookmarksPresenter: BookmarkPresenterFactory, + private val bookmarksPresenter: BookmarksPresenterFactory, private val settingsPresenter: SettingsPresenterFactory, private val aboutPresenter: AboutPresenterFactory, private val readerPresenter: ReaderPresenterFactory, diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/bookmarks/BookmarksPresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/bookmarks/BookmarksPresenter.kt index fc3805f28..28e4a452b 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/bookmarks/BookmarksPresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/bookmarks/BookmarksPresenter.kt @@ -39,6 +39,13 @@ import kotlinx.coroutines.launch import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject +internal typealias BookmarksPresenterFactory = + ( + ComponentContext, + goBack: () -> Unit, + openReaderView: (String) -> Unit, + ) -> BookmarksPresenter + @Inject class BookmarksPresenter( dispatchersProvider: DispatchersProvider, diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feed/FeedPresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feed/FeedPresenter.kt index 18fc7d255..2c9f6e96a 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feed/FeedPresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feed/FeedPresenter.kt @@ -36,6 +36,13 @@ import kotlinx.coroutines.launch import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject +internal typealias FeedPresenterFactory = + ( + feedLink: String, + ComponentContext, + dismiss: () -> Unit, + ) -> FeedPresenter + @Inject class FeedPresenter( dispatchersProvider: DispatchersProvider, diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt index a100db5cd..c0695d173 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/HomePresenter.kt @@ -69,6 +69,16 @@ import kotlinx.datetime.Instant import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject +internal typealias HomePresenterFactory = + ( + ComponentContext, + openSearch: () -> Unit, + openBookmarks: () -> Unit, + openSettings: () -> Unit, + openPost: (String) -> Unit, + openFeedInfo: (String) -> Unit, + ) -> HomePresenter + @Inject @OptIn(ExperimentalCoroutinesApi::class) class HomePresenter( diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/reader/ReaderPresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/reader/ReaderPresenter.kt index 927c4ae6f..b6e3848e6 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/reader/ReaderPresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/reader/ReaderPresenter.kt @@ -41,6 +41,13 @@ import kotlinx.coroutines.withContext import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject +internal typealias ReaderPresenterFactory = + ( + postLink: String, + ComponentContext, + goBack: () -> Unit, + ) -> ReaderPresenter + @Inject class ReaderPresenter( dispatchersProvider: DispatchersProvider, diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/search/SearchPresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/search/SearchPresenter.kt index 9af3cde34..1a6c91c59 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/search/SearchPresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/search/SearchPresenter.kt @@ -50,6 +50,13 @@ import kotlinx.coroutines.launch import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject +internal typealias SearchPresentFactory = + ( + ComponentContext, + goBack: () -> Unit, + openPost: (String) -> Unit, + ) -> SearchPresenter + @Inject class SearchPresenter( rssRepository: RssRepository, diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/settings/SettingsPresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/settings/SettingsPresenter.kt index 125c3c1a6..d510b77cf 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/settings/SettingsPresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/settings/SettingsPresenter.kt @@ -40,6 +40,13 @@ import kotlinx.coroutines.launch import me.tatarka.inject.annotations.Assisted import me.tatarka.inject.annotations.Inject +internal typealias SettingsPresenterFactory = + ( + ComponentContext, + goBack: () -> Unit, + openAbout: () -> Unit, + ) -> SettingsPresenter + @Inject class SettingsPresenter( dispatchersProvider: DispatchersProvider,