-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from stslex/dev
Initial
- Loading branch information
Showing
21 changed files
with
496 additions
and
105 deletions.
There are no files selected for viewing
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,38 @@ | ||
name: Project Build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: macos-latest | ||
timeout-minutes: 60 | ||
|
||
steps: | ||
|
||
- name: Checkout branch | ||
uses: actions/checkout@v2 | ||
|
||
- name: set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: gradle | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- uses: maxim-lobanov/setup-xcode@v1 | ||
with: | ||
xcode-version: latest-stable | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build | ||
|
||
- name: Junit tests with Gradle | ||
run: ./gradlew testDebugUnitTest |
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
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
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 |
---|---|---|
@@ -1,82 +1,9 @@ | ||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.darkColors | ||
import androidx.compose.material.lightColors | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.derivedStateOf | ||
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 org.jetbrains.compose.resources.ExperimentalResourceApi | ||
import org.jetbrains.compose.resources.painterResource | ||
import com.stslex.core.ui.theme.AppTheme | ||
|
||
@OptIn(ExperimentalResourceApi::class) | ||
@Composable | ||
fun App() { | ||
AppTheme { | ||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(MaterialTheme.colors.background) | ||
) { | ||
val defaultGreetState = "Hello World!" | ||
val clickedGreetState = "Compose: ${Greeting().greet()}" | ||
var isClicked by remember { mutableStateOf(false) } | ||
val greetingText by remember { | ||
derivedStateOf { | ||
if (isClicked) { | ||
clickedGreetState | ||
} else { | ||
defaultGreetState | ||
} | ||
} | ||
} | ||
Column( | ||
modifier = Modifier.fillMaxWidth(), | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Button( | ||
onClick = { | ||
isClicked = !isClicked | ||
} | ||
) { | ||
Text(greetingText) | ||
} | ||
AnimatedVisibility(isClicked) { | ||
Image( | ||
painterResource("compose-multiplatform.xml"), | ||
null | ||
) | ||
} | ||
} | ||
} | ||
InitialApp() | ||
} | ||
} | ||
|
||
@Composable | ||
fun AppTheme( | ||
isDarkTheme: Boolean = isSystemInDarkTheme(), | ||
content: @Composable () -> Unit, | ||
) { | ||
val colors = if (isDarkTheme) { | ||
darkColors() | ||
} else { | ||
lightColors() | ||
} | ||
MaterialTheme( | ||
colors = colors, | ||
content = content | ||
) | ||
} |
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,7 @@ | ||
import androidx.compose.runtime.Composable | ||
import com.stslex.feature.home.HomeScreen | ||
|
||
@Composable | ||
fun InitialApp() { | ||
HomeScreen() | ||
} |
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,53 @@ | ||
plugins { | ||
alias(libs.plugins.kotlinMultiplatform) | ||
alias(libs.plugins.androidLibrary) | ||
alias(libs.plugins.jetbrainsCompose) | ||
} | ||
|
||
kotlin { | ||
androidTarget { | ||
compilations.all { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
} | ||
|
||
jvm("desktop") | ||
|
||
listOf( | ||
iosX64(), | ||
iosArm64(), | ||
iosSimulatorArm64() | ||
).forEach { | ||
it.binaries.framework { | ||
baseName = "core" | ||
isStatic = true | ||
} | ||
} | ||
|
||
sourceSets { | ||
val desktopMain by getting | ||
|
||
commonMain.dependencies { | ||
implementation(libs.kermit) | ||
implementation(projects.shared) | ||
implementation(compose.runtime) | ||
implementation(compose.foundation) | ||
} | ||
commonTest.dependencies { | ||
implementation(libs.kotlin.test) | ||
} | ||
desktopMain.dependencies { | ||
implementation(compose.desktop.currentOs) | ||
} | ||
} | ||
} | ||
|
||
android { | ||
namespace = "com.stslex.core.core" | ||
compileSdk = libs.versions.android.compileSdk.get().toInt() | ||
defaultConfig { | ||
minSdk = libs.versions.android.minSdk.get().toInt() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
core/core/src/commonMain/kotlin/com/stslex/core/core/AppDispatcher.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,17 @@ | ||
package com.stslex.core.core | ||
|
||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.MainCoroutineDispatcher | ||
|
||
interface AppDispatcher { | ||
val io: CoroutineDispatcher | ||
val main: MainCoroutineDispatcher | ||
val default: CoroutineDispatcher | ||
} | ||
|
||
class AppDispatcherImpl : AppDispatcher { | ||
override val io: CoroutineDispatcher = Dispatchers.Default // TODO IO | ||
override val main: MainCoroutineDispatcher = Dispatchers.Main | ||
override val default: CoroutineDispatcher = Dispatchers.Default | ||
} |
7 changes: 7 additions & 0 deletions
7
core/core/src/commonMain/kotlin/com/stslex/core/core/CommonUtils.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,7 @@ | ||
package com.stslex.core.core | ||
|
||
import kotlinx.coroutines.CoroutineExceptionHandler | ||
|
||
val coroutineExceptionHandler = CoroutineExceptionHandler { _, throwable -> | ||
Logger.exception(throwable) | ||
} |
34 changes: 34 additions & 0 deletions
34
core/core/src/commonMain/kotlin/com/stslex/core/core/Logger.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,34 @@ | ||
package com.stslex.core.core | ||
|
||
import co.touchlab.kermit.Logger as Log | ||
|
||
object Logger { | ||
|
||
private const val DEFAULT_TAG = "WIZARD" | ||
|
||
fun exception( | ||
throwable: Throwable, | ||
tag: String? = null, | ||
message: String? = null | ||
) { | ||
// TODO check build config if (BuildConfig.DEBUG.not()) return | ||
val currentTag = "$DEFAULT_TAG:${tag.orEmpty()}" | ||
Log.e( | ||
tag = currentTag, | ||
throwable = throwable, | ||
messageString = message ?: throwable.message.orEmpty(), | ||
) | ||
} | ||
|
||
fun debug( | ||
message: String, | ||
tag: String? = null, | ||
) { | ||
// TODO check build config if (BuildConfig.DEBUG.not()) return | ||
val currentTag = "$DEFAULT_TAG:${tag.orEmpty()}" | ||
Log.d( | ||
tag = currentTag, | ||
messageString = message | ||
) | ||
} | ||
} |
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,59 @@ | ||
import org.jetbrains.compose.ExperimentalComposeLibrary | ||
|
||
plugins { | ||
alias(libs.plugins.kotlinMultiplatform) | ||
alias(libs.plugins.androidLibrary) | ||
alias(libs.plugins.jetbrainsCompose) | ||
} | ||
|
||
kotlin { | ||
androidTarget { | ||
compilations.all { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
} | ||
|
||
jvm("desktop") | ||
|
||
listOf( | ||
iosX64(), | ||
iosArm64(), | ||
iosSimulatorArm64() | ||
).forEach { | ||
it.binaries.framework { | ||
baseName = "ui" | ||
isStatic = true | ||
} | ||
} | ||
|
||
sourceSets { | ||
val desktopMain by getting | ||
|
||
commonMain.dependencies { | ||
implementation(project(":core:core")) | ||
|
||
implementation(projects.shared) | ||
implementation(compose.runtime) | ||
implementation(compose.foundation) | ||
implementation(compose.material) | ||
@OptIn(ExperimentalComposeLibrary::class) | ||
implementation(compose.components.resources) | ||
} | ||
commonTest.dependencies { | ||
implementation(libs.kotlin.test) | ||
} | ||
desktopMain.dependencies { | ||
implementation(compose.desktop.currentOs) | ||
} | ||
} | ||
} | ||
|
||
android { | ||
namespace = "com.stslex.core.ui" | ||
compileSdk = libs.versions.android.compileSdk.get().toInt() | ||
defaultConfig { | ||
minSdk = libs.versions.android.minSdk.get().toInt() | ||
} | ||
} |
Oops, something went wrong.