-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make root navigation accessible for all MP presenters (#68)
* - remove showcase example repository from main presenter and move init logs to init * - make root nav controller accessible to all presenters for ease of MultiPlatform navigation
- Loading branch information
Showing
14 changed files
with
55 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
.../androidMain/kotlin/network/bisq/mobile/client/presentation/AndroidClientMainPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 22 additions & 26 deletions
48
...ared/presentation/src/commonMain/kotlin/network/bisq/mobile/presentation/MainPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,50 @@ | ||
package network.bisq.mobile.presentation | ||
|
||
import androidx.navigation.NavHostController | ||
import co.touchlab.kermit.Logger | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.flow.* | ||
import kotlinx.coroutines.launch | ||
import network.bisq.mobile.android.node.BuildNodeConfig | ||
import network.bisq.mobile.client.shared.BuildConfig | ||
import network.bisq.mobile.domain.data.BackgroundDispatcher | ||
import network.bisq.mobile.domain.data.model.Greeting | ||
import network.bisq.mobile.domain.data.repository.GreetingRepository | ||
import network.bisq.mobile.presentation.ui.AppPresenter | ||
|
||
/** | ||
* Main Presenter as an example of implementation for now. | ||
*/ | ||
open class MainPresenter(private val greetingRepository: GreetingRepository<Greeting>) : BasePresenter(null), AppPresenter { | ||
open class MainPresenter() : BasePresenter(null), AppPresenter { | ||
lateinit var navController: NavHostController | ||
private set | ||
|
||
override fun setNavController(controller: NavHostController) { | ||
navController = controller | ||
} | ||
|
||
private val log = Logger.withTag(this::class.simpleName ?: "MainPresenter") | ||
// Observable state | ||
private val _isContentVisible = MutableStateFlow(false) | ||
override val isContentVisible: StateFlow<Boolean> = _isContentVisible | ||
|
||
// passthrough example | ||
private val _greetingText: StateFlow<String> = stateFlowFromRepository( | ||
repositoryFlow = greetingRepository.data, | ||
transform = { it?.greet() ?: "" }, | ||
initialValue = "Welcome!" | ||
) | ||
|
||
override val greetingText: StateFlow<String> = _greetingText | ||
// private val _greetingText: StateFlow<String> = stateFlowFromRepository( | ||
// repositoryFlow = greetingRepository.data, | ||
// transform = { it?.greet() ?: "" }, | ||
// initialValue = "Welcome!" | ||
// ) | ||
// override val greetingText: StateFlow<String> = _greetingText | ||
|
||
init { | ||
CoroutineScope(BackgroundDispatcher).launch { | ||
greetingRepository.create(Greeting()) | ||
} | ||
log.i { "Shared Version: ${BuildConfig.SHARED_LIBS_VERSION}" } | ||
log.i { "iOS Client Version: ${BuildConfig.IOS_APP_VERSION}" } | ||
log.i { "Android Client Version: ${BuildConfig.IOS_APP_VERSION}" } | ||
log.i { "Android Node Version: ${BuildNodeConfig.APP_VERSION}" } | ||
// CoroutineScope(BackgroundDispatcher).launch { | ||
// greetingRepository.create(Greeting()) | ||
// } | ||
} | ||
|
||
// Toggle action | ||
override fun toggleContentVisibility() { | ||
_isContentVisible.value = !_isContentVisible.value | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
log.i { "Shared Version: ${BuildConfig.SHARED_LIBS_VERSION}" } | ||
log.i { "iOS Client Version: ${BuildConfig.IOS_APP_VERSION}" } | ||
log.i { "Android Client Version: ${BuildConfig.IOS_APP_VERSION}" } | ||
log.i { "Android Node Version: ${BuildNodeConfig.APP_VERSION}" } | ||
} | ||
|
||
override fun onPause() { | ||
super.onPause() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters