From 43c1acd1d5b2a84d033b700a4755860f95c3f6c8 Mon Sep 17 00:00:00 2001 From: rodvar Date: Fri, 22 Nov 2024 15:55:25 +1100 Subject: [PATCH] - fix main view controller not attached in ios causing shared ui not to progress (#70) - delete unnecessary platform spread controllers + di: we can assume default main controller is client controller --- .../bisq/mobile/client/MainApplication.kt | 3 +-- .../mobile/client/di/AndroidClientModule.kt | 22 ------------------ .../AndroidClientMainPresenter.kt | 18 --------------- .../node/presentation/NodeMainPresenter.kt | 5 ++-- bisqapps/iosClient/Podfile.lock | 4 ++-- bisqapps/iosClient/Pods/Manifest.lock | 4 ++-- .../LifecycleAwareComposeViewController.swift | 3 ++- .../bisq/mobile/client/di/ClientModule.kt | 15 ++++++++++++ .../bisq/mobile/presentation/MainPresenter.kt | 13 ++++++++++- .../presentation/di/PresentationModule.kt | 3 +-- .../presentation/IosClientMainPresenter.kt | 19 --------------- .../di/DependenciesProviderHelper.kt | 2 +- .../mobile/presentation/di/IosClientModule.kt | 23 ------------------- 13 files changed, 39 insertions(+), 95 deletions(-) delete mode 100644 bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidClientModule.kt delete mode 100644 bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/presentation/AndroidClientMainPresenter.kt delete mode 100644 bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/IosClientMainPresenter.kt delete mode 100644 bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/di/IosClientModule.kt diff --git a/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/MainApplication.kt b/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/MainApplication.kt index 6e3599a2..cdc0d6f3 100644 --- a/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/MainApplication.kt +++ b/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/MainApplication.kt @@ -1,7 +1,6 @@ package network.bisq.mobile.client import android.app.Application -import network.bisq.mobile.client.di.androidClientModule import network.bisq.mobile.client.di.clientModule import network.bisq.mobile.domain.di.domainModule import network.bisq.mobile.presentation.di.presentationModule @@ -15,7 +14,7 @@ class MainApplication: Application() { startKoin { androidContext(this@MainApplication) - modules(listOf(domainModule, presentationModule, clientModule, androidClientModule)) + modules(listOf(domainModule, presentationModule, clientModule)) } } } diff --git a/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidClientModule.kt b/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidClientModule.kt deleted file mode 100644 index 0cdb64b2..00000000 --- a/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidClientModule.kt +++ /dev/null @@ -1,22 +0,0 @@ -package network.bisq.mobile.client.di - -import network.bisq.mobile.android.node.main.bootstrap.ClientApplicationBootstrapFacade -import network.bisq.mobile.client.presentation.AndroidClientMainPresenter -import network.bisq.mobile.client.service.ApiRequestService -import network.bisq.mobile.domain.client.main.user_profile.ClientUserProfileServiceFacade -import network.bisq.mobile.domain.client.main.user_profile.UserProfileApiGateway -import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade -import network.bisq.mobile.domain.user_profile.UserProfileServiceFacade -import network.bisq.mobile.presentation.MainPresenter -import network.bisq.mobile.presentation.ui.AppPresenter -import org.koin.dsl.bind -import org.koin.dsl.module - -val androidClientModule = module { - single { ClientApplicationBootstrapFacade() } - - single { ApiRequestService(get(), "10.0.2.2") } - single { UserProfileApiGateway(get()) } - single { ClientUserProfileServiceFacade(get()) } - single { AndroidClientMainPresenter(get()) } bind AppPresenter::class -} diff --git a/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/presentation/AndroidClientMainPresenter.kt b/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/presentation/AndroidClientMainPresenter.kt deleted file mode 100644 index 11580bba..00000000 --- a/bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/presentation/AndroidClientMainPresenter.kt +++ /dev/null @@ -1,18 +0,0 @@ -package network.bisq.mobile.client.presentation - -import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade -import network.bisq.mobile.presentation.MainPresenter - -class AndroidClientMainPresenter( - private val applicationBootstrapFacade: ApplicationBootstrapFacade -) : MainPresenter() { - private var applicationServiceInited = false - override fun onViewAttached() { - super.onViewAttached() - - if (!applicationServiceInited) { - applicationServiceInited = true - applicationBootstrapFacade.initialize() - } - } -} \ No newline at end of file diff --git a/bisqapps/androidNode/src/androidMain/kotlin/network/bisq/mobile/android/node/presentation/NodeMainPresenter.kt b/bisqapps/androidNode/src/androidMain/kotlin/network/bisq/mobile/android/node/presentation/NodeMainPresenter.kt index c81e6c6b..cb65e446 100644 --- a/bisqapps/androidNode/src/androidMain/kotlin/network/bisq/mobile/android/node/presentation/NodeMainPresenter.kt +++ b/bisqapps/androidNode/src/androidMain/kotlin/network/bisq/mobile/android/node/presentation/NodeMainPresenter.kt @@ -10,11 +10,12 @@ class NodeMainPresenter( private val supplier: AndroidApplicationService.Supplier, private val androidMemoryReportService: AndroidMemoryReportService, private val applicationBootstrapFacade: ApplicationBootstrapFacade -) : MainPresenter() { +) : MainPresenter(applicationBootstrapFacade) { var applicationServiceInited = false override fun onViewAttached() { - super.onViewAttached() +// full override +// super.onViewAttached() if (!applicationServiceInited) { applicationServiceInited = true diff --git a/bisqapps/iosClient/Podfile.lock b/bisqapps/iosClient/Podfile.lock index 672a7cee..e5978153 100644 --- a/bisqapps/iosClient/Podfile.lock +++ b/bisqapps/iosClient/Podfile.lock @@ -13,8 +13,8 @@ EXTERNAL SOURCES: :path: "../shared/presentation" SPEC CHECKSUMS: - domain: 47abf0eea12f1e6f5b4f15c05dd23f437ec5478f - presentation: 55df2024e1ee347459ecf9349d6e1fde59450eef + domain: feb764d7802f6a414d3f649e95721d16a38d018e + presentation: 8c21a3748676af08d28227a02cad92c9a7eeb27a PODFILE CHECKSUM: e4e5bb187d8247572973af90a35b57b84c96b4c6 diff --git a/bisqapps/iosClient/Pods/Manifest.lock b/bisqapps/iosClient/Pods/Manifest.lock index 672a7cee..e5978153 100644 --- a/bisqapps/iosClient/Pods/Manifest.lock +++ b/bisqapps/iosClient/Pods/Manifest.lock @@ -13,8 +13,8 @@ EXTERNAL SOURCES: :path: "../shared/presentation" SPEC CHECKSUMS: - domain: 47abf0eea12f1e6f5b4f15c05dd23f437ec5478f - presentation: 55df2024e1ee347459ecf9349d6e1fde59450eef + domain: feb764d7802f6a414d3f649e95721d16a38d018e + presentation: 8c21a3748676af08d28227a02cad92c9a7eeb27a PODFILE CHECKSUM: e4e5bb187d8247572973af90a35b57b84c96b4c6 diff --git a/bisqapps/iosClient/iosClient/LifecycleAwareComposeViewController.swift b/bisqapps/iosClient/iosClient/LifecycleAwareComposeViewController.swift index 5916a3b3..1b3221a1 100644 --- a/bisqapps/iosClient/iosClient/LifecycleAwareComposeViewController.swift +++ b/bisqapps/iosClient/iosClient/LifecycleAwareComposeViewController.swift @@ -10,6 +10,7 @@ class LifecycleAwareComposeViewController: UIViewController { init(presenter: MainPresenter) { self.presenter = presenter super.init(nibName: nil, bundle: nil) + presenter.attachView(view: self) } required init?(coder: NSCoder) { @@ -31,7 +32,7 @@ class LifecycleAwareComposeViewController: UIViewController { name: UIApplication.didBecomeActiveNotification, object: nil) } - + @objc private func handleDidBecomeActive() { presenter.onResume() } diff --git a/bisqapps/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/di/ClientModule.kt b/bisqapps/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/di/ClientModule.kt index fe568b05..bcd07a8c 100644 --- a/bisqapps/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/di/ClientModule.kt +++ b/bisqapps/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/di/ClientModule.kt @@ -7,11 +7,19 @@ import io.ktor.serialization.kotlinx.json.json import kotlinx.serialization.json.Json import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.contextual +import network.bisq.mobile.android.node.main.bootstrap.ClientApplicationBootstrapFacade +import network.bisq.mobile.client.service.ApiRequestService +import network.bisq.mobile.domain.client.main.user_profile.ClientUserProfileServiceFacade +import network.bisq.mobile.domain.client.main.user_profile.UserProfileApiGateway +import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade +import network.bisq.mobile.domain.user_profile.UserProfileServiceFacade import network.bisq.mobile.utils.ByteArrayAsBase64Serializer import org.koin.dsl.module +// networking and services dependencies val clientModule = module { + single { HttpClient(CIO) { install(ContentNegotiation) { @@ -24,4 +32,11 @@ val clientModule = module { } } } + + + single { ClientApplicationBootstrapFacade() } + + single { ApiRequestService(get(), "10.0.2.2") } + single { UserProfileApiGateway(get()) } + single { ClientUserProfileServiceFacade(get()) } } \ No newline at end of file diff --git a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/MainPresenter.kt b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/MainPresenter.kt index 8adb2a96..041360a3 100644 --- a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/MainPresenter.kt +++ b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/MainPresenter.kt @@ -5,12 +5,13 @@ import co.touchlab.kermit.Logger import kotlinx.coroutines.flow.* import network.bisq.mobile.android.node.BuildNodeConfig import network.bisq.mobile.client.shared.BuildConfig +import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade import network.bisq.mobile.presentation.ui.AppPresenter /** * Main Presenter as an example of implementation for now. */ -open class MainPresenter() : BasePresenter(null), AppPresenter { +open class MainPresenter(private val applicationBootstrapFacade: ApplicationBootstrapFacade) : BasePresenter(null), AppPresenter { lateinit var navController: NavHostController private set @@ -23,6 +24,16 @@ open class MainPresenter() : BasePresenter(null), AppPresenter { private val _isContentVisible = MutableStateFlow(false) override val isContentVisible: StateFlow = _isContentVisible + private var applicationServiceInited = false + override fun onViewAttached() { + super.onViewAttached() + + if (!applicationServiceInited) { + applicationServiceInited = true + applicationBootstrapFacade.initialize() + } + } + // passthrough example // private val _greetingText: StateFlow = stateFlowFromRepository( // repositoryFlow = greetingRepository.data, diff --git a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/di/PresentationModule.kt b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/di/PresentationModule.kt index 3f5ca91b..1482abb4 100644 --- a/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/di/PresentationModule.kt +++ b/bisqapps/shared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/di/PresentationModule.kt @@ -1,6 +1,5 @@ package network.bisq.mobile.presentation.di -import androidx.navigation.NavController import androidx.navigation.NavHostController import network.bisq.mobile.presentation.MainPresenter import network.bisq.mobile.presentation.ui.AppPresenter @@ -20,7 +19,7 @@ val presentationModule = module { single(named("RootNavController")) { getKoin().getProperty("RootNavController") } single(named("TabNavController")) { getKoin().getProperty("TabNavController") } - single { MainPresenter() } bind AppPresenter::class + single { MainPresenter(get()) } bind AppPresenter::class single { SplashPresenter( diff --git a/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/IosClientMainPresenter.kt b/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/IosClientMainPresenter.kt deleted file mode 100644 index 5313bb18..00000000 --- a/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/IosClientMainPresenter.kt +++ /dev/null @@ -1,19 +0,0 @@ -package network.bisq.mobile.presentation - -import network.bisq.mobile.domain.data.repository.GreetingRepository -import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade - -@Suppress("UNCHECKED_CAST") -class IosClientMainPresenter( - private val applicationBootstrapFacade: ApplicationBootstrapFacade -) : MainPresenter() { - var applicationServiceInited = false - override fun onViewAttached() { - super.onViewAttached() - - if (!applicationServiceInited) { - applicationServiceInited = true - applicationBootstrapFacade.initialize() - } - } -} \ No newline at end of file diff --git a/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/di/DependenciesProviderHelper.kt b/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/di/DependenciesProviderHelper.kt index 0524df94..2058947f 100644 --- a/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/di/DependenciesProviderHelper.kt +++ b/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/di/DependenciesProviderHelper.kt @@ -14,7 +14,7 @@ class DependenciesProviderHelper { fun initKoin() { val instance = startKoin { - modules(listOf(domainModule, presentationModule, clientModule, iosClientModule)) + modules(listOf(domainModule, presentationModule, clientModule)) } koin = instance.koin diff --git a/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/di/IosClientModule.kt b/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/di/IosClientModule.kt deleted file mode 100644 index 6b14f6d4..00000000 --- a/bisqapps/shared/presentation/src/iosMain/kotlin/network/bisq/mobile/presentation/di/IosClientModule.kt +++ /dev/null @@ -1,23 +0,0 @@ -package network.bisq.mobile.presentation.di - -import network.bisq.mobile.android.node.main.bootstrap.ClientApplicationBootstrapFacade -import network.bisq.mobile.client.service.ApiRequestService -import network.bisq.mobile.domain.client.main.user_profile.ClientUserProfileServiceFacade -import network.bisq.mobile.domain.client.main.user_profile.UserProfileApiGateway -import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade -import network.bisq.mobile.domain.user_profile.UserProfileServiceFacade -import network.bisq.mobile.presentation.IosClientMainPresenter -import network.bisq.mobile.presentation.MainPresenter -import network.bisq.mobile.presentation.ui.AppPresenter -import org.koin.dsl.bind -import org.koin.dsl.module - -val iosClientModule = module { - single { ClientApplicationBootstrapFacade() } - - single { ApiRequestService(get(), "localhost") } - single { UserProfileApiGateway(get()) } - single { ClientUserProfileServiceFacade(get()) } - - single { IosClientMainPresenter(get()) } bind AppPresenter::class -}