mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
Fixed kmp ios updating
commit_hash:ff04403354785808ec26c644c8be7a3f7e497f78
This commit is contained in:
+13
-8
@@ -1,7 +1,7 @@
|
||||
#if os(iOS)
|
||||
import UIKit
|
||||
|
||||
@_spi(Legacy) import DivKit
|
||||
import DivKit
|
||||
|
||||
internal import VGSLUI
|
||||
internal import DivKitExtensions
|
||||
@@ -29,13 +29,18 @@ internal import DivKitExtensions
|
||||
cardId: String
|
||||
) -> UIView {
|
||||
let divView = DivView(divKitComponents: divkitComponents)
|
||||
divView.setSource(
|
||||
DivViewSource(
|
||||
kind: .data(Data(jsonString.utf8)),
|
||||
cardId: DivCardID(rawValue: cardId)
|
||||
)
|
||||
)
|
||||
return DivKitKMPView(divView: divView)
|
||||
let kmpView = DivKitKMPView(divView: divView)
|
||||
kmpView.updateSourceIfNeeded(jsonString: jsonString, cardId: cardId)
|
||||
return kmpView
|
||||
}
|
||||
|
||||
@objc public func updateDivKitView(
|
||||
_ view: UIView,
|
||||
jsonString: String,
|
||||
cardId: String
|
||||
) {
|
||||
guard let kmpView = view as? DivKitKMPView else { return }
|
||||
kmpView.updateSourceIfNeeded(jsonString: jsonString, cardId: cardId)
|
||||
}
|
||||
|
||||
@objc public func getVariableValue(_ name: String) -> Any? {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#if os(iOS)
|
||||
import UIKit
|
||||
|
||||
import DivKit
|
||||
@_spi(Legacy) import DivKit
|
||||
|
||||
final class DivKitKMPView: UIView {
|
||||
override var intrinsicContentSize: CGSize {
|
||||
@@ -13,6 +13,7 @@ final class DivKitKMPView: UIView {
|
||||
}
|
||||
|
||||
private let divView: DivView
|
||||
private var current: (cardId: String, json: String) = ("", "")
|
||||
|
||||
init(divView: DivView) {
|
||||
self.divView = divView
|
||||
@@ -25,6 +26,18 @@ final class DivKitKMPView: UIView {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func updateSourceIfNeeded(jsonString: String, cardId: String) {
|
||||
guard cardId != current.cardId || jsonString != current.json else { return }
|
||||
current = (cardId, jsonString)
|
||||
divView.setSource(
|
||||
DivViewSource(
|
||||
kind: .data(Data(jsonString.utf8)),
|
||||
cardId: DivCardID(rawValue: cardId)
|
||||
),
|
||||
shouldResetPreviousCardData: true
|
||||
)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
|
||||
@@ -15,16 +15,16 @@ PODS:
|
||||
- DivKitKMP (32.38.0):
|
||||
- DivKit (= 32.38.0)
|
||||
- DivKitExtensions (= 32.38.0)
|
||||
- VGSL (7.19.1):
|
||||
- VGSLFundamentals (= 7.19.1)
|
||||
- VGSLNetworking (= 7.19.1)
|
||||
- VGSLUI (= 7.19.1)
|
||||
- VGSLFundamentals (7.19.1)
|
||||
- VGSLNetworking (7.19.1):
|
||||
- VGSLFundamentals (= 7.19.1)
|
||||
- VGSLUI (= 7.19.1)
|
||||
- VGSLUI (7.19.1):
|
||||
- VGSLFundamentals (= 7.19.1)
|
||||
- VGSL (7.21.0):
|
||||
- VGSLFundamentals (= 7.21.0)
|
||||
- VGSLNetworking (= 7.21.0)
|
||||
- VGSLUI (= 7.21.0)
|
||||
- VGSLFundamentals (7.21.0)
|
||||
- VGSLNetworking (7.21.0):
|
||||
- VGSLFundamentals (= 7.21.0)
|
||||
- VGSLUI (= 7.21.0)
|
||||
- VGSLUI (7.21.0):
|
||||
- VGSLFundamentals (= 7.21.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- DivKitKMP (from `../`)
|
||||
@@ -52,10 +52,10 @@ SPEC CHECKSUMS:
|
||||
DivKit_Serialization: c2fab65288397ea29bd91d3966c07d2d12ee608d
|
||||
DivKitExtensions: 08d57b3cab5ca255ae88f812168380a44b405fc1
|
||||
DivKitKMP: 28fa257455a5ea2815cc5f930831bb89d89679ac
|
||||
VGSL: 11fa7ce04704742563023605ebae5f1f07650402
|
||||
VGSLFundamentals: 06fafc043931efd4023be34bd98bec6df05a0080
|
||||
VGSLNetworking: dfc9d7a2244def8272afc0ca1af6fd417ecbf7c6
|
||||
VGSLUI: e4809e668479fb6c151970d1097a086b6c7c176b
|
||||
VGSL: 0573c2b82b05aadcba4836398ce3778d271bfd13
|
||||
VGSLFundamentals: 3a081684c1a5df5800bf88aca8a9bdff2c10cfd9
|
||||
VGSLNetworking: 0ea8a335bc4f4eba3f6123ffe441cf1c08f267f2
|
||||
VGSLUI: 249a16cccdb75f1a5a1733894d013bca76e27c5e
|
||||
|
||||
PODFILE CHECKSUM: 4009ac52a15ffdedf1dc6002da52adfc1f079b30
|
||||
|
||||
|
||||
+4
-5
@@ -43,13 +43,12 @@ internal class DivKitScopeImpl(
|
||||
jsonData: String,
|
||||
modifier: Modifier
|
||||
) {
|
||||
val view = remember(cardId, jsonData) {
|
||||
divKitFacade.makeDivKitView(jsonString = jsonData, cardId = cardId)
|
||||
}
|
||||
|
||||
UIKitView(
|
||||
factory = {
|
||||
view
|
||||
divKitFacade.makeDivKitView(jsonString = jsonData, cardId = cardId)
|
||||
},
|
||||
update = { view ->
|
||||
divKitFacade.updateDivKitView(view, jsonString = jsonData, cardId = cardId)
|
||||
},
|
||||
modifier = modifier,
|
||||
properties = UIKitInteropProperties(
|
||||
|
||||
@@ -15,16 +15,16 @@ PODS:
|
||||
- DivKitKMP (32.38.0):
|
||||
- DivKit (= 32.38.0)
|
||||
- DivKitExtensions (= 32.38.0)
|
||||
- VGSL (7.19.1):
|
||||
- VGSLFundamentals (= 7.19.1)
|
||||
- VGSLNetworking (= 7.19.1)
|
||||
- VGSLUI (= 7.19.1)
|
||||
- VGSLFundamentals (7.19.1)
|
||||
- VGSLNetworking (7.19.1):
|
||||
- VGSLFundamentals (= 7.19.1)
|
||||
- VGSLUI (= 7.19.1)
|
||||
- VGSLUI (7.19.1):
|
||||
- VGSLFundamentals (= 7.19.1)
|
||||
- VGSL (7.21.0):
|
||||
- VGSLFundamentals (= 7.21.0)
|
||||
- VGSLNetworking (= 7.21.0)
|
||||
- VGSLUI (= 7.21.0)
|
||||
- VGSLFundamentals (7.21.0)
|
||||
- VGSLNetworking (7.21.0):
|
||||
- VGSLFundamentals (= 7.21.0)
|
||||
- VGSLUI (= 7.21.0)
|
||||
- VGSLUI (7.21.0):
|
||||
- VGSLFundamentals (= 7.21.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- DivKitKMP (from `../../divkit-multiplatform/DivKitKMP`)
|
||||
@@ -52,10 +52,10 @@ SPEC CHECKSUMS:
|
||||
DivKit_Serialization: c2fab65288397ea29bd91d3966c07d2d12ee608d
|
||||
DivKitExtensions: 08d57b3cab5ca255ae88f812168380a44b405fc1
|
||||
DivKitKMP: 28fa257455a5ea2815cc5f930831bb89d89679ac
|
||||
VGSL: 11fa7ce04704742563023605ebae5f1f07650402
|
||||
VGSLFundamentals: 06fafc043931efd4023be34bd98bec6df05a0080
|
||||
VGSLNetworking: dfc9d7a2244def8272afc0ca1af6fd417ecbf7c6
|
||||
VGSLUI: e4809e668479fb6c151970d1097a086b6c7c176b
|
||||
VGSL: 0573c2b82b05aadcba4836398ce3778d271bfd13
|
||||
VGSLFundamentals: 3a081684c1a5df5800bf88aca8a9bdff2c10cfd9
|
||||
VGSLNetworking: 0ea8a335bc4f4eba3f6123ffe441cf1c08f267f2
|
||||
VGSLUI: 249a16cccdb75f1a5a1733894d013bca76e27c5e
|
||||
|
||||
PODFILE CHECKSUM: d6a16f2757fae6a8b9bc890d8f61fa4cd1dabc22
|
||||
|
||||
|
||||
Reference in New Issue
Block a user