@craft-native/android 0.0.192 → 0.0.194

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craft-native/android",
3
- "version": "0.0.192",
3
+ "version": "0.0.194",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/android#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -571,6 +571,7 @@ internal class CraftNativeChrome(context: Context, private val tabs: List<CraftN
571
571
  val content = FrameLayout(context)
572
572
  private val bar = LinearLayout(context)
573
573
  private val backButton = ImageView(context)
574
+ private val leadingButtons = LinearLayout(context)
574
575
  private val titleView = TextView(context)
575
576
  private val largeTitleView = TextView(context)
576
577
  private val buttons = LinearLayout(context)
@@ -609,6 +610,9 @@ internal class CraftNativeChrome(context: Context, private val tabs: List<CraftN
609
610
  backButton.background = rippleBackground()
610
611
  backButton.setOnClickListener { onBack?.invoke() }
611
612
  bar.addView(backButton, LayoutParams(dp(48), dp(48)))
613
+ leadingButtons.orientation = HORIZONTAL
614
+ leadingButtons.gravity = Gravity.CENTER_VERTICAL
615
+ bar.addView(leadingButtons, LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dp(56)))
612
616
  titleView.textSize = 20f
613
617
  titleView.typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL)
614
618
  titleView.isSingleLine = true
@@ -717,6 +721,12 @@ internal class CraftNativeChrome(context: Context, private val tabs: List<CraftN
717
721
  largeTitleView.text = title
718
722
  largeTitleView.visibility = if (!hidden && large && title.isNotBlank()) View.VISIBLE else View.GONE
719
723
  buttons.removeAllViews()
724
+ leadingButtons.removeAllViews()
725
+ val leading = options.optJSONArray("leftButtons") ?: JSONArray()
726
+ for (index in 0 until leading.length()) {
727
+ val button = leading.optJSONObject(index) ?: continue
728
+ leadingButtons.addView(navButton(button))
729
+ }
720
730
  val list = options.optJSONArray("rightButtons") ?: JSONArray()
721
731
  for (index in 0 until list.length()) {
722
732
  val button = list.optJSONObject(index) ?: continue
@@ -796,7 +806,6 @@ internal class CraftNativeChrome(context: Context, private val tabs: List<CraftN
796
806
  icon.foreground = vector
797
807
  icon.text = if (vector != null) "" else number ?: CraftNativeSymbols.glyph(tabs[index].symbol)
798
808
  }
799
- for (index in 0 until buttons.childCount) (buttons.getChildAt(index) as? TextView)?.setTextColor(accent)
800
809
  }
801
810
 
802
811
  private fun navButton(button: JSONObject): View {
@@ -805,7 +814,8 @@ internal class CraftNativeChrome(context: Context, private val tabs: List<CraftN
805
814
  val symbol = button.optString("symbol")
806
815
  val view = TextView(context)
807
816
  val dark = Color.luminance(ContextCompat.getColor(context, R.color.background)) < 0.5
808
- val tint = button.optString("color").takeIf { it.isNotBlank() }?.let { runCatching { craftNativeColor(it) }.getOrNull() } ?: accentColor(dark)
817
+ val defaultTint = if (button.optString("variant") == "neutral") { if (dark) Color.WHITE else Color.parseColor("#1C1C1E") } else accentColor(dark)
818
+ val tint = button.optString("color").takeIf { it.isNotBlank() }?.let { runCatching { craftNativeColor(it) }.getOrNull() } ?: defaultTint
809
819
  val vector = if (symbol.isNotBlank()) CraftNativeIcons.drawable(context, null, symbol, tint) else null
810
820
  view.text = if (vector != null) "" else if (symbol.isNotBlank()) CraftNativeSymbols.glyph(symbol) else title
811
821
  view.textSize = if (symbol.isNotBlank()) 22f else 16f
@@ -2458,6 +2458,8 @@ private data class LayoutBounds(
2458
2458
  */
2459
2459
  private class CraftNativeActivityIndicator(context: Context) :
2460
2460
  android.widget.ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal) {
2461
+ var indicatorScale = 1f
2462
+
2461
2463
  init {
2462
2464
  val spinner = android.widget.ProgressBar(context).indeterminateDrawable
2463
2465
  indeterminateDrawable = spinner
@@ -4903,8 +4905,7 @@ class MainActivity : AppCompatActivity() {
4903
4905
  is Number -> (requestedSize.toDouble() / 24.0).takeIf { it.isFinite() }?.toFloat()?.coerceAtLeast(0.5f) ?: 1f
4904
4906
  else -> 1f
4905
4907
  }
4906
- scaleX = scale
4907
- scaleY = scale
4908
+ indicatorScale = scale
4908
4909
  val animating = props.optBoolean("animating", true)
4909
4910
  isIndeterminate = animating
4910
4911
  visibility = if (!animating && props.optBoolean("hidesWhenStopped", true)) View.GONE else View.VISIBLE
@@ -5546,8 +5547,11 @@ class MainActivity : AppCompatActivity() {
5546
5547
  private fun applyTransform(view: View, transforms: JSONArray?) {
5547
5548
  view.translationX = 0f
5548
5549
  view.translationY = 0f
5549
- view.scaleX = 1f
5550
- view.scaleY = 1f
5550
+ // Reconciliation reapplies transforms; start from the control's
5551
+ // intrinsic scale rather than erasing its authored indicator size.
5552
+ val intrinsicScale = (view as? CraftNativeActivityIndicator)?.indicatorScale ?: 1f
5553
+ view.scaleX = intrinsicScale
5554
+ view.scaleY = intrinsicScale
5551
5555
  view.rotation = 0f
5552
5556
  view.rotationX = 0f
5553
5557
  view.rotationY = 0f