Skip to content

Commit

Permalink
Rearrange sample structure
Browse files Browse the repository at this point in the history
  • Loading branch information
egorikftp committed May 28, 2024
1 parent c713c78 commit 6f071d2
Show file tree
Hide file tree
Showing 82 changed files with 510 additions and 684 deletions.
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ captures
.cxx
.kotlin
publish.bat
kotlin-js-store/
kotlin-js-store/

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
*.xccheckout
*.xcsmblueprint
xcuserdata/
xcshareddata/
contents.xcworkspacedata
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ Nothing specific (yet)
### Run/Build sample
Android: `./gradlew example:composeApp:assembleDebug`
Android: `./gradlew example:app:composeApp:assembleDebug`
Desktop: `./gradlew example:composeApp:run`
Desktop: `./gradlew example:app:composeApp:run`
Web: `./gradlew example:composeApp:wasmJsBrowserRun`
Web: `./gradlew example:app:composeApp:wasmJsBrowserRun`
iOS: run XCode project or else use [KMM](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile) plugin iOS target
Expand Down
2 changes: 2 additions & 0 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,8 @@ Compose:
active: true
MutableParams:
active: true
ParameterNaming:
active: true
MutableStateAutoboxing:
active: true
MutableStateParam:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ kotlin {
iosTarget.binaries.framework {
baseName = "ComposeApp"
isStatic = true

export(projects.example.sampleKoin)
}
}

Expand All @@ -50,10 +52,13 @@ kotlin {
}

