@onekeyfe/react-native-bottom-tabs 6.7.0-alpha.386 → 6.7.0-alpha.389

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.
@@ -75,6 +75,8 @@ class RCTBottomTabsContainerView: UIView {
75
75
  private var reportedTabBarPlacement: String?
76
76
  private var sideAccessoryButton: UIButton?
77
77
  private var loadedSideAccessoryIcon: UIImage?
78
+ // Increments per icon load; a completion applies only to the latest one.
79
+ private var sideAccessoryIconRequest = 0
78
80
  private var isSideAccessoryLayoutScheduled = false
79
81
  private static let sideAccessorySize: CGFloat = 48
80
82
  private static let sideAccessorySpacing: CGFloat = 12
@@ -336,12 +338,16 @@ class RCTBottomTabsContainerView: UIView {
336
338
  }
337
339
 
338
340
  private func loadSideAccessoryIcon() {
339
- let source = sideAccessoryIcon.map { IconSource(dict: $0) }
340
- guard let source, let url = URL(string: source.uri) else {
341
+ sideAccessoryIconRequest += 1
342
+ let request = sideAccessoryIconRequest
343
+ // Drop the previous icon so a slower or failed load never leaves it shown
344
+ // for the new source.
345
+ if loadedSideAccessoryIcon != nil {
341
346
  loadedSideAccessoryIcon = nil
342
347
  scheduleSideAccessoryLayout()
343
- return
344
348
  }
349
+ let source = sideAccessoryIcon.map { IconSource(dict: $0) }
350
+ guard let source, let url = URL(string: source.uri) else { return }
345
351
  // The image loader arrives with the first state update; setImageLoader
346
352
  // calls this again.
347
353
  guard let imageLoader else { return }
@@ -356,7 +362,7 @@ class RCTBottomTabsContainerView: UIView {
356
362
  completionBlock: { [weak self] error, image in
357
363
  guard error == nil, let image else { return }
358
364
  DispatchQueue.main.async {
359
- guard let self else { return }
365
+ guard let self, request == self.sideAccessoryIconRequest else { return }
360
366
  self.loadedSideAccessoryIcon = image
361
367
  .resizeImageTo(size: self.iconSize)?
362
368
  .withRenderingMode(.alwaysTemplate)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-bottom-tabs",
3
- "version": "6.7.0-alpha.386",
3
+ "version": "6.7.0-alpha.389",
4
4
  "description": "Native bottom tabs (tab bar + scene container) for React Native on iOS and Android",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",