Skip to content

Commit

Permalink
Recycler view fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownJoe796 committed Dec 20, 2024
1 parent 5c81229 commit c309478
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 97 deletions.
2 changes: 1 addition & 1 deletion example-app-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {

defaultConfig {
applicationId = "com.lightningkite.kiteuiexample"
minSdk = 26
minSdk = 21
targetSdk = 34
versionCode = 1
versionName = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion example-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ android {
compileSdk = 31

defaultConfig {
minSdk = 26
minSdk = 21
}
compileOptions {
// Flag to enable support for the new language APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,17 @@ object RecyclerViewScreen : Screen {
recyclerView = this
spacing = 0.5.rem
// columns = 2
reactive {
val index = expanded()
if(index == -1) return@reactive
launch {
delay(250)
// this@recyclerView.scrollToIndex(index - 1, Align.Start, true)
}
}
this.scrollToIndex(10, Align.Start)
children(items) {
col child@{
reactive {
val index = it()
if(expanded() == index){
launch {
delay(250)
this@recyclerView.scrollToIndex(index - 1, Align.Start, true)
}
}
}
dynamicTheme {
if (it() == 50) ImportantSemantic
else if (it() % 7 == 0) HoverSemantic
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ android {
compileSdk = 34

defaultConfig {
minSdk = 26
minSdk = 21
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.lightningkite.kiteui.views.direct
import android.content.res.ColorStateList
import android.graphics.drawable.ClipDrawable
import android.graphics.drawable.ShapeDrawable
import android.os.Build.VERSION
import android.os.Build.VERSION_CODES
import android.view.Gravity
import com.lightningkite.kiteui.models.Theme
import com.lightningkite.kiteui.views.RContext
Expand All @@ -11,15 +13,17 @@ import kotlin.math.roundToInt

actual class ProgressBar actual constructor(context: RContext): RView(context) {
override val native = android.widget.ProgressBar(context.activity, null, android.R.attr.progressBarStyleHorizontal).apply {
min = 0
// min = 0
max = 10000

// The default drawable uses a fixed height; use a custom drawable to support progress bars of any height
progressDrawable = ClipDrawable(ShapeDrawable(), Gravity.START, ClipDrawable.HORIZONTAL)
clipToOutline = true
}
override fun applyForeground(theme: Theme) {
native.setProgressTintList(ColorStateList.valueOf(theme.foreground.colorInt()))
if(VERSION.SDK_INT >= VERSION_CODES.O) {
native.setProgressTintList(ColorStateList.valueOf(theme.foreground.colorInt()))
}
native.setPaddingAll(0)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.lightningkite.kiteui.views.direct

import android.graphics.Paint
import android.os.Build.VERSION
import android.os.Build.VERSION_CODES
import android.text.InputType
import android.text.method.PasswordTransformationMethod
import android.util.TypedValue
Expand Down Expand Up @@ -176,12 +178,14 @@ var EditText.keyboardHints: KeyboardHints
InputType.TYPE_CLASS_DATETIME -> KeyboardHints(KeyboardCase.None, KeyboardType.Text)
else -> KeyboardHints(KeyboardCase.None, KeyboardType.Text)
}.let {
autofillHints?.let { hints ->
return if (hints.contains(View.AUTOFILL_HINT_EMAIL_ADDRESS)) it.copy(autocomplete = AutoComplete.Email)
else if (hints.contains(View.AUTOFILL_HINT_PASSWORD)) it.copy(autocomplete = AutoComplete.Password)
else if (hints.contains(View.AUTOFILL_HINT_PHONE)) it.copy(autocomplete = AutoComplete.Phone)
else it
} ?: it
if(VERSION.SDK_INT >= VERSION_CODES.O) {
autofillHints?.let { hints ->
return if (hints.contains(View.AUTOFILL_HINT_EMAIL_ADDRESS)) it.copy(autocomplete = AutoComplete.Email)
else if (hints.contains(View.AUTOFILL_HINT_PASSWORD)) it.copy(autocomplete = AutoComplete.Password)
else if (hints.contains(View.AUTOFILL_HINT_PHONE)) it.copy(autocomplete = AutoComplete.Phone)
else it
} ?: it
} else it
}
}
set(value) {
Expand All @@ -204,10 +208,12 @@ var EditText.keyboardHints: KeyboardHints
it or (this.inputType and (InputType.TYPE_TEXT_FLAG_MULTI_LINE or InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE))
}
n.inputType = inputType
when (value.autocomplete) {
AutoComplete.Email -> View.AUTOFILL_HINT_EMAIL_ADDRESS
AutoComplete.Password, AutoComplete.NewPassword -> View.AUTOFILL_HINT_PASSWORD
AutoComplete.Phone -> View.AUTOFILL_HINT_PHONE
null -> null
}?.let { n.setAutofillHints(it) }
if(VERSION.SDK_INT >= VERSION_CODES.O) {
when (value.autocomplete) {
AutoComplete.Email -> View.AUTOFILL_HINT_EMAIL_ADDRESS
AutoComplete.Password, AutoComplete.NewPassword -> View.AUTOFILL_HINT_PASSWORD
AutoComplete.Phone -> View.AUTOFILL_HINT_PHONE
null -> null
}?.let { n.setAutofillHints(it) }
}
}
Loading

0 comments on commit c309478

Please sign in to comment.