Skip to content

Commit

Permalink
Dropdown fix
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownJoe796 committed Mar 15, 2024
1 parent 1e39faa commit 1f0bb6a
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 47 deletions.
1 change: 0 additions & 1 deletion example-app-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.lightningkite.mppexampleapp
import com.lightningkite.rock.*
import com.lightningkite.rock.models.Align
import com.lightningkite.rock.models.SizeConstraints
import com.lightningkite.rock.models.px
import com.lightningkite.rock.models.rem
import com.lightningkite.rock.navigation.RockScreen
import com.lightningkite.rock.reactive.*
Expand Down Expand Up @@ -52,6 +53,7 @@ object RecyclerViewScreen : RockScreen {
}
recyclerView {
recyclerView = this
spacing = 0.5.rem
// columns = 2
children(items) {
themeFromLast { theme ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object ViewPagerElementScreen: DocScreen {
text("You can use a view pager to create an element that scrolls horizontally displaying pages.")
text("This is frequently used for browsing photos or advertising features.")
text("V2")
val currentPage = Property(0)
val currentPage = Property(9)
val items = Constant((1..30).toList())
example("""
val currentPage = Property(0)
Expand Down
2 changes: 1 addition & 1 deletion library/library.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Pod::Spec.new do |spec|
fi
set -ev
REPO_ROOT="$PODS_TARGET_SRCROOT"
"$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \
"$REPO_ROOT/../../picme-frontend/gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \
-Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
-Pkotlin.native.cocoapods.archs="$ARCHS" \
-Pkotlin.native.cocoapods.configuration="$CONFIGURATION"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.lightningkite.rock.views.direct

import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.widget.TextView
Expand Down Expand Up @@ -45,7 +47,7 @@ actual fun <T> Select.bind(
return convertView
} else {
with(native.viewWriter) {
padded - text {
text {
content = render(list[position])
}
}
Expand Down Expand Up @@ -98,8 +100,10 @@ actual fun <T> Select.bind(
}

@ViewDsl
actual inline fun ViewWriter.selectActual(crossinline setup: Select.() -> Unit) {
actual fun ViewWriter.selectActual(setup: Select.() -> Unit) {
return viewElement(factory = ::NSelect, wrapper = ::Select, setup = {
native.viewWriter = newViews()
setup(this)
handleThemeControl(native, viewLoads = true, customDrawable = {
// LayerDrawable has poor interfaces for dynamically adding layers, so we have to do this to be able to
// safely call setDrawable(1, ...) later
Expand All @@ -113,42 +117,11 @@ actual inline fun ViewWriter.selectActual(crossinline setup: Select.() -> Unit)
setDrawable(1, dropdown)
setLayerGravity(1, Gravity.END or Gravity.CENTER_VERTICAL)
setLayerInsetEnd(1, it.spacing.value.toInt())
},background = {
}, foreground = { theme, nselect -> nselect.setPaddingAll(0) }, background = {
native.setPopupBackgroundDrawable(it.backgroundDrawable(8.dp.value, true))
}) {
native.viewWriter = newViews()
setup(this)
}
})
}


data class SpinnerTextStyle(
val textColor: Int,
val textSize: Float,
val paddingLeft: Int,
val paddingTop: Int,
val paddingRight: Int,
val paddingBottom: Int,
val typeface: Typeface?,
val letterSpacing: Float?,
val lineSpacingMultiplier: Float?,
val gravity: Int,
) {
fun apply(to: TextView) {
to.gravity = gravity
to.setTextColor(textColor)
to.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
to.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom)
letterSpacing?.let { to.letterSpacing = it }
lineSpacingMultiplier?.let { to.setLineSpacing(0f, it) }
typeface?.let { to.typeface = it }
}
}

var Spinner.spinnerTextStyle: SpinnerTextStyle?
get() = spinnerTextStyleMap[this]
set(value) {
spinnerTextStyleMap[this] = value
}
private val spinnerTextStyleMap = WeakHashMap<Spinner, SpinnerTextStyle>()
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ object DynamicCSS {
style(
".toggle-button", mapOf(
"display" to "flex",
"align-items" to "center",
"align-items" to "stretch",
)
)

Expand Down Expand Up @@ -788,7 +788,7 @@ object DynamicCSS {
)

style(
".notransition *", mapOf(
".notransition, .notransition *", mapOf(
"transition" to "none !important"
)
)
Expand Down Expand Up @@ -835,17 +835,17 @@ object DynamicCSS {
style(".contentScroll-V > *", mapOf(
"position" to "absolute",
"max-height" to "unset",
"width" to "calc(100% - var(--spacing, 0px) * var(--usePadding, 0) * 2)",
"margin-left" to "calc(var(--spacing, 0px) * var(--usePadding, 0))",
"margin-right" to "calc(var(--spacing, 0px) * var(--usePadding, 0))",
"width" to "calc(100% - var(--parentSpacing, 0px) * var(--usePadding, 0) * 2)",
"margin-left" to "calc(var(--parentSpacing, 0px) * var(--usePadding, 0))",
"margin-right" to "calc(var(--parentSpacing, 0px) * var(--usePadding, 0))",
"overflow-anchor" to "revert",
))
style(".contentScroll-H > *", mapOf(
"max-width" to "unset",
"position" to "absolute",
"height" to "calc(100% - var(--spacing, 0px) * var(--usePadding, 0) * 2)",
"margin-top" to "calc(var(--spacing, 0px) * var(--usePadding, 0))",
"margin-bottom" to "calc(var(--spacing, 0px) * var(--usePadding, 0))",
"height" to "calc(100% - var(--parentSpacing, 0px) * var(--usePadding, 0) * 2)",
"margin-top" to "calc(var(--parentSpacing, 0px) * var(--usePadding, 0))",
"margin-bottom" to "calc(var(--parentSpacing, 0px) * var(--usePadding, 0))",
"overflow-anchor" to "revert",
))
style(".contentScroll-V > .recyclerViewGridSub", mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ actual inline fun NView.withoutAnimation(action: () -> Unit) {
}
try {
animationsEnabled = false
clientWidth
classList.add("notransition")
clientWidth
action()
} finally {
offsetHeight // force layout calculation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ actual inline fun ViewWriter.radioToggleButtonActual(crossinline setup: RadioTog
this.style.display = "none"
}
themedElementClickable<HTMLSpanElement>("span") {
classList.add("checkResponsive")
classList.add("checkResponsive", "rock-stack")
tabIndex = 0
setup(RadioToggleButton(this))
addEventListener("keydown", { ev ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ class RecyclerController2(

fun ready() {
lock("ready") {
spacing = window.getComputedStyle(root).columnGap.removeSuffix("px").toDouble().toInt()
populate()
forceCenteringHandler()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ actual inline fun ViewWriter.toggleButtonActual(crossinline setup: ToggleButton.
this.style.display = "none"
}
themedElementClickable<HTMLSpanElement>("span") {
classList.add("checkResponsive")
classList.add("checkResponsive", "rock-stack")
tabIndex = 0
setup(ToggleButton(this))
addEventListener("keydown", { ev ->
Expand Down

0 comments on commit 1f0bb6a

Please sign in to comment.