Skip to content

Commit

Permalink
removed title and refactored to a card
Browse files Browse the repository at this point in the history
  • Loading branch information
vextorspace committed May 29, 2024
1 parent 134a399 commit d967135
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
3 changes: 3 additions & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ android {
debugImplementation(libs.compose.ui.tooling)
}
}
dependencies {
implementation(libs.androidx.ui.desktop)
}

compose.desktop {
application {
Expand Down
22 changes: 2 additions & 20 deletions composeApp/src/commonMain/kotlin/App.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import model.Item
import org.jetbrains.compose.ui.tooling.preview.Preview


Expand All @@ -19,22 +16,7 @@ fun App() {
Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
makeCard("Create a card", "- create card body")
Item("Create a card", "- create card body").makeCard()
}
}
}

private fun makeCard(title: String, content: String) {
Card(
modifier = Modifier.padding(6.dp),
elevation = 3.dp
) {
Column {
Text(
text = title,
style = MaterialTheme.typography.h5
)
Text(content)
}
}
}
22 changes: 22 additions & 0 deletions composeApp/src/commonMain/kotlin/model/Item.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package model

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

data class Item(val title: String, val content: String) {
@Composable fun makeCard() {
Card(
modifier = Modifier.padding(6.dp),
elevation = 3.dp
) {
Column {
Text(content)
}
}
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ kotest = "5.8.1"
mockk = "1.13.10"
robolectric = "4.12.1"
coreKtx = "1.5.0"
uiDesktop = "1.6.7"

[libraries]
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
Expand All @@ -38,6 +39,7 @@ compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview"
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
androidx-test-core-ktx = { group = "androidx.test", name = "core-ktx", version.ref = "coreKtx" }
androidx-ui-desktop = { group = "androidx.compose.ui", name = "ui-desktop", version.ref = "uiDesktop" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
Expand Down

0 comments on commit d967135

Please sign in to comment.