Skip to content

Commit

Permalink
Merge pull request #80 from Konyaco/gallery/buildKonfig
Browse files Browse the repository at this point in the history
[gallery] Refactor: Migrate SettingsScreen to new UI
  • Loading branch information
Sanlorng authored Nov 8, 2024
2 parents 0ce7bec + b5ef920 commit 43768b6
Show file tree
Hide file tree
Showing 11 changed files with 409 additions and 473 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ object BuildConfig {
var integerVersionName: String = ""
internal set

var branch: String = "dev"
internal set

object Android {
const val compileSdkVersion = 34

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.konyaco.fluent.plugin.build

import com.konyaco.fluent.plugin.build.BuildConfig.branch
import com.konyaco.fluent.plugin.build.BuildConfig.integerVersionName
import com.konyaco.fluent.plugin.build.BuildConfig.isRelease
import com.konyaco.fluent.plugin.build.BuildConfig.libraryVersion
import com.konyaco.fluent.plugin.build.BuildConfig.snapshotLibraryVersion
Expand Down Expand Up @@ -103,10 +105,20 @@ class BuildPlugin : Plugin<Project> {
private fun setupLibraryVersion(target: Project) {
val providers = target.providers

providers.exec {
commandLine("git", "branch", "--show-current")
isIgnoreExitValue = true
}.standardOutput
.asText
.orNull
?.trim()
?.let { branch = it }

val gitTag = providers.exec {
commandLine("git", "describe", "--abbrev=0", "--tags")
isIgnoreExitValue = true
}.standardOutput.asText.get().trim()

val relativeCommitCount = providers.exec {
commandLine("git", "describe", "--tags")
isIgnoreExitValue = true
Expand All @@ -125,7 +137,7 @@ class BuildPlugin : Plugin<Project> {
else -> snapshotLibraryVersion
}

BuildConfig.integerVersionName = libraryVersion
integerVersionName = libraryVersion
.removePrefix("v")
.removeSuffix("-SNAPSHOT")
.substringBefore("-dev")
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.build.konfig) apply false
id("com.konyaco.fluent.plugin.build")
}

Expand Down
19 changes: 19 additions & 0 deletions gallery/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.api.variant.impl.VariantOutputImpl
import com.codingfeline.buildkonfig.compiler.FieldSpec
import com.konyaco.fluent.plugin.build.BuildConfig
import com.konyaco.fluent.plugin.build.applyTargets
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
Expand All @@ -10,6 +11,7 @@ plugins {
alias(libs.plugins.compose)
alias(libs.plugins.android.application)
alias(libs.plugins.ksp)
alias(libs.plugins.build.konfig)
}

kotlin {
Expand Down Expand Up @@ -159,6 +161,9 @@ compose.desktop {
windows {
iconFile.set(project.file("icons/icon.ico"))
upgradeUuid = "a23572e1-c6fd-4b76-98ec-1e45953eb941"
shortcut = true
menu = true
perUserInstall = true
}
linux {
iconFile.set(project.file("icons/icon.png"))
Expand All @@ -167,6 +172,20 @@ compose.desktop {
}
}

buildkonfig {
packageName = "${BuildConfig.packageName}.build"

defaultConfigs {
buildConfigField(FieldSpec.Type.STRING, "LIBRARY_VERSION", BuildConfig.libraryVersion, const = true)
buildConfigField(FieldSpec.Type.STRING, "GALLERY_VERSION", BuildConfig.integerVersionName, const = true)
buildConfigField(FieldSpec.Type.STRING, "COMPOSE_VERSION", libs.versions.compose.get(), const = true)
buildConfigField(FieldSpec.Type.STRING, "KOTLIN_VERSION", libs.versions.kotlin.get(), const = true)
buildConfigField(FieldSpec.Type.STRING, "HAZE_VERSION", libs.versions.haze.get(), const = true)

buildConfigField(FieldSpec.Type.STRING, "CURRENT_BRANCH", BuildConfig.branch, const = true)
}
}

dependencies {
val processor = project(":gallery-processor")
add("kspCommonMainMetadata", processor)
Expand Down
Binary file modified gallery/src/commonMain/composeResources/drawable/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ fun App(
}
},
footer = {
val settingItem = remember(navigator) {
ComponentItem("Settings", group = "", description = "", icon = Icons.Default.Settings) { SettingsScreen(navigator) }
}
NavigationItem(navigator.latestBackEntry, navigator::navigate, settingItem)
}
) {
Expand Down Expand Up @@ -237,6 +240,4 @@ private fun NavigationItem(
}
}
)
}

private val settingItem = ComponentItem("Settings", group = "", description = "", icon = Icons.Default.Settings) { SettingsScreen() }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.konyaco.fluent.gallery

import com.konyaco.fluent.build.BuildKonfig

object ProjectUrl {

const val ROOT = "https://github.com/Konyaco/compose-fluent-ui"
Expand All @@ -10,7 +12,7 @@ object ProjectUrl {

const val FEED_BACK = "$ROOT/issues/new/choose"

private const val BRANCH = "master"
private const val BRANCH = BuildKonfig.CURRENT_BRANCH

fun componentCodeOf(path: String): String {
return "$ROOT/tree/$BRANCH/$path"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.konyaco.fluent.FluentTheme
import com.konyaco.fluent.build.BuildKonfig
import com.konyaco.fluent.component.Icon
import com.konyaco.fluent.component.Text
import com.konyaco.fluent.gallery.LocalStore
Expand Down Expand Up @@ -86,13 +87,25 @@ fun HomeScreen() {
contentDescription = null,
modifier = Modifier.scale(2.05f)
)
Text(
modifier = Modifier.align(Alignment.BottomEnd).padding(16.dp),
text = "Compose\nFluent Design",
style = FluentTheme.typography.titleLarge,
textAlign = TextAlign.End,
color = FluentTheme.colors.text.text.primary
)
Column(
Modifier.padding(16.dp).align(Alignment.BottomEnd),
horizontalAlignment = Alignment.End
) {
Text(
modifier = Modifier,
text = "Compose\nFluent Design",
style = FluentTheme.typography.title,
textAlign = TextAlign.End,
color = FluentTheme.colors.text.text.primary
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = BuildKonfig.LIBRARY_VERSION,
style = FluentTheme.typography.body,
textAlign = TextAlign.End,
color = FluentTheme.colors.text.text.secondary
)
}
}

Card(
Expand Down
Loading

0 comments on commit 43768b6

Please sign in to comment.