Wire project infrastructure
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:name=".MainApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
||||
@@ -22,4 +22,4 @@ class MainActivity : ComponentActivity() {
|
||||
@Composable
|
||||
fun AppAndroidPreview() {
|
||||
App()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.ulfrx.recipe
|
||||
|
||||
import android.app.Application
|
||||
import dev.ulfrx.recipe.di.initKoin
|
||||
import dev.ulfrx.recipe.logging.configureLogging
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
|
||||
class MainApplication : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
configureLogging()
|
||||
initKoin {
|
||||
androidContext(this@MainApplication)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,15 @@ import androidx.compose.foundation.layout.safeContentPadding
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
|
||||
import recipe.composeapp.generated.resources.Res
|
||||
import recipe.composeapp.generated.resources.compose_multiplatform
|
||||
|
||||
@@ -25,10 +28,11 @@ fun App() {
|
||||
MaterialTheme {
|
||||
var showContent by remember { mutableStateOf(false) }
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colorScheme.primaryContainer)
|
||||
.safeContentPadding()
|
||||
.fillMaxSize(),
|
||||
modifier =
|
||||
Modifier
|
||||
.background(MaterialTheme.colorScheme.primaryContainer)
|
||||
.safeContentPadding()
|
||||
.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Button(onClick = { showContent = !showContent }) {
|
||||
@@ -46,4 +50,4 @@ fun App() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.ulfrx.recipe.di
|
||||
|
||||
import org.koin.dsl.module
|
||||
|
||||
// Phase 2 adds authModule; Phase 4 adds syncModule; Phase 5 adds catalogModule; etc.
|
||||
val appModule =
|
||||
module {
|
||||
// intentionally empty in Phase 1
|
||||
}
|
||||
11
composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/di/Koin.kt
Normal file
11
composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/di/Koin.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package dev.ulfrx.recipe.di
|
||||
|
||||
import org.koin.core.KoinApplication
|
||||
import org.koin.core.context.startKoin
|
||||
import org.koin.dsl.KoinAppDeclaration
|
||||
|
||||
fun initKoin(config: KoinAppDeclaration? = null): KoinApplication =
|
||||
startKoin {
|
||||
config?.invoke(this)
|
||||
modules(appModule)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package dev.ulfrx.recipe.logging
|
||||
|
||||
import co.touchlab.kermit.Logger
|
||||
|
||||
fun configureLogging() {
|
||||
Logger.setTag("recipe")
|
||||
// Platform log writers (OSLog iOS, LogCat Android, System.out JVM/Wasm) install by default.
|
||||
}
|
||||
@@ -4,9 +4,8 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class ComposeAppCommonTest {
|
||||
|
||||
@Test
|
||||
fun example() {
|
||||
assertEquals(3, 1 + 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@ package dev.ulfrx.recipe
|
||||
|
||||
import androidx.compose.ui.window.ComposeUIViewController
|
||||
|
||||
fun MainViewController() = ComposeUIViewController { App() }
|
||||
fun MainViewController() = ComposeUIViewController { App() }
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package dev.ulfrx.recipe.di
|
||||
|
||||
import dev.ulfrx.recipe.logging.configureLogging
|
||||
|
||||
fun doInitKoin() {
|
||||
configureLogging()
|
||||
initKoin()
|
||||
}
|
||||
@@ -2,12 +2,18 @@ package dev.ulfrx.recipe
|
||||
|
||||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.application
|
||||
import dev.ulfrx.recipe.di.initKoin
|
||||
import dev.ulfrx.recipe.logging.configureLogging
|
||||
|
||||
fun main() = application {
|
||||
Window(
|
||||
onCloseRequest = ::exitApplication,
|
||||
title = "recipe",
|
||||
) {
|
||||
App()
|
||||
fun main() {
|
||||
configureLogging()
|
||||
initKoin()
|
||||
application {
|
||||
Window(
|
||||
onCloseRequest = ::exitApplication,
|
||||
title = "recipe",
|
||||
) {
|
||||
App()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,14 @@ package dev.ulfrx.recipe
|
||||
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.window.ComposeViewport
|
||||
import dev.ulfrx.recipe.di.initKoin
|
||||
import dev.ulfrx.recipe.logging.configureLogging
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
fun main() {
|
||||
configureLogging()
|
||||
initKoin()
|
||||
ComposeViewport {
|
||||
App()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user