diff --git a/client/ios/DivKit/DivFlagsInfo.swift b/client/ios/DivKit/DivFlagsInfo.swift index a44113307..6e35b2bee 100644 --- a/client/ios/DivKit/DivFlagsInfo.swift +++ b/client/ios/DivKit/DivFlagsInfo.swift @@ -1,21 +1,5 @@ public struct DivFlagsInfo { - public let isTextSelectingEnabled: Bool - public let appendVariablesEnabled: Bool - public let metalImageRenderingEnabled: Bool + public init() {} - public init( - isTextSelectingEnabled: Bool, - appendVariablesEnabled: Bool, - metalImageRenderingEnabled: Bool - ) { - self.isTextSelectingEnabled = isTextSelectingEnabled - self.appendVariablesEnabled = appendVariablesEnabled - self.metalImageRenderingEnabled = metalImageRenderingEnabled - } - - public static let `default` = DivFlagsInfo( - isTextSelectingEnabled: false, - appendVariablesEnabled: true, - metalImageRenderingEnabled: false - ) + public static let `default` = DivFlagsInfo() } diff --git a/client/ios/DivKit/Extensions/DivBackgroundExtensions.swift b/client/ios/DivKit/Extensions/DivBackgroundExtensions.swift index 1fe69f8d3..c46fc2a46 100644 --- a/client/ios/DivKit/Extensions/DivBackgroundExtensions.swift +++ b/client/ios/DivKit/Extensions/DivBackgroundExtensions.swift @@ -9,8 +9,7 @@ import NetworkingPublic extension DivBackground { func makeBlockBackground( with imageHolderFactory: ImageHolderFactory, - expressionResolver: ExpressionResolver, - metalImageRenderingEnabled: Bool + expressionResolver: ExpressionResolver ) -> LayoutKit.Background? { switch self { case let .divLinearGradient(gradient): @@ -32,8 +31,7 @@ extension DivBackground { ), contentMode: imageBackground.resolveContentMode(expressionResolver), alpha: imageBackground.resolveAlpha(expressionResolver), - effects: imageBackground.makeEffects(with: expressionResolver), - metalImageRenderingEnabled: metalImageRenderingEnabled + effects: imageBackground.makeEffects(with: expressionResolver) ) return .image(image) case let .divSolidBackground(solidBackground): diff --git a/client/ios/DivKit/Extensions/DivBase/DivBaseExtensions.swift b/client/ios/DivKit/Extensions/DivBase/DivBaseExtensions.swift index c941dc70a..0a7aad1d8 100644 --- a/client/ios/DivKit/Extensions/DivBase/DivBaseExtensions.swift +++ b/client/ios/DivKit/Extensions/DivBase/DivBaseExtensions.swift @@ -64,8 +64,7 @@ extension DivBase { background, to: block, imageHolderFactory: context.imageHolderFactory, - expressionResolver: expressionResolver, - metalImageRenderingEnabled: context.flagsInfo.metalImageRenderingEnabled + expressionResolver: expressionResolver ) .addingDecorations( boundary: border.makeBoundaryTrait(with: expressionResolver), @@ -223,8 +222,7 @@ extension DivBase { _ backgrounds: [DivBackground]?, to block: Block, imageHolderFactory: ImageHolderFactory, - expressionResolver: ExpressionResolver, - metalImageRenderingEnabled: Bool + expressionResolver: ExpressionResolver ) -> Block { guard let backgrounds = backgrounds else { return block @@ -234,8 +232,7 @@ extension DivBase { if backgrounds.count == 1 { guard let background = backgrounds[0].makeBlockBackground( with: imageHolderFactory, - expressionResolver: expressionResolver, - metalImageRenderingEnabled: metalImageRenderingEnabled + expressionResolver: expressionResolver ) else { return block } @@ -248,8 +245,7 @@ extension DivBase { let blockBackgrounds = backgrounds.compactMap { $0.makeBlockBackground( with: imageHolderFactory, - expressionResolver: expressionResolver, - metalImageRenderingEnabled: metalImageRenderingEnabled + expressionResolver: expressionResolver ) } guard let background = blockBackgrounds.composite() else { diff --git a/client/ios/DivKit/Extensions/DivImage/DivImageExtensions.swift b/client/ios/DivKit/Extensions/DivImage/DivImageExtensions.swift index 1beb1d7af..aae4eb236 100644 --- a/client/ios/DivKit/Extensions/DivImage/DivImageExtensions.swift +++ b/client/ios/DivKit/Extensions/DivImage/DivImageExtensions.swift @@ -41,7 +41,6 @@ extension DivImage: DivBlockModeling, DivImageProtocol { tintColor: resolveTintColor(expressionResolver), tintMode: resolveTintMode(expressionResolver).tintMode, effects: makeEffects(with: expressionResolver), - metalImageRenderingEnabled: context.flagsInfo.metalImageRenderingEnabled, appearanceAnimation: appearanceAnimation?.makeAppearanceAnimation(with: expressionResolver) ) } diff --git a/client/ios/DivKit/Extensions/DivTextExtensions.swift b/client/ios/DivKit/Extensions/DivTextExtensions.swift index c9b4a98b5..dc06e6a05 100644 --- a/client/ios/DivKit/Extensions/DivTextExtensions.swift +++ b/client/ios/DivKit/Extensions/DivTextExtensions.swift @@ -100,8 +100,7 @@ extension DivText: DivBlockModeling { images: images, truncationToken: truncationToken, truncationImages: truncationImages, - canSelect: resolveSelectable(context.expressionResolver) && context.flagsInfo - .isTextSelectingEnabled + canSelect: resolveSelectable(context.expressionResolver) ) } diff --git a/client/ios/DivKitPlayground/AppComponents.swift b/client/ios/DivKitPlayground/AppComponents.swift index 0fc369f01..0b75d6553 100644 --- a/client/ios/DivKitPlayground/AppComponents.swift +++ b/client/ios/DivKitPlayground/AppComponents.swift @@ -28,11 +28,7 @@ enum AppComponents { sizeProviderExtensionHandler, ShimmerImagePreviewExtension(), ], - flagsInfo: DivFlagsInfo( - isTextSelectingEnabled: true, - appendVariablesEnabled: true, - metalImageRenderingEnabled: true - ), + flagsInfo: DivFlagsInfo(), patchProvider: DemoPatchProvider(), updateCardAction: updateCardAction, playerFactory: DefaultPlayerFactory(), diff --git a/client/ios/DivKitSnapshotTests/DivKitSnapshotTestCase.swift b/client/ios/DivKitSnapshotTests/DivKitSnapshotTestCase.swift index d48aebc4f..c060e354e 100644 --- a/client/ios/DivKitSnapshotTests/DivKitSnapshotTestCase.swift +++ b/client/ios/DivKitSnapshotTests/DivKitSnapshotTestCase.swift @@ -24,16 +24,19 @@ open class DivKitSnapshotTestCase: XCTestCase { rootDirectory: String ) -> Bool { guard - let jsonDict = jsonDict(fileName: file.name, subdirectory: rootDirectory + "/" + file.subdirectory) + let jsonDict = jsonDict( + fileName: file.name, + subdirectory: rootDirectory + "/" + file.subdirectory + ) else { // json is invalid, test should be added into the test suite return true } - + guard let platforms = jsonDict.getArray("platforms").value else { return true } - + return platforms.contains { $0 as? String == "ios" } } @@ -54,11 +57,7 @@ open class DivKitSnapshotTestCase: XCTestCase { let divKitComponents = DivKitComponents( extensionHandlers: extensions, - flagsInfo: .init( - isTextSelectingEnabled: false, - appendVariablesEnabled: true, - metalImageRenderingEnabled: true - ), + flagsInfo: DivFlagsInfo(), imageHolderFactory: imageHolderFactory ?? makeImageHolderFactory(), updateCardAction: nil, urlOpener: { _ in } diff --git a/client/ios/LayoutKit/LayoutKit/Blocks/ImageBlock+Copy.swift b/client/ios/LayoutKit/LayoutKit/Blocks/ImageBlock+Copy.swift index 89e16101e..ca3a7f92b 100644 --- a/client/ios/LayoutKit/LayoutKit/Blocks/ImageBlock+Copy.swift +++ b/client/ios/LayoutKit/LayoutKit/Blocks/ImageBlock+Copy.swift @@ -10,7 +10,6 @@ extension ImageBlock { tintColor: tintColor, tintMode: tintMode, effects: effects, - metalImageRenderingEnabled: metalImageRenderingEnabled, accessibilityElement: accessibilityElement ) } diff --git a/client/ios/LayoutKit/LayoutKit/Blocks/ImageBlock.swift b/client/ios/LayoutKit/LayoutKit/Blocks/ImageBlock.swift index db873bb6c..57d4da214 100644 --- a/client/ios/LayoutKit/LayoutKit/Blocks/ImageBlock.swift +++ b/client/ios/LayoutKit/LayoutKit/Blocks/ImageBlock.swift @@ -14,7 +14,6 @@ public final class ImageBlock: ImageBaseBlock { public let effects: [ImageEffect] public let accessibilityElement: AccessibilityElement? public let appearanceAnimation: TransitioningAnimation? - public let metalImageRenderingEnabled: Bool public init( imageHolder: ImageHolder, @@ -24,7 +23,6 @@ public final class ImageBlock: ImageBaseBlock { tintColor: Color?, tintMode: TintMode?, effects: [ImageEffect] = [], - metalImageRenderingEnabled: Bool = false, accessibilityElement: AccessibilityElement? = nil, appearanceAnimation: TransitioningAnimation? = nil ) { @@ -35,7 +33,6 @@ public final class ImageBlock: ImageBaseBlock { self.tintColor = tintColor self.tintMode = tintMode self.effects = effects - self.metalImageRenderingEnabled = metalImageRenderingEnabled self.accessibilityElement = accessibilityElement self.appearanceAnimation = appearanceAnimation } @@ -48,7 +45,6 @@ public final class ImageBlock: ImageBaseBlock { tintColor: Color? = nil, tintMode: TintMode? = nil, effects: [ImageEffect] = [], - metalImageRenderingEnabled: Bool = false, accessibilityElement: AccessibilityElement? = nil, appearanceAnimation: TransitioningAnimation? = nil ) { @@ -60,7 +56,6 @@ public final class ImageBlock: ImageBaseBlock { tintColor: tintColor, tintMode: tintMode, effects: effects, - metalImageRenderingEnabled: metalImageRenderingEnabled, accessibilityElement: accessibilityElement, appearanceAnimation: appearanceAnimation ) @@ -73,7 +68,6 @@ public final class ImageBlock: ImageBaseBlock { tintColor: Color? = nil, tintMode: TintMode? = nil, effects: [ImageEffect] = [], - metalImageRenderingEnabled: Bool = false, accessibilityElement: AccessibilityElement? = nil, appearanceAnimation: TransitioningAnimation? = nil ) { @@ -85,7 +79,6 @@ public final class ImageBlock: ImageBaseBlock { tintColor: tintColor, tintMode: tintMode, effects: effects, - metalImageRenderingEnabled: metalImageRenderingEnabled, accessibilityElement: accessibilityElement, appearanceAnimation: appearanceAnimation ) diff --git a/client/ios/LayoutKit/LayoutKit/UI/Blocks/ImageBlock+UIViewRenderableBlock.swift b/client/ios/LayoutKit/LayoutKit/UI/Blocks/ImageBlock+UIViewRenderableBlock.swift index 3aeee3733..3b28af497 100644 --- a/client/ios/LayoutKit/LayoutKit/UI/Blocks/ImageBlock+UIViewRenderableBlock.swift +++ b/client/ios/LayoutKit/LayoutKit/UI/Blocks/ImageBlock+UIViewRenderableBlock.swift @@ -13,7 +13,7 @@ extension ImageBlock { renderingDelegate _: RenderingDelegate? ) { let remoteImageViewContainer = view as! RemoteImageViewContainer - if metalImageRenderingEnabled && !remoteImageViewContainer.contentView + if (!effects.isEmpty || tintMode != nil) && !remoteImageViewContainer.contentView .isKind(of: MetalImageView.self) { remoteImageViewContainer.contentView = MetalImageView() } diff --git a/client/ios/LayoutKit/LayoutKit/UI/Views/Background+UIViewRendering.swift b/client/ios/LayoutKit/LayoutKit/UI/Views/Background+UIViewRendering.swift index e3fffbd7b..0e6fe0db9 100644 --- a/client/ios/LayoutKit/LayoutKit/UI/Views/Background+UIViewRendering.swift +++ b/client/ios/LayoutKit/LayoutKit/UI/Views/Background+UIViewRendering.swift @@ -89,7 +89,7 @@ extension BackgroundView { view = ColoredView() case let .image(backgroundImage): - if backgroundImage.metalImageRenderingEnabled { + if !backgroundImage.effects.isEmpty { view = RemoteImageViewContainer(contentView: MetalImageView()) } else { view = RemoteImageViewContainer(contentView: RemoteImageView()) diff --git a/client/ios/LayoutKit/LayoutKit/ViewModels/BackgroundImage.swift b/client/ios/LayoutKit/LayoutKit/ViewModels/BackgroundImage.swift index bc10cdb6a..325981dd8 100644 --- a/client/ios/LayoutKit/LayoutKit/ViewModels/BackgroundImage.swift +++ b/client/ios/LayoutKit/LayoutKit/ViewModels/BackgroundImage.swift @@ -6,20 +6,17 @@ public struct BackgroundImage { let contentMode: ImageContentMode let alpha: Double let effects: [ImageEffect] - let metalImageRenderingEnabled: Bool public init( imageHolder: ImageHolder, contentMode: ImageContentMode = .default, alpha: Double = 1.0, - effects: [ImageEffect] = [], - metalImageRenderingEnabled: Bool = false + effects: [ImageEffect] = [] ) { self.imageHolder = imageHolder self.contentMode = contentMode self.alpha = alpha self.effects = effects - self.metalImageRenderingEnabled = metalImageRenderingEnabled } } diff --git a/client/ios/Tests/reference_snapshots/div-text/image-background_320@2x.png b/client/ios/Tests/reference_snapshots/div-text/image-background_320@2x.png index 9bff3286c..fc7a232e3 100644 Binary files a/client/ios/Tests/reference_snapshots/div-text/image-background_320@2x.png and b/client/ios/Tests/reference_snapshots/div-text/image-background_320@2x.png differ diff --git a/client/ios/Tests/reference_snapshots/div-text/image-background_375@2x.png b/client/ios/Tests/reference_snapshots/div-text/image-background_375@2x.png index 9bff3286c..fc7a232e3 100644 Binary files a/client/ios/Tests/reference_snapshots/div-text/image-background_375@2x.png and b/client/ios/Tests/reference_snapshots/div-text/image-background_375@2x.png differ diff --git a/client/ios/Tests/reference_snapshots/div-text/image-background_375@3x.png b/client/ios/Tests/reference_snapshots/div-text/image-background_375@3x.png index 19a880d2e..61896d489 100644 Binary files a/client/ios/Tests/reference_snapshots/div-text/image-background_375@3x.png and b/client/ios/Tests/reference_snapshots/div-text/image-background_375@3x.png differ diff --git a/client/ios/Tests/reference_snapshots/div-text/image-background_414@2x.png b/client/ios/Tests/reference_snapshots/div-text/image-background_414@2x.png index 9bff3286c..fc7a232e3 100644 Binary files a/client/ios/Tests/reference_snapshots/div-text/image-background_414@2x.png and b/client/ios/Tests/reference_snapshots/div-text/image-background_414@2x.png differ diff --git a/client/ios/Tests/reference_snapshots/div-text/image-background_414@3x.png b/client/ios/Tests/reference_snapshots/div-text/image-background_414@3x.png index 19a880d2e..61896d489 100644 Binary files a/client/ios/Tests/reference_snapshots/div-text/image-background_414@3x.png and b/client/ios/Tests/reference_snapshots/div-text/image-background_414@3x.png differ