Skip to content

Commit

Permalink
Release 30.25.0
Browse files Browse the repository at this point in the history
commit_hash:2cbd79544fc83fb38eb3318636dd527e0909f66e
  • Loading branch information
robot-divkit committed Nov 5, 2024
1 parent f49cec4 commit 0620280
Show file tree
Hide file tree
Showing 39 changed files with 1,975 additions and 62 deletions.
11 changes: 11 additions & 0 deletions .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"DivKit/Actions/DivUrlHandler.swift":"divkit/public-ios/DivKit/Actions/DivUrlHandler.swift",
"DivKit/Actions/DivVideoAction.swift":"divkit/public-ios/DivKit/Actions/DivVideoAction.swift",
"DivKit/Actions/FocusElementActionHandler.swift":"divkit/public-ios/DivKit/Actions/FocusElementActionHandler.swift",
"DivKit/Actions/HideTooltipActionHandler.swift":"divkit/public-ios/DivKit/Actions/HideTooltipActionHandler.swift",
"DivKit/Actions/OverflowMode.swift":"divkit/public-ios/DivKit/Actions/OverflowMode.swift",
"DivKit/Actions/ScrollMode.swift":"divkit/public-ios/DivKit/Actions/ScrollMode.swift",
"DivKit/Actions/SetVariableActionHandler.swift":"divkit/public-ios/DivKit/Actions/SetVariableActionHandler.swift",
Expand Down Expand Up @@ -130,6 +131,7 @@
"DivKit/Extensions/DivSizeUnitExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivSizeUnitExtensions.swift",
"DivKit/Extensions/DivSliderExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivSliderExtensions.swift",
"DivKit/Extensions/DivStateExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivStateExtensions.swift",
"DivKit/Extensions/DivSwitchExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivSwitchExtensions.swift",
"DivKit/Extensions/DivTabsExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivTabsExtensions.swift",
"DivKit/Extensions/DivTextExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivTextExtensions.swift",
"DivKit/Extensions/DivTooltipExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivTooltipExtensions.swift",
Expand Down Expand Up @@ -292,6 +294,8 @@
"DivKit/generated_sources/DivChangeTransitionTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivChangeTransitionTemplate.swift",
"DivKit/generated_sources/DivCircleShape.swift":"divkit/public-ios/DivKit/generated_sources/DivCircleShape.swift",
"DivKit/generated_sources/DivCircleShapeTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivCircleShapeTemplate.swift",
"DivKit/generated_sources/DivCloudBackground.swift":"divkit/public-ios/DivKit/generated_sources/DivCloudBackground.swift",
"DivKit/generated_sources/DivCloudBackgroundTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivCloudBackgroundTemplate.swift",
"DivKit/generated_sources/DivCollectionItemBuilder.swift":"divkit/public-ios/DivKit/generated_sources/DivCollectionItemBuilder.swift",
"DivKit/generated_sources/DivCollectionItemBuilderTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivCollectionItemBuilderTemplate.swift",
"DivKit/generated_sources/DivColorAnimator.swift":"divkit/public-ios/DivKit/generated_sources/DivColorAnimator.swift",
Expand Down Expand Up @@ -461,6 +465,8 @@
"DivKit/generated_sources/DivStretchIndicatorItemPlacementTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivStretchIndicatorItemPlacementTemplate.swift",
"DivKit/generated_sources/DivStroke.swift":"divkit/public-ios/DivKit/generated_sources/DivStroke.swift",
"DivKit/generated_sources/DivStrokeTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivStrokeTemplate.swift",
"DivKit/generated_sources/DivSwitch.swift":"divkit/public-ios/DivKit/generated_sources/DivSwitch.swift",
"DivKit/generated_sources/DivSwitchTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivSwitchTemplate.swift",
"DivKit/generated_sources/DivTabs.swift":"divkit/public-ios/DivKit/generated_sources/DivTabs.swift",
"DivKit/generated_sources/DivTabsTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTabsTemplate.swift",
"DivKit/generated_sources/DivTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTemplate.swift",
Expand Down Expand Up @@ -983,6 +989,7 @@
"Specs/DivKit/30.22.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.22.0/DivKit.podspec",
"Specs/DivKit/30.23.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.23.0/DivKit.podspec",
"Specs/DivKit/30.24.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.24.0/DivKit.podspec",
"Specs/DivKit/30.25.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.25.0/DivKit.podspec",
"Specs/DivKit/30.3.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.3.0/DivKit.podspec",
"Specs/DivKit/30.4.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.4.0/DivKit.podspec",
"Specs/DivKit/30.5.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.5.0/DivKit.podspec",
Expand Down Expand Up @@ -1059,6 +1066,7 @@
"Specs/DivKitExtensions/30.22.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.22.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.23.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.23.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.24.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.24.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.25.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.25.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.3.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.3.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.4.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.4.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.5.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.5.0/DivKitExtensions.podspec",
Expand Down Expand Up @@ -1117,6 +1125,7 @@
"Specs/DivKit_LayoutKit/30.22.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.22.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.23.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.23.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.24.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.24.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.25.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.25.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.3.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.3.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.4.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.4.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.5.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.5.0/DivKit_LayoutKit.podspec",
Expand Down Expand Up @@ -1175,6 +1184,7 @@
"Specs/DivKit_LayoutKitInterface/30.22.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.22.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.23.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.23.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.24.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.24.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.25.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.25.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.3.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.3.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.4.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.4.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.5.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.5.0/DivKit_LayoutKitInterface.podspec",
Expand Down Expand Up @@ -1233,6 +1243,7 @@
"Specs/DivKit_Serialization/30.22.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.22.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.23.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.23.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.24.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.24.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.25.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.25.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.3.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.3.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.4.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.4.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.5.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.5.0/DivKit_Serialization.podspec",
Expand Down
15 changes: 11 additions & 4 deletions DivKit/Actions/DivActionHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public final class DivActionHandler {
private let videoActionHandler = VideoActionHandler()
private let animatorHandler: AnimatorActionHandler
private let showTooltipActionHandler: ShowTooltipActionHandler
private let hideTooltipActionHandler: HideTooltipActionHandler

/// Deprecated. Do not create `DivActionHandler`. Use the instance from `DivKitComponents`.
public convenience init(
Expand Down Expand Up @@ -122,6 +123,10 @@ public final class DivActionHandler {
performer: tooltipActionPerformer,
showTooltip: showTooltip
)
self.hideTooltipActionHandler = HideTooltipActionHandler(
performer: tooltipActionPerformer,
showTooltip: showTooltip
)
}

public func handle(
Expand Down Expand Up @@ -151,7 +156,7 @@ public final class DivActionHandler {

/// Deprecated. This method is intended for backward compatibility only. Do not use it.
public func handleDivActionUrl(_ url: URL, cardId: DivCardID) -> Bool {
divActionURLHandler.handleURL(url, path: cardId.path)
divActionURLHandler.handleURL(url, cardId: cardId)
}

func handle(
Expand Down Expand Up @@ -222,8 +227,10 @@ public final class DivActionHandler {
animatorHandler.handle(action, context: context)
case let .divActionAnimatorStop(action):
animatorHandler.handle(action, context: context)
case .divActionHideTooltip, .divActionDownload,
.divActionSetState, .divActionSetStoredValue, .divActionScrollBy, .divActionScrollTo:
case let .divActionHideTooltip(action):
hideTooltipActionHandler.handle(action, context: context)
case .divActionDownload, .divActionSetState,
.divActionSetStoredValue, .divActionScrollBy, .divActionScrollTo:
break
case .none:
isHandled = false
Expand Down Expand Up @@ -274,7 +281,7 @@ public final class DivActionHandler {

let isDivActionURLHandled = divActionURLHandler.handleURL(
url,
path: info.path,
info: info,
completion: { [weak self] result in
guard let self else {
return
Expand Down
18 changes: 14 additions & 4 deletions DivKit/Actions/DivActionURLHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,28 @@ public final class DivActionURLHandler {
cardId: DivCardID,
completion: @escaping (Result<Void, Error>) -> Void = { _ in }
) -> Bool {
handleURL(url, path: cardId.path, completion: completion)
let info = DivActionInfo(
path: cardId.path,
logId: cardId.rawValue,
url: url,
logUrl: nil,
referer: nil,
source: .tap,
payload: nil
)
return handleURL(url, info: info, completion: completion)
}

func handleURL(
_ url: URL,
path: UIElementPath,
info: DivActionInfo,
completion: @escaping (Result<Void, Error>) -> Void = { _ in }
) -> Bool {
guard let intent = DivActionIntent(url: url) else {
return false
}

let cardId = path.cardId
let cardId = info.path.cardId
switch intent {
case let .showTooltip(id, multiple):
let tooltipInfo = TooltipInfo(id: id, showsOnStart: false, multiple: multiple)
Expand All @@ -93,6 +102,7 @@ public final class DivActionURLHandler {
case let .download(patchUrl):
patchProvider.getPatch(
url: patchUrl,
info: info,
completion: { [unowned self] in
self.applyPatch(cardId: cardId, result: $0, completion: completion)
}
Expand All @@ -106,7 +116,7 @@ public final class DivActionURLHandler {
updateCard(.state(cardId))
case let .setVariable(name, value):
variableUpdater.update(
path: path,
path: info.path,
name: DivVariableName(rawValue: name),
value: value
)
Expand Down
23 changes: 23 additions & 0 deletions DivKit/Actions/HideTooltipActionHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import LayoutKit

final class HideTooltipActionHandler {
private let performer: TooltipActionPerformer?
private let showTooltip: DivActionURLHandler.ShowTooltipAction?

init (performer: TooltipActionPerformer?, showTooltip: DivActionURLHandler.ShowTooltipAction?) {
self.performer = performer
self.showTooltip = showTooltip
}

func handle(_ action: DivActionHideTooltip, context: DivActionHandlingContext) {
guard let cardId = action.resolveId(context.expressionResolver) else {
return
}

guard showTooltip == nil else {
return
}

performer?.hideTooltip(id: cardId)
}
}
2 changes: 1 addition & 1 deletion DivKit/DivKitInfo.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
public enum DivKitInfo {
public static let version = "30.24.0"
public static let version = "30.25.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extension Div {
.divSeparator,
.divSlider,
.divState,
.divSwitch,
.divTabs,
.divVideo:
return accessibility?.resolveDescription(expressionResolver)
Expand Down
1 change: 1 addition & 0 deletions DivKit/Extensions/DivData/DivDataPatchExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ extension Div {
.divSelect,
.divSeparator,
.divSlider,
.divSwitch,
.divVideo,
.divText:
// no children
Expand Down
1 change: 1 addition & 0 deletions DivKit/Extensions/DivExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extension Div {
.divSelect,
.divSeparator,
.divSlider,
.divSwitch,
.divVideo,
.divText:
[]
Expand Down
17 changes: 17 additions & 0 deletions DivKit/Extensions/DivInputExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ extension DivInput: DivBlockModeling {
let onFocusActions = focus?.onFocus?.uiActions(context: context) ?? []
let onBlurActions = focus?.onBlur?.uiActions(context: context) ?? []

let enterKeyActions = enterKeyActions?.uiActions(context: context) ?? []
let enterKeyType = resolveEnterKeyType(expressionResolver)

let inputPath = context.parentPath + (id ?? DivInput.type)

let blockStateStorage = context.blockStateStorage
Expand All @@ -68,6 +71,7 @@ extension DivInput: DivBlockModeling {
multiLineMode: keyboardType == .multiLineText,
inputType: keyboardType.system,
autocapitalizationType: autocapitalizationType.system,
enterKeyType: enterKeyType.system,
highlightColor: resolveHighlightColor(expressionResolver),
maxVisibleLines: resolveMaxVisibleLines(expressionResolver),
selectAllOnFocus: resolveSelectAllOnFocus(expressionResolver),
Expand All @@ -76,6 +80,7 @@ extension DivInput: DivBlockModeling {
isFocused: isFocused,
onFocusActions: onFocusActions,
onBlurActions: onBlurActions,
enterKeyActions: enterKeyActions,
parentScrollView: context.parentScrollView,
filters: makeFilters(context),
validators: makeValidators(context),
Expand Down Expand Up @@ -232,6 +237,18 @@ extension DivInput.Autocapitalization {
}
}

extension DivInput.EnterKeyType {
fileprivate var system: TextInputBlock.EnterKeyType {
switch self {
case .default: .default
case .go: .go
case .search: .search
case .send: .send
case .done: .done
}
}
}

extension DivInputMask {
fileprivate func makeMaskValidator(_ resolver: ExpressionResolver) -> MaskValidator? {
switch self {
Expand Down
29 changes: 29 additions & 0 deletions DivKit/Extensions/DivSwitchExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import LayoutKit

extension DivSwitch: DivBlockModeling {
public func makeBlock(context: DivBlockModelingContext) throws -> Block {
let resolver = context.expressionResolver
let switchVariable = context.makeBinding(
variableName: isOnVariable,
defaultValue: false
)

return try applyBaseProperties(
to: {
SwitchBlock(
on: switchVariable,
enabled: resolveIsEnabled(resolver),
action: nil,
onTintColor: resolveOnColor(resolver)
)
},
context: context,
actionsHolder: nil,
customAccessibilityParams: CustomAccessibilityParams(
defaultTraits: .switchButton
) { [unowned self] in
accessibility?.resolveDescription(resolver)
}
)
}
}
51 changes: 43 additions & 8 deletions DivKit/Extensions/DivTextExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ extension DivText: DivBlockModeling {
)
}

let additionalTextInsets = additionalTextInsets(context: context)

return TextBlock(
widthTrait: resolveContentWidthTrait(context),
heightTrait: resolveContentHeightTrait(context),
Expand All @@ -114,6 +116,7 @@ extension DivText: DivBlockModeling {
accessibilityElement: nil,
truncationToken: truncationToken,
truncationImages: truncationImages,
additionalTextInsets: additionalTextInsets,
canSelect: resolveSelectable(expressionResolver),
tightenWidth: resolveTightenWidth(expressionResolver)
)
Expand Down Expand Up @@ -205,11 +208,12 @@ extension DivText: DivBlockModeling {
typos.forEach { $0.apply(to: string, at: cfRange) }
string.apply(actions, at: cfRange)

range.makeBackground(range: cfRange, resolver: expressionResolver)?
.apply(to: string, at: cfRange)

range.makeBorder(range: cfRange, resolver: expressionResolver)?
.apply(to: string, at: cfRange)
[
range.makeBackground(context: context, range: cfRange),
range.makeBorder(range: cfRange, resolver: expressionResolver),
].forEach {
$0?.apply(to: string, at: cfRange)
}
}

private func resolveGradient(_ expressionResolver: ExpressionResolver) -> Gradient? {
Expand All @@ -231,6 +235,25 @@ extension DivText: DivBlockModeling {
).map { .radial($0) }
}
}

private func additionalTextInsets(
context: DivBlockModelingContext
) -> EdgeInsets {
var additionalInsets: EdgeInsets = .zero
ranges?.forEach {
if case let .divCloudBackground(background) = $0.background {
let backgroundInsets = background.paddings?.resolve(context) ?? .zero
additionalInsets = EdgeInsets(
top: max(additionalInsets.top, backgroundInsets.top),

left: max(additionalInsets.left, backgroundInsets.left),
bottom: max(additionalInsets.bottom, backgroundInsets.bottom),
right: max(additionalInsets.right, backgroundInsets.right)
)
}
}
return additionalInsets
}
}

extension DivText: FontParamsProvider {}
Expand Down Expand Up @@ -308,14 +331,26 @@ extension DivText.Range {
}

fileprivate func makeBackground(
range: CFRange,
resolver: ExpressionResolver
) -> BackgroundAttribute? {
context: DivBlockModelingContext,
range: CFRange
) -> StringAttribute? {
guard let background else { return nil }
let resolver = context.expressionResolver
switch background {
case let .divSolidBackground(solid):
let color = solid.resolveColor(resolver) ?? .clear
return BackgroundAttribute(color: color.cgColor, range: range)
case let .divCloudBackground(cloud):
guard let color = cloud.resolveColor(resolver),
let cornerRadius = cloud.resolveCornerRadius(resolver)
else { return nil }
let insets = cloud.paddings?.resolve(context)
return CloudBackgroundAttribute(
color: color,
cornerRadius: CGFloat(cornerRadius),
range: range.location..<(range.location + range.length),
insets: insets
)
}
}
}
Expand Down
Loading

0 comments on commit 0620280

Please sign in to comment.