Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/version-3' into version-3
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownJoe796 committed Nov 26, 2024
2 parents e33fc0e + 5090795 commit 4904931
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.lightningkite.kiteui.views.direct

import android.widget.FrameLayout
import com.lightningkite.kiteui.models.DismissSemantic
import com.lightningkite.kiteui.models.Icon
import com.lightningkite.kiteui.models.Theme
import com.lightningkite.kiteui.models.ThemeAndBack
import com.lightningkite.kiteui.navigation.dialogScreenNavigator
import com.lightningkite.kiteui.navigation.screenNavigator
import com.lightningkite.kiteui.reactive.Action
Expand All @@ -22,12 +24,12 @@ actual class DismissBackground actual constructor(context: RContext): RView(cont
}
}

override fun applyBackground(theme: Theme, fullyApply: Boolean) {
val color = theme.background.closestColor()
native.setBackgroundColor(color.withAlpha(0.5f).toInt())
}
override fun postSetup() {
super.postSetup()
children.forEach { it.native.isClickable = true }
}

override fun applyState(theme: ThemeAndBack): ThemeAndBack {
return super.applyState(theme[DismissSemantic])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,25 @@ actual class MenuButton actual constructor(context: RContext): RView(context) {
}.run {
willRemove = dismissBackground {
themeChoice += ThemeDerivation {
it.copy(background = Color.transparent, revert = true).withBack
it.copy(
id = "mnubtndsm",
revert = true,
derivations = mapOf(
DismissSemantic to {
it.copy(
background = Color.transparent,
outlineWidth = 0.dp,
cornerRadii = CornerRadii.Constant(0.dp),
revert = true,
).withBack
}
)
).withBack
}
onClick {
closePopovers()
}
atTopStart - card - stack {
themeChoice += ThemeDerivation {
it.copy(elevation = 5.dp, revert = true).withBack
}
atTopStart - dialog - stack {
this@dismissBackground.native.apply {
clipChildren = false
clipToPadding = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ class KiteUiCss(val dynamicCss: DynamicCss) {
color: var(--icon-color, black);
}
.dismissBackground {
border-radius: 0px;
outline-width: 0px;
background-color: color-mix(in srgb, color-mix(in srgb, var(--nearest-background-color, black) 50%, black) 50%, transparent);
}
.padded:not(.unpadded):not(.isRoot):not(.swapImage) {
padding: var(--spacing, 0px);
}
Expand Down Expand Up @@ -295,15 +289,6 @@ class KiteUiCss(val dynamicCss: DynamicCss) {
scroll-behavior: auto;
}
.dismissBackground + * {
z-index: 999;
}
.dismissBackground {
z-index: 998;
pointer-events: auto;
}
.notransition, .notransition * {
transition: none !important;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.lightningkite.kiteui.views.direct

import com.lightningkite.kiteui.models.DismissSemantic
import com.lightningkite.kiteui.models.Theme
import com.lightningkite.kiteui.models.ThemeAndBack
import com.lightningkite.kiteui.navigation.dialogScreenNavigator
import com.lightningkite.kiteui.navigation.screenNavigator
import com.lightningkite.kiteui.views.*
Expand All @@ -10,7 +12,6 @@ import kotlinx.coroutines.launch
actual class DismissBackground actual constructor(context: RContext) : RView(context) {
init {
native.tag = "div"
native.classes.add("dismissBackground")
native.classes.add("kiteui-stack")
native.replaceEventListener("click") { dialogScreenNavigator.clear() }
}
Expand All @@ -28,10 +29,7 @@ actual class DismissBackground actual constructor(context: RContext) : RView(con
native.replaceEventListener("click") { launch { action() } }
}

override fun applyBackground(theme: Theme, fullyApply: Boolean) {
native.classes.removeAll { it.startsWith("t-") }
native.classes.addAll(context.kiteUiCss.themeInteractive(theme))

native.setStyleProperty("--parentSpacing", parentSpacing.value)
override fun applyState(theme: ThemeAndBack): ThemeAndBack {
return super.applyState(theme[DismissSemantic])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ data object CardSemantic : Semantic {
override fun default(theme: Theme): ThemeAndBack = theme.withBack
}

data object DismissSemantic : Semantic {
override val key: String = "dsmss"
override fun default(theme: Theme): ThemeAndBack = theme.copy(
spacing = 0.dp,
cornerRadii = CornerRadii.Constant(0.dp),
background = Color.black.applyAlpha(0.5f),
revert = true,
).withBack
}

data object FieldSemantic : Semantic {
override val key: String = "fld"
override fun default(theme: Theme): ThemeAndBack = theme.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ abstract class RViewHelper(override val context: RContext) : ViewWriter() {
return
}
if (parent?.fullyStarted == false) {

if (this == viewDebugTarget) println("refreshThemeing abandoned due to parent $parent not being fully started")
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fun ViewWriter.appNavBottomTabs(setup: AppNav.() -> Unit) {
centered - icon(Icon.chevronLeft, "Go Back")
centered - text {
::content {
screenNavigator.stack()?.let { it.getOrNull(it.size - 2) }?.title?.let { it() } ?: ""
screenNavigator.stack()?.let { it.getOrNull(it.size - 2) }?.title?.let { it().let{ if(it.length > 15) it.take(15) + "\u2026" else it } } ?: ""
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ actual class DismissBackground actual constructor(context: RContext) : RView(con
onClick { dialogScreenNavigator.clear() }
}

override fun applyBackground(theme: Theme, fullyApply: Boolean) {
val color = theme.background.closestColor()
native.backgroundColor = color.withAlpha(0.5f).toUiColor()
override fun applyState(theme: ThemeAndBack): ThemeAndBack {
return super.applyState(theme[DismissSemantic])
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,26 @@ actual class MenuButton actual constructor(context: RContext): RView(context) {
}.run {
willRemove = dismissBackground {
themeChoice += ThemeDerivation {
it.copy(background = Color.transparent).withBack
it.copy(
id = "mnubtndsm",
revert = true,
derivations = mapOf(
DismissSemantic to {
it.copy(
background = Color.transparent,
outlineWidth = 0.dp,
cornerRadii = CornerRadii.Constant(0.dp),
revert = true,
).withBack
}
)
).withBack
}
native.anchor = preferredDirection to this@MenuButton.native
onClick {
closePopovers()
}
card - stack {
themeChoice += ThemeDerivation {
it.copy(elevation = 5.dp, revert = true).withBack
}
dialog - stack {
createMenu()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ actual class NRecyclerView(): UIScrollView(CGRectMake(0.0, 0.0, 0.0, 0.0)),
set(value) {
field = value
if (value) {
val s = allSubviews.last().let { it.startPosition + it.size + spacingRaw }
val s = allSubviews.lastOrNull { it.visible }?.let { it.startPosition + it.size + spacingRaw } ?: return
setContentSize(if(vertical) CGSizeMake(0.0, s) else CGSizeMake(s, 0.0))
} else {
val s = reservedScrollingSpace
Expand Down Expand Up @@ -230,6 +230,7 @@ actual class NRecyclerView(): UIScrollView(CGRectMake(0.0, 0.0, 0.0, 0.0)),
if (allSubviews.any { it.needsLayout }) {
relayout()
}
capViewAtBottom = allSubviews.last().index >= dataDirect.max
}
} finally {
animationsEnabled = before
Expand Down

0 comments on commit 4904931

Please sign in to comment.