-
Notifications
You must be signed in to change notification settings - Fork 1
demo app for settings opener example #1
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
Open
livotov
wants to merge
18
commits into
feature/oskit-compose-4.1.0
Choose a base branch
from
dev/settings_screen_opener_example
base: feature/oskit-compose-4.1.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d562720
demo app for settings opener example
0e83992
ios tweaks
42da0bc
Merge remote-tracking branch 'origin/feature/oskit-compose-4.1.0' int…
1eac60f
merge conflict fix
bd65f95
Merge branch 'feature/oskit-compose-4.1.0' into dev/settings_screen_o…
ryanmitchener eb21f99
Updated imported oskit-version
ryanmitchener 2966498
Merge branch 'feature/oskit-compose-4.1.0' into dev/settings_screen_o…
ryanmitchener f80d70a
Merge branch 'feature/oskit-compose-4.1.0' into dev/settings_screen_o…
ryanmitchener b7b3a90
PR feedback
3943d58
Merge remote-tracking branch 'origin/dev/settings_screen_opener_examp…
066b528
Merge branch 'feature/oskit-compose-4.1.0' into dev/settings_screen_o…
cf7cdeb
demo app for settings opener update
3393b05
Merge branch 'release/oskit-compose-4.1.0' into dev/settings_screen_o…
ryanmitchener 0ec03d0
Fixes for different targets
ryanmitchener ef549d2
More fixes
ryanmitchener 015aafe
Minor rename
ryanmitchener 44810ef
Minor update
ryanmitchener d149d4c
Merge branch 'feature/oskit-compose-4.1.0' into dev/settings_screen_o…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
65 changes: 65 additions & 0 deletions
65
composeApp/src/commonMain/kotlin/ui/settingsOpenerExample/SettingsOpenerExampleScreen.kt
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
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.foundation.layout.padding | ||
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") { | ||
Column( | ||
modifier = Modifier.fillMaxSize(), | ||
verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterVertically), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
|
||
Button( | ||
content = { Text("Open App Settings") }, | ||
onClick = interactor::appSettingsClicked | ||
) | ||
ResultLabel(state.appSettingsOutcome) | ||
|
||
Button( | ||
content = { Text("Open System Settings") }, | ||
onClick = interactor::systemSettingsClicked | ||
) | ||
ResultLabel(state.systemSettingsOutcome) | ||
|
||
Button( | ||
content = { Text("Open Bluetooth Settings") }, | ||
onClick = interactor::bluetoothSettingsClicked | ||
) | ||
ResultLabel(state.btSettingsOutcome) | ||
|
||
Button( | ||
content = { Text("Open Location Settings") }, | ||
onClick = interactor::locationSettingsClicked | ||
) | ||
ResultLabel(state.locationSettingsOutcome) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun ResultLabel(message: String?) { | ||
if (!message.isNullOrBlank()) { | ||
Text("Result is $message", modifier = Modifier.padding(top = 4.dp, bottom = 16.dp)) | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...App/src/commonMain/kotlin/ui/settingsOpenerExample/SettingsOpenerExampleViewInteractor.kt
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package ui.settingsOpenerExample | ||
|
||
import com.outsidesource.oskitkmp.interactor.Interactor | ||
import com.outsidesource.oskitkmp.systemui.IKmpSettingsScreenOpener | ||
import com.outsidesource.oskitkmp.systemui.SettingsScreenType | ||
import coordinator.AppCoordinator | ||
import kotlinx.coroutines.launch | ||
|
||
data class SettingsOpenerExampleViewState( | ||
val appSettingsOutcome: String? = null, | ||
val systemSettingsOutcome: String? = null, | ||
val btSettingsOutcome: String? = null, | ||
val locationSettingsOutcome: String? = null, | ||
) | ||
|
||
class SettingsOpenerExampleViewInteractor( | ||
private val coordinator: AppCoordinator, | ||
private val settingsScreenOpener: IKmpSettingsScreenOpener | ||
) : Interactor<SettingsOpenerExampleViewState>( | ||
initialState = SettingsOpenerExampleViewState() | ||
) { | ||
|
||
fun appSettingsClicked() { | ||
interactorScope.launch { | ||
val res = settingsScreenOpener.open(SettingsScreenType.App) | ||
update { state -> | ||
state.copy( | ||
appSettingsOutcome = res.toString() | ||
) | ||
} | ||
} | ||
} | ||
|
||
fun systemSettingsClicked() { | ||
interactorScope.launch { | ||
val res = settingsScreenOpener.open(SettingsScreenType.SystemSettings) | ||
update { state -> | ||
state.copy( | ||
systemSettingsOutcome = res.toString() | ||
) | ||
} | ||
} | ||
} | ||
|
||
fun bluetoothSettingsClicked() { | ||
interactorScope.launch { | ||
val res = settingsScreenOpener.open(SettingsScreenType.Bluetooth) | ||
update { state -> | ||
state.copy( | ||
btSettingsOutcome = res.toString() | ||
) | ||
} | ||
} | ||
} | ||
|
||
fun locationSettingsClicked() { | ||
interactorScope.launch { | ||
val res = settingsScreenOpener.open(SettingsScreenType.Location) | ||
update { state -> | ||
state.copy( | ||
locationSettingsOutcome = res.toString() | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.