@craft-native/android 0.0.193 → 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
|
@@ -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
|
|
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
|