mirror of
https://github.com/msfjarvis/compose-lobsters.git
synced 2024-06-03 04:18:58 +05:30
all: commonize theming
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
d63a331325
commit
090c3c2017
|
@ -3,27 +3,16 @@ package dev.msfjarvis.claw.android
|
|||
import android.os.Bundle
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import dev.msfjarvis.claw.android.theme.LobstersTheme
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import dev.msfjarvis.claw.common.posts.LobstersItem
|
||||
import dev.msfjarvis.lobsters.data.local.SavedPost
|
||||
|
||||
val TEST_POST =
|
||||
SavedPost(
|
||||
shortId = "zqyydb",
|
||||
title = "k2k20 hackathon report: Bob Beck on LibreSSL progress",
|
||||
url = "https://undeadly.org/cgi?action=article;sid=20200921105847",
|
||||
createdAt = "2020-09-21T07:11:14.000-05:00",
|
||||
commentsUrl = "https://lobste.rs/s/zqyydb/k2k20_hackathon_report_bob_beck_on",
|
||||
submitterName = "Vigdis",
|
||||
submitterAvatarUrl = "/404.html",
|
||||
tags = listOf("openbsd", "linux", "containers", "hack the planet", "no thanks"),
|
||||
)
|
||||
import dev.msfjarvis.claw.common.posts.TEST_POST
|
||||
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
LobstersTheme {
|
||||
LobstersTheme(darkTheme = isSystemInDarkTheme()) {
|
||||
LobstersItem(
|
||||
post = TEST_POST,
|
||||
isSaved = false,
|
||||
|
|
|
@ -22,14 +22,26 @@ import androidx.compose.material.Text
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.google.accompanist.flowlayout.FlowRow
|
||||
import dev.msfjarvis.claw.common.theme.titleColor
|
||||
import dev.msfjarvis.lobsters.data.local.SavedPost
|
||||
import io.kamel.image.KamelImage
|
||||
import io.kamel.image.lazyImageResource
|
||||
|
||||
val TEST_POST =
|
||||
SavedPost(
|
||||
shortId = "zqyydb",
|
||||
title = "k2k20 hackathon report: Bob Beck on LibreSSL progress",
|
||||
url = "https://undeadly.org/cgi?action=article;sid=20200921105847",
|
||||
createdAt = "2020-09-21T07:11:14.000-05:00",
|
||||
commentsUrl = "https://lobste.rs/s/zqyydb/k2k20_hackathon_report_bob_beck_on",
|
||||
submitterName = "Vigdis",
|
||||
submitterAvatarUrl = "/404.html",
|
||||
tags = listOf("openbsd", "linux", "containers", "hack the planet", "no thanks"),
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun LobstersItem(
|
||||
post: SavedPost,
|
||||
|
@ -84,7 +96,7 @@ fun PostTitle(
|
|||
) {
|
||||
Text(
|
||||
text = title,
|
||||
color = Color.Black,
|
||||
color = titleColor,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.then(modifier),
|
||||
)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.msfjarvis.claw.android.theme
|
||||
package dev.msfjarvis.claw.common.theme
|
||||
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.darkColors
|
||||
import androidx.compose.material.lightColors
|
||||
|
@ -34,9 +33,9 @@ val darkColors =
|
|||
)
|
||||
|
||||
@Composable
|
||||
fun LobstersTheme(children: @Composable () -> Unit) {
|
||||
fun LobstersTheme(darkTheme: Boolean, children: @Composable () -> Unit) {
|
||||
MaterialTheme(
|
||||
colors = if (isSystemInDarkTheme()) darkColors else lightColors,
|
||||
colors = if (darkTheme) darkColors else lightColors,
|
||||
content = children,
|
||||
)
|
||||
}
|
|
@ -14,7 +14,9 @@ kotlin {
|
|||
dependencies { implementation(libs.thirdparty.sqldelight.androidDriver) }
|
||||
}
|
||||
val androidTest by getting
|
||||
val desktopMain by getting { dependencies { implementation(libs.thirdparty.sqldelight.jvmDriver) } }
|
||||
val desktopMain by getting {
|
||||
dependencies { implementation(libs.thirdparty.sqldelight.jvmDriver) }
|
||||
}
|
||||
val desktopTest by getting {
|
||||
dependencies {
|
||||
implementation(libs.kotlin.coroutines.core)
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
import androidx.compose.desktop.Window
|
||||
import dev.msfjarvis.claw.common.App
|
||||
import dev.msfjarvis.claw.common.posts.LobstersItem
|
||||
import dev.msfjarvis.claw.common.posts.TEST_POST
|
||||
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
||||
|
||||
fun main() = Window { App() }
|
||||
fun main() = Window {
|
||||
LobstersTheme(darkTheme = true) {
|
||||
LobstersItem(
|
||||
post = TEST_POST,
|
||||
isSaved = false,
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user