craft-native 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/dist/android/templates/CraftNativeShell.kt.template +12 -2
- package/dist/android/templates/MainActivityNative.kt.template +8 -4
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/ios/templates/CraftNativeScreen.swift +17 -4
- package/package.json +1 -1
|
@@ -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
|
|
@@ -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
|
-
|
|
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
|
-
|
|
5550
|
-
|
|
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
|
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
|
@@ -726,6 +726,11 @@ private func craftNativeAlignContentCode(_ value: String) -> UInt32 {
|
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
+
/// Keep the indicator's intrinsic size separate from authored style transforms.
|
|
730
|
+
private final class CraftNativeActivityIndicatorView: UIActivityIndicatorView {
|
|
731
|
+
var indicatorScale: CGFloat = 1
|
|
732
|
+
}
|
|
733
|
+
|
|
729
734
|
/// A native screen's `<Video>`: AVPlayerViewController in place.
|
|
730
735
|
///
|
|
731
736
|
/// With sound, a video takes the audio session as a playing sound does
|
|
@@ -4401,6 +4406,11 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
4401
4406
|
navigationController?.setNavigationBarHidden(hidden, animated: view.window != nil)
|
|
4402
4407
|
}
|
|
4403
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
|
+
}
|
|
4404
4414
|
if options.keys.contains("rightButtons") {
|
|
4405
4415
|
let buttons = (options["rightButtons"] as? [[String: Any]]) ?? []
|
|
4406
4416
|
navigationItem.rightBarButtonItems = buttons.compactMap(navigationButton).reversed()
|
|
@@ -4475,6 +4485,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
4475
4485
|
} else {
|
|
4476
4486
|
item.accessibilityLabel = id
|
|
4477
4487
|
}
|
|
4488
|
+
if spec["variant"] as? String == "neutral" { item.tintColor = .label }
|
|
4478
4489
|
if let tint = (spec["color"] as? String).flatMap({ UIColor(hex: $0) }) { item.tintColor = tint }
|
|
4479
4490
|
// `image`: a picture (an https URL, the account's own photo), drawn
|
|
4480
4491
|
// round as iOS draws an account button. The symbol or title shows
|
|
@@ -5510,7 +5521,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
5510
5521
|
updateHandler(nonEmptyHandler(events["onValueChange"]) ?? nonEmptyHandler(events["onChange"]), for: slider)
|
|
5511
5522
|
updateAuxiliaryHandler(events["onSlidingComplete"], in: &sliderCompleteHandlers, for: slider)
|
|
5512
5523
|
case "ActivityIndicator":
|
|
5513
|
-
let indicator = result as!
|
|
5524
|
+
let indicator = result as! CraftNativeActivityIndicatorView
|
|
5514
5525
|
let requestedSize = props["size"]
|
|
5515
5526
|
indicator.style = (requestedSize as? String) == "large" ? .large : .medium
|
|
5516
5527
|
let scale: CGFloat
|
|
@@ -5522,7 +5533,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
5522
5533
|
} else {
|
|
5523
5534
|
scale = 1
|
|
5524
5535
|
}
|
|
5525
|
-
indicator.
|
|
5536
|
+
indicator.indicatorScale = scale
|
|
5526
5537
|
indicator.color = color(props["color"]) ?? .tintColor
|
|
5527
5538
|
indicator.hidesWhenStopped = props["hidesWhenStopped"] as? Bool ?? true
|
|
5528
5539
|
if props["animating"] as? Bool == false {
|
|
@@ -5728,7 +5739,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
5728
5739
|
slider.addTarget(self, action: #selector(sliderFinished(_:)), for: [.touchUpInside, .touchUpOutside, .touchCancel])
|
|
5729
5740
|
return slider
|
|
5730
5741
|
case "ActivityIndicator":
|
|
5731
|
-
return
|
|
5742
|
+
return CraftNativeActivityIndicatorView(style: .medium)
|
|
5732
5743
|
case "StatusBar", "RefreshControl":
|
|
5733
5744
|
return CraftNativeFlowView()
|
|
5734
5745
|
case "Image":
|
|
@@ -6437,8 +6448,9 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
6437
6448
|
}
|
|
6438
6449
|
|
|
6439
6450
|
private func applyTransform(_ raw: Any?, to view: UIView) {
|
|
6440
|
-
|
|
6451
|
+
let intrinsicScale = (view as? CraftNativeActivityIndicatorView)?.indicatorScale ?? 1
|
|
6441
6452
|
view.layer.transform = CATransform3DIdentity
|
|
6453
|
+
view.transform = CGAffineTransform(scaleX: intrinsicScale, y: intrinsicScale)
|
|
6442
6454
|
guard let transforms = raw as? [[String: Any]] else { return }
|
|
6443
6455
|
var affine = CGAffineTransform.identity
|
|
6444
6456
|
var threeDimensional = CATransform3DIdentity
|
|
@@ -6461,6 +6473,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
6461
6473
|
hasThreeDimensionalRotation = true
|
|
6462
6474
|
}
|
|
6463
6475
|
}
|
|
6476
|
+
affine = affine.scaledBy(x: intrinsicScale, y: intrinsicScale)
|
|
6464
6477
|
if hasThreeDimensionalRotation {
|
|
6465
6478
|
view.layer.transform = CATransform3DConcat(CATransform3DMakeAffineTransform(affine), threeDimensional)
|
|
6466
6479
|
} else {
|