Skip to content

Commit

Permalink
Merge pull request #2 from stslex/dev
Browse files Browse the repository at this point in the history
Initial
  • Loading branch information
stslex authored Nov 23, 2023
2 parents b9fe280 + 28f7eac commit fd070bf
Show file tree
Hide file tree
Showing 21 changed files with 496 additions and 105 deletions.
29 changes: 0 additions & 29 deletions .fleet/receipt.json

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/build_app.yml
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ captures
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings
.fleet
4 changes: 4 additions & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ kotlin {
implementation(compose.desktop.currentOs)
}
commonMain.dependencies {
implementation(project(":core:core"))
implementation(project(":core:ui"))
implementation(project(":feature:home"))

implementation(projects.shared)
implementation(compose.runtime)
implementation(compose.foundation)
Expand Down
77 changes: 2 additions & 75 deletions composeApp/src/commonMain/kotlin/App.kt
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
)
}
7 changes: 7 additions & 0 deletions composeApp/src/commonMain/kotlin/InitialApp.kt
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()
}
53 changes: 53 additions & 0 deletions core/core/build.gradle.kts
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()
}
}
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
}
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 core/core/src/commonMain/kotlin/com/stslex/core/core/Logger.kt
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
)
}
}
59 changes: 59 additions & 0 deletions core/ui/build.gradle.kts
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()
}
}
Loading

0 comments on commit fd070bf

Please sign in to comment.