Skip to content

Commit

Permalink
Android stuff + remove stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierPineau committed Oct 26, 2023
1 parent 253c946 commit 89497ea
Show file tree
Hide file tree
Showing 24 changed files with 107 additions and 189 deletions.
1 change: 1 addition & 0 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ android {
dependencies {
implementation(project(":shared"))

implementation(libs.android.splash)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.activity.compose)

Expand Down
23 changes: 0 additions & 23 deletions androidApp/src/main/java/com/mirego/kmp/boilerplate/Greeting.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.mirego.kmp.boilerplate.app
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import com.mirego.kmp.boilerplate.app.ui.application.ApplicationView
import com.mirego.kmp.boilerplate.bootstrap.Bootstrapper
Expand All @@ -21,6 +22,7 @@ class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
ApplicationView(applicationViewModel = viewModel)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.mirego.kmp.boilerplate.app.bootstrap

import android.content.Context
import com.mirego.kmp.boilerplate.BuildConfig
import com.mirego.kmp.boilerplate.app.resources.AndroidImageProvider
import com.mirego.kmp.boilerplate.bootstrap.AppEnvironment
import com.mirego.kmp.boilerplate.bootstrap.Bootstrap
import com.mirego.kmp.boilerplate.common.BuildConfig
import com.mirego.trikot.kword.android.AndroidKWord
import com.mirego.trikot.viewmodels.declarative.configuration.DefaultTextStyleProvider
import com.mirego.trikot.viewmodels.declarative.configuration.TrikotViewModelDeclarative
import java.util.Locale
import java.util.*

class AndroidBootstrap(context: Context) : Bootstrap {

Expand All @@ -27,7 +28,8 @@ class AndroidBootstrap(context: Context) : Bootstrap {
}

TrikotViewModelDeclarative.initialize(
imageProvider = AndroidImageProvider()
imageProvider = AndroidImageProvider(),
textStyleProvider = DefaultTextStyleProvider()
)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mirego.kmp.boilerplate.app.bootstrap

import android.content.Context
import com.mirego.kmp.boilerplate.BuildConfig
import com.mirego.kmp.boilerplate.bootstrap.AppInformation
import com.mirego.kmp.boilerplate.common.BuildConfig
import com.mirego.kmp.boilerplate.model.Language
import com.mirego.kmp.boilerplate.model.Locale

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.mirego.kmp.boilerplate.app.ui.application

import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.tooling.preview.Preview
import com.mirego.kmp.boilerplate.app.ui.preview.PreviewProvider
import com.mirego.kmp.boilerplate.app.ui.root.RootView
import com.mirego.kmp.boilerplate.viewmodel.application.ApplicationViewModel
import com.mirego.trikot.viewmodels.declarative.compose.extensions.observeAsState
Expand All @@ -11,3 +13,11 @@ fun ApplicationView(applicationViewModel: ApplicationViewModel) {
val viewModel: ApplicationViewModel by applicationViewModel.observeAsState()
RootView(rootViewModel = viewModel.rootViewModel)
}

@Preview
@Composable
fun PreviewApplicationView() {
PreviewProvider {
ApplicationView(applicationViewModel = it.createApplication())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.mirego.kmp.boilerplate.app.ui.preview

import androidx.compose.runtime.Composable
import com.mirego.kmp.boilerplate.BuildConfig
import com.mirego.kmp.boilerplate.app.resources.AndroidImageProvider
import com.mirego.kmp.boilerplate.viewmodel.factory.ViewModelFactoryPreview
import com.mirego.trikot.kword.android.PreviewI18N
import com.mirego.trikot.viewmodels.declarative.configuration.TrikotViewModelDeclarative

@Composable
fun PreviewProvider(content: @Composable (ViewModelFactoryPreview) -> Unit) {
TrikotViewModelDeclarative.initialize(AndroidImageProvider())
val viewModelFactoryPreview = ViewModelFactoryPreview(
i18N = PreviewI18N(BuildConfig.KWORD_TRANSLATION_FILE_PATH)
)

content(viewModelFactoryPreview)
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
package com.mirego.kmp.boilerplate.app.ui.root

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import com.mirego.kmp.boilerplate.app.ui.application.ApplicationView
import com.mirego.kmp.boilerplate.app.ui.preview.PreviewProvider
import com.mirego.kmp.boilerplate.viewmodel.root.RootViewModel
import com.mirego.trikot.viewmodels.declarative.compose.extensions.observeAsState

@Composable
fun RootView(rootViewModel: RootViewModel) {
val viewModel: RootViewModel by rootViewModel.observeAsState()
Text(text = "Hi")
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.White)
) {
Text(text = "Hi")
}
}

@Preview
@Composable
fun PreviewRootView() {
PreviewProvider {
RootView(rootViewModel = it.createRoot())
}
}
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
androidComposeCompiler = "1.5.3"
androidGradlePlugin = "8.1.2"
android-splash = "1.0.1"
androidxActivityCompose = "1.8.0"
androidxAppcompat = "1.6.1"
androidxComposeBom = "2023.10.01"
Expand All @@ -17,6 +18,7 @@ ktlint = "11.6.1"
trikot = "5.2.0"

[libraries]
android-splash = { module = "androidx.core:core-splashscreen", version.ref = "android-splash" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidxActivityCompose" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppcompat" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidxComposeBom" }
Expand All @@ -26,9 +28,9 @@ androidx-compose-material = { group = "androidx.compose.material", name = "mater
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-annotations = { module = "io.insert-koin:koin-annotations", version.ref = "koin_ksp" }
ksp-koinCompiler = { module = "io.insert-koin:koin-ksp-compiler", version.ref = "koin_ksp" }
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin-android"}
koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin-androidx-compose"}
koin-androidx-compose-navigation = { module = "io.insert-koin:koin-androidx-compose-navigation", version.ref = "koin-androidx-compose"}
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin-android" }
koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin-androidx-compose" }
koin-androidx-compose-navigation = { module = "io.insert-koin:koin-androidx-compose-navigation", version.ref = "koin-androidx-compose" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
Expand Down
14 changes: 7 additions & 7 deletions ios/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
89011D542AE9A8150073544B /* LocaleExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89011D522AE9A8150073544B /* LocaleExtensions.swift */; };
89011D552AE9A8150073544B /* AppInformationImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89011D532AE9A8150073544B /* AppInformationImpl.swift */; };
89011D5B2AE9B0310073544B /* PreviewHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89011D5A2AE9B0310073544B /* PreviewHelpers.swift */; };
895BECFB2AEAB3DC005B1212 /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 895BECFA2AEAB3DC005B1212 /* RootView.swift */; };
9B8ACFDB4E332DFCA8B97CBB /* Pods_iosApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E4E1328B104D05A50A097EE /* Pods_iosApp.framework */; };
BC83B466276E4F080053E064 /* FlowUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC83B465276E4F080053E064 /* FlowUtils.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -40,7 +40,7 @@
89011D522AE9A8150073544B /* LocaleExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocaleExtensions.swift; sourceTree = "<group>"; };
89011D532AE9A8150073544B /* AppInformationImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppInformationImpl.swift; sourceTree = "<group>"; };
89011D5A2AE9B0310073544B /* PreviewHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewHelpers.swift; sourceTree = "<group>"; };
BC83B465276E4F080053E064 /* FlowUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlowUtils.swift; sourceTree = "<group>"; };
895BECFA2AEAB3DC005B1212 /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };
E232C917135C2C1E3BC8748A /* Pods-iosApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.release.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -93,7 +93,6 @@
89011D5C2AE9B14A0073544B /* Extensions */,
7555FF8C242A565B00829871 /* Info.plist */,
058557BA273AAA24004C7B11 /* Assets.xcassets */,
BC83B464276E4EF80053E064 /* Utils */,
058557D7273AAEEB004C7B11 /* Preview Content */,
);
path = iosApp;
Expand All @@ -114,6 +113,7 @@
isa = PBXGroup;
children = (
89011D582AE9B00F0073544B /* Application */,
895BECF92AEAB3D1005B1212 /* Root */,
89011D592AE9B0160073544B /* Previews */,
);
path = UI;
Expand Down Expand Up @@ -143,12 +143,12 @@
path = Extensions;
sourceTree = "<group>";
};
BC83B464276E4EF80053E064 /* Utils */ = {
895BECF92AEAB3D1005B1212 /* Root */ = {
isa = PBXGroup;
children = (
BC83B465276E4F080053E064 /* FlowUtils.swift */,
895BECFA2AEAB3DC005B1212 /* RootView.swift */,
);
path = Utils;
path = Root;
sourceTree = "<group>";
};
C8C629BFDC2144230B71E3BC /* Frameworks */ = {
Expand Down Expand Up @@ -328,9 +328,9 @@
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
89011D512AE9A7750073544B /* ImageProvider.swift in Sources */,
89011D4B2AE9A4CD0073544B /* BootstrapImpl.swift in Sources */,
895BECFB2AEAB3DC005B1212 /* RootView.swift in Sources */,
7555FF83242A565900829871 /* ApplicationView.swift in Sources */,
89011D552AE9A8150073544B /* AppInformationImpl.swift in Sources */,
BC83B466276E4F080053E064 /* FlowUtils.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
3 changes: 2 additions & 1 deletion ios/iosApp/AppInitializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ enum AppInitializer {
private static func initializeCommon() {
TrikotKword.shared.setCurrentLanguage(Foundation.Locale.isPreferredLanguagesFrench ? "fr" : "en")
TrikotViewModelDeclarative.shared.initialize(
imageProvider: ImageProvider()
imageProvider: ImageProvider(),
spanStyleProvider: DefaultSpanStyleProvider()
)
}

Expand Down
16 changes: 8 additions & 8 deletions ios/iosApp/UI/Application/ApplicationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import Trikot

struct ApplicationView: View {
@ObservedObject private var observableViewModel: ObservableViewModelAdapter<ApplicationViewModel>

init(viewModel: ApplicationViewModel) {
observableViewModel = viewModel.asObservable()
}

var viewModel: ApplicationViewModel {
observableViewModel.viewModel
}
var body: some View {
Text("Hi")
}

var body: some View {
RootView(viewModel: viewModel.rootViewModel)
}
}

struct GreetingView_Previews: PreviewProvider {
static var previews: some View {
struct ApplicationView_Previews: PreviewProvider {
static var previews: some View {
ApplicationView(viewModel: factoryPreview().createApplication())
}
}
}
25 changes: 25 additions & 0 deletions ios/iosApp/UI/Root/RootView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Shared
import SwiftUI
import Trikot

struct RootView: View {
@ObservedObject private var observableViewModel: ObservableViewModelAdapter<RootViewModel>

init(viewModel: RootViewModel) {
observableViewModel = viewModel.asObservable()
}

var viewModel: RootViewModel {
observableViewModel.viewModel
}

var body: some View {
Text("Hi")
}
}

struct RootView_Previews: PreviewProvider {
static var previews: some View {
RootView(viewModel: factoryPreview().createRoot())
}
}
21 changes: 0 additions & 21 deletions ios/iosApp/Utils/FlowUtils.swift

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 89497ea

Please sign in to comment.