From ac0f5021d4a26fdfcb5c51984f6bb704ec59bea9 Mon Sep 17 00:00:00 2001 From: Drew Heavner Date: Fri, 16 Aug 2024 02:06:53 -0400 Subject: [PATCH 1/9] Started adding sample app --- .../annotations/ContributesSubcomponent.kt | 7 +- build.gradle.kts | 4 + gradle/libs.versions.toml | 15 +- sample/androidApp/build.gradle.kts | 61 +++ .../androidApp/src/main/AndroidManifest.xml | 19 + .../kimchi/restaurant/android/MainActivity.kt | 31 ++ .../restaurant/android/MyApplicationTheme.kt | 55 +++ .../android/RestaurantApplication.kt | 11 + .../androidApp/src/main/res/values/styles.xml | 3 + .../iosApp/iosApp.xcodeproj/project.pbxproj | 391 ++++++++++++++++++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 98 +++++ .../iosApp/Assets.xcassets/Contents.json | 6 + sample/iosApp/iosApp/ContentView.swift | 16 + sample/iosApp/iosApp/Info.plist | 48 +++ .../Preview Assets.xcassets/Contents.json | 6 + sample/iosApp/iosApp/iOSApp.swift | 10 + sample/shared/build.gradle.kts | 74 ++++ .../kimchi/restaurant/Platform.android.kt | 7 + .../com/r0adkll/kimchi/restaurant/Greeting.kt | 9 + .../com/r0adkll/kimchi/restaurant/Platform.kt | 7 + .../r0adkll/kimchi/restaurant/Platform.ios.kt | 9 + sample/ui/build.gradle.kts | 51 +++ settings.gradle.kts | 5 + 24 files changed, 951 insertions(+), 3 deletions(-) create mode 100644 sample/androidApp/build.gradle.kts create mode 100644 sample/androidApp/src/main/AndroidManifest.xml create mode 100644 sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/MainActivity.kt create mode 100644 sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/MyApplicationTheme.kt create mode 100644 sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/RestaurantApplication.kt create mode 100644 sample/androidApp/src/main/res/values/styles.xml create mode 100644 sample/iosApp/iosApp.xcodeproj/project.pbxproj create mode 100644 sample/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 sample/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 sample/iosApp/iosApp/Assets.xcassets/Contents.json create mode 100644 sample/iosApp/iosApp/ContentView.swift create mode 100644 sample/iosApp/iosApp/Info.plist create mode 100644 sample/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 sample/iosApp/iosApp/iOSApp.swift create mode 100644 sample/shared/build.gradle.kts create mode 100644 sample/shared/src/androidMain/kotlin/com/r0adkll/kimchi/restaurant/Platform.android.kt create mode 100644 sample/shared/src/commonMain/kotlin/com/r0adkll/kimchi/restaurant/Greeting.kt create mode 100644 sample/shared/src/commonMain/kotlin/com/r0adkll/kimchi/restaurant/Platform.kt create mode 100644 sample/shared/src/iosMain/kotlin/com/r0adkll/kimchi/restaurant/Platform.ios.kt create mode 100644 sample/ui/build.gradle.kts diff --git a/annotations/src/commonMain/kotlin/com/r0adkll/kimchi/annotations/ContributesSubcomponent.kt b/annotations/src/commonMain/kotlin/com/r0adkll/kimchi/annotations/ContributesSubcomponent.kt index 3ed89b7..ed63135 100644 --- a/annotations/src/commonMain/kotlin/com/r0adkll/kimchi/annotations/ContributesSubcomponent.kt +++ b/annotations/src/commonMain/kotlin/com/r0adkll/kimchi/annotations/ContributesSubcomponent.kt @@ -9,4 +9,9 @@ import kotlin.reflect.KClass annotation class ContributesSubcomponent( val scope: KClass<*>, val parentScope: KClass<*>, -) +) { + + @MustBeDocumented + @Retention(AnnotationRetention.SOURCE) + annotation class Factory +} diff --git a/build.gradle.kts b/build.gradle.kts index 81791cc..b0058e2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,8 +11,12 @@ import java.net.URI import org.jetbrains.dokka.gradle.DokkaTaskPartial plugins { + alias(libs.plugins.androidApplication) apply false alias(libs.plugins.androidLibrary) apply false + alias(libs.plugins.compose.compiler) apply false + alias(libs.plugins.compose.multiplatform) apply false alias(libs.plugins.dokka) + alias(libs.plugins.kotlinAndroid) apply false alias(libs.plugins.kotlinMultiplatform) apply false alias(libs.plugins.ksp) apply false alias(libs.plugins.mavenPublish) apply false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 80fe410..6b77ee9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,9 @@ [versions] agp = "8.5.2" +androidx-activityCompose = "1.9.1" autoservice = "1.1.1" +circuit = "0.23.1" +compose-multiplatform = "1.6.11" dokka = "1.9.20" kotlin = "2.0.10" kotlin-inject = "0.7.1" @@ -10,10 +13,9 @@ ksp-autoservce = "1.2.0" ktlint = "0.49.1" mavenPublish = "0.29.0" spotless = "6.25.0" -jvmTarget = "11" -publishedJvmTarget = "1.8" [libraries] +androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } autoservice-annotations = { module = "com.google.auto.service:auto-service-annotations", version.ref = "autoservice" } kotlin-ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -23,9 +25,18 @@ kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" } kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinpoet" } ksp-autoservice = { module = "dev.zacsweers.autoservice:auto-service-ksp", version.ref = "ksp-autoservce" } +# Sample app dependencies +circuit-foundation = { module = "com.slack.circuit:circuit-foundation", version.ref = "circuit" } +circuit-overlay = { module = "com.slack.circuit:circuit-overlay", version.ref = "circuit" } +circuit-runtime = { module = "com.slack.circuit:circuit-runtime", version.ref = "circuit" } +circuit-retained = { module = "com.slack.circuit:circuit-retained", version.ref = "circuit" } +circuitx-gesturenav = { module = "com.slack.circuit:circuitx-gesture-navigation", version.ref = "circuit" } + [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } androidLibrary = { id = "com.android.library", version.ref = "agp" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } diff --git a/sample/androidApp/build.gradle.kts b/sample/androidApp/build.gradle.kts new file mode 100644 index 0000000..5d281c5 --- /dev/null +++ b/sample/androidApp/build.gradle.kts @@ -0,0 +1,61 @@ +plugins { + alias(libs.plugins.androidApplication) + alias(libs.plugins.kotlinAndroid) + alias(libs.plugins.compose.compiler) + alias(libs.plugins.compose.multiplatform) + alias(libs.plugins.ksp) +} + +android { + namespace = "com.r0adkll.kimchi.restaurant.android" + compileSdk = 34 + + defaultConfig { + applicationId = "com.r0adkll.kimchi.restaurant.android" + minSdk = 26 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + } + + buildFeatures { + compose = true + } + + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } +} + +dependencies { + implementation(projects.annotations) + implementation(projects.sample.shared) + + implementation(libs.androidx.activity.compose) + implementation(libs.circuit.runtime) + implementation(libs.circuit.foundation) + + api(compose.foundation) + api(compose.material) + api(compose.material3) + api(compose.materialIconsExtended) + api(compose.animation) + + ksp(projects.compiler) + ksp(libs.kotlininject.ksp) +} diff --git a/sample/androidApp/src/main/AndroidManifest.xml b/sample/androidApp/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f5ba8a0 --- /dev/null +++ b/sample/androidApp/src/main/AndroidManifest.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/MainActivity.kt b/sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/MainActivity.kt new file mode 100644 index 0000000..c3fe9f2 --- /dev/null +++ b/sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/MainActivity.kt @@ -0,0 +1,31 @@ +package com.r0adkll.kimchi.restaurant.android + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.* +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.r0adkll.kimchi.restaurant.Greeting + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + MyApplicationTheme { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background, + ) { + GreetingView(Greeting().greet()) + } + } + } + } +} + +@Composable +fun GreetingView(text: String) { + Text(text = text) +} diff --git a/sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/MyApplicationTheme.kt b/sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/MyApplicationTheme.kt new file mode 100644 index 0000000..ff223d0 --- /dev/null +++ b/sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/MyApplicationTheme.kt @@ -0,0 +1,55 @@ +package com.r0adkll.kimchi.restaurant.android + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Shapes +import androidx.compose.material3.Typography +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +@Composable +fun MyApplicationTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit +) { + val colors = if (darkTheme) { + darkColorScheme( + primary = Color(0xFFBB86FC), + secondary = Color(0xFF03DAC5), + tertiary = Color(0xFF3700B3) + ) + } else { + lightColorScheme( + primary = Color(0xFF6200EE), + secondary = Color(0xFF03DAC5), + tertiary = Color(0xFF3700B3) + ) + } + val typography = Typography( + bodyMedium = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp + ) + ) + val shapes = Shapes( + small = RoundedCornerShape(4.dp), + medium = RoundedCornerShape(4.dp), + large = RoundedCornerShape(0.dp) + ) + + MaterialTheme( + colorScheme = colors, + typography = typography, + shapes = shapes, + content = content + ) +} diff --git a/sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/RestaurantApplication.kt b/sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/RestaurantApplication.kt new file mode 100644 index 0000000..0feac3a --- /dev/null +++ b/sample/androidApp/src/main/java/com/r0adkll/kimchi/restaurant/android/RestaurantApplication.kt @@ -0,0 +1,11 @@ +package com.r0adkll.kimchi.restaurant.android + +import android.app.Application + +class RestaurantApplication : Application() { + + override fun onCreate() { + super.onCreate() + + } +} diff --git a/sample/androidApp/src/main/res/values/styles.xml b/sample/androidApp/src/main/res/values/styles.xml new file mode 100644 index 0000000..6b4fa3d --- /dev/null +++ b/sample/androidApp/src/main/res/values/styles.xml @@ -0,0 +1,3 @@ + +