sourceSets {
val desktopMain by getting

commonMain.dependencies {
implementation(projects.tiamat)
implementation(projects.example.uiCore)
}
androidMain.dependencies {
implementation(projects.tiamatKoin)
implementation(projects.example.sampleKoin)

implementation(libs.androidx.activity.compose)
implementation(libs.androidx.camera.camera2)
Expand All @@ -62,40 +67,38 @@ kotlin {
implementation(libs.androidx.concurrent.futures)
implementation(libs.koin.compose)
}
commonMain.dependencies {
implementation(projects.tiamat)

implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.materialIconsExtended)
implementation(compose.ui)
}
desktopMain.dependencies {
iosMain.dependencies {
implementation(projects.tiamatKoin)
api(projects.example.sampleKoin)

implementation(compose.desktop.currentOs)
implementation(libs.koin.compose)
implementation(libs.kotlin.coroutines.swing)
}
iosMain.dependencies {
implementation(projects.tiamatKoin)
wasmJsMain.dependencies {

implementation(libs.koin.compose)
}
val desktopMain by getting {
dependencies {
implementation(projects.tiamatKoin)
implementation(projects.example.sampleKoin)

implementation(compose.desktop.currentOs)
implementation(libs.koin.compose)
implementation(libs.kotlin.coroutines.swing)
}
}
}
}

android {
namespace = "com.compose.gear.navigation.example"
namespace = "composegears.tiamat.example"
compileSdk = libs.versions.android.compileSdk.get().toInt()

sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")

defaultConfig {
applicationId = "com.compose.gear.navigation"
applicationId = "composegears.tiamat.example"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 1
Expand All @@ -109,11 +112,11 @@ android {

compose.desktop {
application {
mainClass = "MainKt"
mainClass = "composegears.tiamat.example.MainKt"

nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "com.compose.gear.navigation.example"
packageName = "composegears.tiamat.example"
packageVersion = "1.0.0"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
android:name="com.composegear.navigation.MainApplication"
android:name=".MainApplication"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
<activity
android:name="com.composegear.navigation.MainActivity"
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleInstance"
android:configChanges="screenSize|screenLayout|orientation">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.composegear.navigation
package composegears.tiamat.example

import android.content.Intent
import androidx.compose.runtime.getValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.composegear.navigation
package composegears.tiamat.example

import App
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.runtime.DisposableEffect
import com.composegears.tiamat.navigationFadeInOut
import content.MainScreen
import content.examples.PlatformExample
import composegears.tiamat.example.common.PlatformExampleScreen

class MainActivity : ComponentActivity() {

Expand All @@ -31,7 +29,7 @@ class MainActivity : ComponentActivity() {
add(MainScreen)
}
rootNavController.replace(
dest = PlatformExample,
dest = PlatformExampleScreen,
freeArgs = deeplink,
// we only animate root content switch
// all nested items should use navigationNone() transition to prevent `blink`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.composegear.navigation
package composegears.tiamat.example

import android.app.Application
import content.examples.koin.KoinLib
import composegears.tiamat.sample.koin.KoinLib

class MainApplication : Application() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package composegears.tiamat.example.common

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import com.composegears.tiamat.*
import composegears.tiamat.example.DeeplinkData
import composegears.tiamat.example.common.PlatformConfig.PlatformDestination
import composegears.tiamat.example.platform.AndroidViewLifecycleScreen
import composegears.tiamat.example.platform.DeeplinkScreen
import composegears.tiamat.example.platform.SavedStateScreen
import composegears.tiamat.sample.koin.KoinIntegrationScreen

actual val platformConfig = PlatformConfig(
platformName = "Android",
availableScreens = listOf(
PlatformDestination(
name = "Android SavedState",
destination = SavedStateScreen
),
PlatformDestination(
name = "AndroidView + Lifecycle handle",
destination = AndroidViewLifecycleScreen
),
PlatformDestination(
name = "Deeplink",
destination = DeeplinkScreen
),
PlatformDestination(
name = "Koin (ViewModel/SharedViewModel)",
destination = KoinIntegrationScreen
)
)
)

actual val PlatformExampleScreen: NavDestination<Unit> by navDestination {
val deeplink = freeArgs<DeeplinkData>()

val platformNavController = rememberNavController(
startDestination = PlatformScreen,
destinations = platformConfig.destinations() + PlatformScreen
) {
if (deeplink != null) {
editBackStack {
clear()
add(PlatformScreen)
}
replace(
dest = DeeplinkScreen,
freeArgs = deeplink,
transition = navigationNone()
)
clearFreeArgs()
}
}

Navigation(
navController = platformNavController,
modifier = Modifier.fillMaxSize()
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package content.examples.platform.examples
package composegears.tiamat.example.platform

import android.Manifest
import android.app.Activity
Expand Down Expand Up @@ -36,10 +36,10 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.composegears.tiamat.navController
import com.composegears.tiamat.navDestination
import content.examples.common.BackButton
import content.examples.common.NextButton
import content.examples.common.SimpleScreen
import content.examples.common.TextBody
import composegears.tiamat.example.ui.core.BackButton
import composegears.tiamat.example.ui.core.NextButton
import composegears.tiamat.example.ui.core.SimpleScreen
import composegears.tiamat.example.ui.core.TextBody

val AndroidViewLifecycleScreen by navDestination<Unit> {
val context = LocalContext.current
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package content.examples.platform.examples
package composegears.tiamat.example.platform

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -7,12 +7,12 @@ import androidx.compose.material3.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.composegear.navigation.DeeplinkData
import com.composegears.tiamat.*
import content.examples.common.BackButton
import content.examples.common.NextButton
import content.examples.common.SimpleScreen
import content.examples.common.TextBody
import composegears.tiamat.example.DeeplinkData
import composegears.tiamat.example.ui.core.BackButton
import composegears.tiamat.example.ui.core.NextButton
import composegears.tiamat.example.ui.core.SimpleScreen
import composegears.tiamat.example.ui.core.TextBody

/*
* To run sample from adb, run in terminal:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package content.examples.platform.examples
package composegears.tiamat.example.platform

import android.os.Parcelable
import androidx.compose.foundation.border
Expand All @@ -17,7 +17,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.composegears.tiamat.*
import content.examples.common.*
import composegears.tiamat.example.ui.core.*
import kotlinx.parcelize.Parcelize

val SavedStateScreen by navDestination<Unit> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@file:Suppress("MissingPackageDeclaration")

package composegears.tiamat.example

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.material3.Surface
Expand All @@ -9,9 +11,9 @@ import com.composegears.tiamat.NavController
import com.composegears.tiamat.Navigation
import com.composegears.tiamat.StorageMode
import com.composegears.tiamat.rememberNavController
import content.MainScreen
import content.examples.*
import content.examples.multimodule.MultiModuleRoot
import composegears.tiamat.example.common.PlatformExampleScreen
import composegears.tiamat.example.multimodule.MultiModuleRoot
import composegears.tiamat.example.ui.core.AppTheme

@Composable
fun App(configure: @Composable (NavController) -> Unit = {}) {
Expand Down Expand Up @@ -46,7 +48,7 @@ fun App(configure: @Composable (NavController) -> Unit = {}) {
MultiModuleRoot,
BackStackAlterationRoot,
TwoPaneResizableRoot,
PlatformExample
PlatformExampleScreen
)
)
configure(rootNavController)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package content.examples
package composegears.tiamat.example

import androidx.compose.foundation.background
import androidx.compose.foundation.border
Expand All @@ -16,7 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.composegears.tiamat.*
import content.examples.common.*
import composegears.tiamat.example.ui.core.*

@Composable
private fun NavDestinationScope<*>.Screen(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package content.examples
package composegears.tiamat.example

import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
Expand All @@ -14,7 +14,7 @@ import com.composegears.tiamat.navController
import com.composegears.tiamat.navDestination
import com.composegears.tiamat.navigationSlideInOut
import com.composegears.tiamat.navigationSlideOutToBottom
import content.examples.common.*
import composegears.tiamat.example.ui.core.*

val CustomTransitionRoot by navDestination<Unit> {
val navController = navController()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@file:Suppress("MatchingDeclarationName")

package content.examples
package composegears.tiamat.example

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -14,8 +14,8 @@ import androidx.compose.ui.unit.dp
import com.composegears.tiamat.freeArgs
import com.composegears.tiamat.navController
import com.composegears.tiamat.navDestination
import content.examples.common.BackButton
import content.examples.common.SimpleScreen
import composegears.tiamat.example.ui.core.BackButton
import composegears.tiamat.example.ui.core.SimpleScreen

class FreeArgsData

Expand Down
Loading

0 comments on commit 6f071d2

Please sign in to comment.