-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(wip) Router push & pop new screen with viewModels integration
- Loading branch information
1 parent
e8d9bd5
commit 409148c
Showing
19 changed files
with
377 additions
and
49 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
9 changes: 0 additions & 9 deletions
9
androidApp/src/main/java/com/mirego/kmp/boilerplate/android/composables/Home.kt
This file was deleted.
Oops, something went wrong.
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
41 changes: 41 additions & 0 deletions
41
androidApp/src/main/java/com/mirego/kmp/boilerplate/android/composables/example/Example.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.mirego.kmp.boilerplate.android.composables.example | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.mirego.kmp.boilerplate.presentation.viewmodel.example.ExampleViewModel | ||
|
||
@Composable | ||
fun Example(viewModel: ExampleViewModel) { | ||
val exampleText: String by viewModel.exampleMessage.collectAsState(initial = "") | ||
val backButtonText: String by viewModel.backButtonText.collectAsState(initial = "") | ||
|
||
Box(modifier = Modifier.fillMaxSize(1.0f), contentAlignment = Alignment.Center) { | ||
Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
Text(text = exampleText) | ||
|
||
Spacer(modifier = Modifier.height(8.dp)) | ||
|
||
Button(onClick = viewModel::onBackButtonClick) { | ||
Text(text = backButtonText) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewExample() { | ||
Example(viewModel = ExampleViewModel.Preview) | ||
} |
41 changes: 41 additions & 0 deletions
41
androidApp/src/main/java/com/mirego/kmp/boilerplate/android/composables/home/Home.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.mirego.kmp.boilerplate.android.composables.home | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.mirego.kmp.boilerplate.android.composables.Greeting | ||
import com.mirego.kmp.boilerplate.presentation.viewmodel.home.HomeViewModel | ||
|
||
@Composable | ||
fun Home(viewModel: HomeViewModel) { | ||
Box(modifier = Modifier.fillMaxSize(1.0f), contentAlignment = Alignment.Center) { | ||
Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
Greeting(textFlow = viewModel.greetingMessage) | ||
|
||
Spacer(modifier = Modifier.height(8.dp)) | ||
|
||
val buttonText: String by viewModel.buttonText.collectAsState("") | ||
|
||
Button(onClick = viewModel::onButtonClick) { | ||
Text(text = buttonText) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewHome() { | ||
Home(viewModel = HomeViewModel.Preview) | ||
} |
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
78 changes: 78 additions & 0 deletions
78
iosApp/iosApp.xcworkspace/xcshareddata/xcschemes/iosApp.xcscheme
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1330" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "7555FF7A242A565900829871" | ||
BuildableName = "iosApp.app" | ||
BlueprintName = "iosApp" | ||
ReferencedContainer = "container:iosApp.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "7555FF7A242A565900829871" | ||
BuildableName = "iosApp.app" | ||
BlueprintName = "iosApp" | ||
ReferencedContainer = "container:iosApp.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "7555FF7A242A565900829871" | ||
BuildableName = "iosApp.app" | ||
BlueprintName = "iosApp" | ||
ReferencedContainer = "container:iosApp.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import SwiftUI | ||
import shared | ||
|
||
struct Example: View { | ||
|
||
private let viewModel: ExampleViewModel | ||
|
||
@ObservedObject var message: ObservableFlowWrapper<NSString> | ||
@ObservedObject var backButtonText: ObservableFlowWrapper<NSString> | ||
|
||
init(viewModel: ExampleViewModel) { | ||
self.viewModel = viewModel | ||
|
||
message = ObservableFlowWrapper<NSString>(viewModel.exampleMessage, initial: "") | ||
backButtonText = ObservableFlowWrapper<NSString>(viewModel.backButtonText, initial: "") | ||
} | ||
|
||
var body: some View { | ||
VStack(alignment: .center, spacing: 16) { | ||
Text("\(message.value)") | ||
|
||
Button("\(backButtonText.value)", action: viewModel.onBackButtonClick) | ||
} | ||
} | ||
|
||
} | ||
|
||
struct Example_Previews: PreviewProvider { | ||
static var previews: some View { | ||
Example(viewModel: ExampleViewModelPreview()) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import SwiftUI | ||
import shared | ||
|
||
struct Home: View { | ||
|
||
private let viewModel: HomeViewModel | ||
|
||
@ObservedObject var message: ObservableFlowWrapper<NSString> | ||
@ObservedObject var buttonText: ObservableFlowWrapper<NSString> | ||
|
||
init(viewModel: HomeViewModel) { | ||
self.viewModel = viewModel | ||
|
||
message = ObservableFlowWrapper<NSString>(viewModel.greetingMessage, initial: "") | ||
buttonText = ObservableFlowWrapper<NSString>(viewModel.buttonText, initial: "") | ||
} | ||
|
||
var body: some View { | ||
VStack(alignment: .center, spacing: 16) { | ||
Text("\(message.value)") | ||
|
||
Button("\(buttonText.value)", action: viewModel.onButtonClick) | ||
} | ||
} | ||
} | ||
|
||
struct Home_Previews: PreviewProvider { | ||
static var previews: some View { | ||
Home(viewModel: HomeViewModelPreview()) | ||
} | ||
} |
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
Oops, something went wrong.