craft-native 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.
|
@@ -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
|
package/dist/cli.js
CHANGED
|
@@ -3424,7 +3424,7 @@ function pinCraftNativeDependency(packagePath, craftVersion) {
|
|
|
3424
3424
|
`);
|
|
3425
3425
|
}
|
|
3426
3426
|
// package.json
|
|
3427
|
-
var version = "0.0.
|
|
3427
|
+
var version = "0.0.194";
|
|
3428
3428
|
|
|
3429
3429
|
// bin/cli.ts
|
|
3430
3430
|
var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -4406,6 +4406,11 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
4406
4406
|
navigationController?.setNavigationBarHidden(hidden, animated: view.window != nil)
|
|
4407
4407
|
}
|
|
4408
4408
|
}
|
|
4409
|
+
if options.keys.contains("leftButtons") {
|
|
4410
|
+
let buttons = (options["leftButtons"] as? [[String: Any]]) ?? []
|
|
4411
|
+
navigationItem.leftItemsSupplementBackButton = true
|
|
4412
|
+
navigationItem.leftBarButtonItems = buttons.compactMap(navigationButton)
|
|
4413
|
+
}
|
|
4409
4414
|
if options.keys.contains("rightButtons") {
|
|
4410
4415
|
let buttons = (options["rightButtons"] as? [[String: Any]]) ?? []
|
|
4411
4416
|
navigationItem.rightBarButtonItems = buttons.compactMap(navigationButton).reversed()
|
|
@@ -4480,6 +4485,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
4480
4485
|
} else {
|
|
4481
4486
|
item.accessibilityLabel = id
|
|
4482
4487
|
}
|
|
4488
|
+
if spec["variant"] as? String == "neutral" { item.tintColor = .label }
|
|
4483
4489
|
if let tint = (spec["color"] as? String).flatMap({ UIColor(hex: $0) }) { item.tintColor = tint }
|
|
4484
4490
|
// `image`: a picture (an https URL, the account's own photo), drawn
|
|
4485
4491
|
// round as iOS draws an account button. The symbol or title shows
|