Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
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 composeApp/src/androidMain/kotlin/PlatformDI.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import android.content.Context
import com.outsidesource.oskitkmp.storage.KmpKvStore
import com.outsidesource.oskitkmp.systemui.KmpSettingsScreen
import org.koin.dsl.bind
import org.koin.dsl.module
import service.swift.ISwiftExampleService
Expand All @@ -11,4 +12,5 @@ actual fun platformModule(platformContext: PlatformContext) = module {
single { platformContext.context }
single { NoOpSwiftExampleService() } bind ISwiftExampleService::class
single { KmpKvStore(appContext = get()) }
single { KmpSettingsScreen(context = get()) } bind KmpSettingsScreen::class
}
2 changes: 2 additions & 0 deletions composeApp/src/commonMain/kotlin/DI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import ui.file.FileSystemViewInteractor
import ui.home.HomeViewInteractor
import ui.iosServices.IOSServicesScreenViewInteractor
import ui.popups.PopupsScreenViewInteractor
import ui.settingsOpenerExample.SettingsOpenerExampleViewInteractor
import ui.viewStateExample.ViewStateExampleViewInteractor

fun initKoin(
Expand Down Expand Up @@ -59,4 +60,5 @@ fun commonModule() = module {
factory { IOSServicesScreenViewInteractor(get()) }
factory { CapabilityScreenViewInteractor(get()) }
factory { ColorPickerViewInteractor() }
factory { SettingsOpenerExampleViewInteractor(get(), get()) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ class AppCoordinator(): Coordinator(
fun widgetsClicked() = push(Route.Widgets)
fun capabilityClicked() = push(Route.Capability)
fun colorPickerClicked() = push(Route.ColorPicker)
fun settingsOpenerExampleClicked() = push(Route.SettingsOpenerExample)
fun htmlDemoClicked() = push(Route.WebDemo)
}
1 change: 1 addition & 0 deletions composeApp/src/commonMain/kotlin/ui/Route.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sealed class Route(
data object Widgets: Route(webRoutePath = "/widgets")
data object Capability : Route(webRoutePath = "/capability")
data object ColorPicker : Route(webRoutePath = "/color-picker")
data object SettingsOpenerExample: Route(webRoutePath = "/settings-opener")
data object WebDemo : Route(webRoutePath = "/web-demo")

companion object {
Expand Down
2 changes: 2 additions & 0 deletions composeApp/src/commonMain/kotlin/ui/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import ui.popups.PopupsScreen
import ui.viewStateExample.ViewStateExampleScreen
import ui.htmlDemo.HtmlDemoScreen
import ui.widgets.WidgetsScreen
import ui.settingsOpenerExample.SettingsOpenerExampleScreen

@Composable
fun App(
Expand Down Expand Up @@ -53,6 +54,7 @@ fun App(
is Route.Widgets -> WidgetsScreen()
is Route.Capability -> CapabilityScreen()
is Route.ColorPicker -> ColorPickerScreen()
is Route.SettingsOpenerExample -> SettingsOpenerExampleScreen()
is Route.WebDemo -> HtmlDemoScreen(
transitionDirection = if (it == interactor.getActiveRoute()) {
RouteTransitionDirection.In
Expand Down
4 changes: 4 additions & 0 deletions composeApp/src/commonMain/kotlin/ui/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ fun HomeScreen(
content = { Text("Color Picker") },
onClick = interactor::colorPickerButtonClicked,
)
Button(
content = { Text("App & System Settings Opener") },
onClick = interactor::settingsOpenerExampleButtonClicked,
)
Button(
content = { Text(rememberKmpString(Strings.iosServices)) },
onClick = interactor::iosServicesButtonClicked,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class HomeViewInteractor(
coordinator.colorPickerClicked()
}

fun settingsOpenerExampleButtonClicked() {
coordinator.settingsOpenerExampleClicked()
}

fun htmlDemoButtonClicked() {
coordinator.htmlDemoClicked()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package ui.settingsOpenerExample

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import ui.common.Screen
import com.outsidesource.oskitcompose.interactor.collectAsState
import com.outsidesource.oskitcompose.lib.rememberInjectForRoute
import ui.viewStateExample.ViewStateExampleViewInteractor

@Composable
fun SettingsOpenerExampleScreen(
interactor: SettingsOpenerExampleViewInteractor = rememberInjectForRoute()
) {
val state = interactor.collectAsState()

Screen("Settings Opener Example") {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterVertically),
horizontalAlignment = Alignment.CenterHorizontally,
) {

Button(
content = { Text("Open App Settings") },
onClick = interactor::appSettingsClicked
)

Button(
content = { Text("Open System Settings") },
onClick = interactor::systemSettingsClicked
)

Button(
content = { Text("Open Bluetooth Settings") },
onClick = interactor::bluetoothSettingsClicked
)

Button(
content = { Text("Open Location Settings") },
onClick = interactor::locationSettingsClicked
)

Button(
content = { Text("Pop To Home") },
onClick = interactor::popToHome
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ui.settingsOpenerExample

import coordinator.AppCoordinator
import com.outsidesource.oskitkmp.interactor.Interactor
import com.outsidesource.oskitkmp.systemui.KmpSettingsScreen
import com.outsidesource.oskitkmp.systemui.SettingsScreenType
import kotlinx.coroutines.launch

data class SettingsOpenerExampleViewState(
val text: Boolean = true
)

class SettingsOpenerExampleViewInteractor(
private val coordinator: AppCoordinator,
private val screenOpener: KmpSettingsScreen
): Interactor<SettingsOpenerExampleViewState>(
initialState = SettingsOpenerExampleViewState()
) {

override fun computed(state: SettingsOpenerExampleViewState): SettingsOpenerExampleViewState {
return state
}

fun popToHome() = coordinator.popToHome()

fun appSettingsClicked() {
interactorScope.launch {
screenOpener.open(SettingsScreenType.App)
}
}

fun systemSettingsClicked() {
interactorScope.launch {
screenOpener.open(SettingsScreenType.SystemSettings)
}
}

fun bluetoothSettingsClicked() {
interactorScope.launch {
screenOpener.open(SettingsScreenType.Bluetooth)
}
}

fun locationSettingsClicked() {
interactorScope.launch {
screenOpener.open(SettingsScreenType.Location)
}
}
}
3 changes: 3 additions & 0 deletions composeApp/src/desktopMain/kotlin/PlatformDI.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

import com.outsidesource.oskitkmp.storage.KmpKvStore
import org.koin.dsl.bind
import com.outsidesource.oskitkmp.systemui.KmpSettingsScreen
import org.koin.dsl.bind
import org.koin.dsl.module
import service.swift.ISwiftExampleService
import service.swift.NoOpSwiftExampleService
Expand All @@ -10,4 +12,5 @@ actual class PlatformContext
actual fun platformModule(platformContext: PlatformContext) = module {
single { NoOpSwiftExampleService() } bind ISwiftExampleService::class
single { KmpKvStore(appName = "OSKit-Example-App") }
single { KmpSettingsScreen() } bind KmpSettingsScreen::class
}
2 changes: 2 additions & 0 deletions composeApp/src/iosMain/kotlin/PlatformDI.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.outsidesource.oskitkmp.storage.KmpKvStore
import com.outsidesource.oskitkmp.systemui.KmpSettingsScreen
import org.koin.dsl.bind
import org.koin.dsl.module
import service.swift.ISwiftExampleService
Expand All @@ -11,6 +12,7 @@ private val koin = initKoin(

actual fun platformModule(platformContext: PlatformContext) = module {
single { KmpKvStore() }
single { KmpSettingsScreen() }
}

fun loadKoinSwiftModules(
Expand Down
3 changes: 3 additions & 0 deletions composeApp/src/wasmJsMain/kotlin/PlatformDI.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import com.outsidesource.oskitkmp.storage.KmpKvStore
import com.outsidesource.oskitkmp.storage.WasmKmpKvStoreType
import org.koin.dsl.bind
import com.outsidesource.oskitkmp.systemui.KmpSettingsScreen
import org.koin.dsl.bind
import org.koin.dsl.module
import service.swift.ISwiftExampleService
import service.swift.NoOpSwiftExampleService
Expand All @@ -10,4 +12,5 @@ actual object PlatformContext
actual fun platformModule(platformContext: PlatformContext) = module {
single { NoOpSwiftExampleService() } bind ISwiftExampleService::class
single { KmpKvStore(type = WasmKmpKvStoreType.LocalStorage) }
single { KmpSettingsScreen() } bind KmpSettingsScreen::class
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kotlinxCoroutinesCore = "1.10.2"
kotlinxDatetime = "0.6.1"
okio = "3.9.1"
oskitCompose = "4.1.0"
oskitKmp = "5.0.0"
oskitKmp = "5.1.0"
skie = "0.10.1"
ui = "1.8.1"
material-icons = "1.7.3"
Expand Down