Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPLAY-1508 Add support and tests for always template rendering mode #1239

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<!--Images View Controller-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController storyboardIdentifier="Images" id="Y6W-OH-hqX" sceneMemberID="viewController">
<viewController storyboardIdentifier="Images" id="Y6W-OH-hqX" customClass="ImagesViewController" customModule="SRHost" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="dd_logo" translatesAutoresizingMaskIntoConstraints="NO" id="xxq-Cw-MRl">
<rect key="frame" x="156.66666666666666" y="95" width="80" height="80"/>
<rect key="frame" x="156.66666666666666" y="75" width="80" height="80"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="1vb-jA-kiT"/>
<constraint firstAttribute="width" constant="80" id="KCk-0l-g6b"/>
</constraints>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="apple.logo" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="KF9-wK-Okh">
<rect key="frame" x="166" y="201" width="61" height="59.333333333333371"/>
<rect key="frame" x="166" y="171.33333333333334" width="61" height="59.333333333333343"/>
<color key="tintColor" systemColor="systemPurpleColor"/>
<constraints>
<constraint firstAttribute="width" constant="61" id="QrF-HG-Jtn"/>
<constraint firstAttribute="height" constant="61" id="rFX-W6-8HU"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" alignment="center" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="zQI-BZ-L2g">
<rect key="frame" x="0.0" y="269.66666666666669" width="393" height="288.00000000000006"/>
<rect key="frame" x="0.0" y="248" width="393" height="288"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="n6y-pj-DAN">
<rect key="frame" x="52.666666666666657" y="0.0" width="288" height="60"/>
Expand Down Expand Up @@ -183,7 +183,7 @@
</subviews>
</stackView>
<tabBar contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="raw-wh-zEy">
<rect key="frame" x="0.0" y="593.66666666666663" width="393" height="49"/>
<rect key="frame" x="0.0" y="552" width="393" height="49"/>
<constraints>
<constraint firstAttribute="height" constant="49" id="t9n-YU-wtJ"/>
</constraints>
Expand All @@ -198,7 +198,7 @@
</items>
</tabBar>
<navigationBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ftc-4B-7Pp">
<rect key="frame" x="0.0" y="678.66666666666663" width="393" height="44"/>
<rect key="frame" x="0.0" y="617" width="393" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="4hr-VJ-mh1"/>
</constraints>
Expand All @@ -209,25 +209,37 @@
</navigationItem>
</items>
</navigationBar>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="vKz-Ut-7bS">
<rect key="frame" x="156.66666666666666" y="677" width="80" height="80"/>
<constraints>
<constraint firstAttribute="width" constant="80" id="YUK-jg-T8h"/>
<constraint firstAttribute="height" constant="80" id="zPr-qF-VOv"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="raw-wh-zEy" firstAttribute="top" secondItem="zQI-BZ-L2g" secondAttribute="bottom" constant="36" id="3Tf-N7-p6F"/>
<constraint firstItem="vKz-Ut-7bS" firstAttribute="top" secondItem="ftc-4B-7Pp" secondAttribute="bottom" constant="16" id="2KW-Vg-MSH"/>
<constraint firstItem="raw-wh-zEy" firstAttribute="top" secondItem="zQI-BZ-L2g" secondAttribute="bottom" constant="16" id="3Tf-N7-p6F"/>
<constraint firstItem="raw-wh-zEy" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" id="ET0-BN-qth"/>
<constraint firstItem="zQI-BZ-L2g" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" id="OAe-l4-L39"/>
<constraint firstItem="xxq-Cw-MRl" firstAttribute="centerX" secondItem="vDu-zF-Fre" secondAttribute="centerX" id="OTN-dD-tUV"/>
<constraint firstItem="ftc-4B-7Pp" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" id="OuL-9P-SDJ"/>
<constraint firstItem="ftc-4B-7Pp" firstAttribute="trailing" secondItem="vDu-zF-Fre" secondAttribute="trailing" id="P5h-A7-U1M"/>
<constraint firstItem="zQI-BZ-L2g" firstAttribute="top" secondItem="KF9-wK-Okh" secondAttribute="bottom" constant="8" id="PcY-W5-rVM"/>
<constraint firstItem="ftc-4B-7Pp" firstAttribute="top" secondItem="raw-wh-zEy" secondAttribute="bottom" constant="36" id="TIg-KH-e5o"/>
<constraint firstItem="zQI-BZ-L2g" firstAttribute="top" secondItem="KF9-wK-Okh" secondAttribute="bottom" constant="16" id="PcY-W5-rVM"/>
<constraint firstItem="ftc-4B-7Pp" firstAttribute="top" secondItem="raw-wh-zEy" secondAttribute="bottom" constant="16" id="TIg-KH-e5o"/>
<constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="zQI-BZ-L2g" secondAttribute="trailing" id="Wjg-fd-LWW"/>
<constraint firstItem="KF9-wK-Okh" firstAttribute="centerX" secondItem="vDu-zF-Fre" secondAttribute="centerX" id="bah-mp-OGG"/>
<constraint firstItem="KF9-wK-Okh" firstAttribute="top" secondItem="xxq-Cw-MRl" secondAttribute="bottom" constant="25.666666666666657" id="d96-un-7EN"/>
<constraint firstItem="KF9-wK-Okh" firstAttribute="top" secondItem="xxq-Cw-MRl" secondAttribute="bottom" constant="16" id="d96-un-7EN"/>
<constraint firstItem="raw-wh-zEy" firstAttribute="trailing" secondItem="vDu-zF-Fre" secondAttribute="trailing" id="iAJ-aX-zcr"/>
<constraint firstItem="xxq-Cw-MRl" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" constant="36" id="jIN-YZ-8QX"/>
<constraint firstItem="vKz-Ut-7bS" firstAttribute="centerX" secondItem="vDu-zF-Fre" secondAttribute="centerX" id="iGo-IL-Tk7"/>
<constraint firstItem="xxq-Cw-MRl" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" constant="16" id="jIN-YZ-8QX"/>
</constraints>
</view>
<connections>
<outlet property="customImageView" destination="vKz-Ut-7bS" id="aJg-Sy-OrB"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

import UIKit

internal class ImagesViewController: UIViewController {
@IBOutlet weak var customImageView: UIImageView!

override func viewDidLoad() {
super.viewDidLoad()
customImageView.image = UIImage(named: "dd_logo")?.withRenderingMode(.alwaysTemplate)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
61E7DFB9299A5A3E001D7A3A /* Basic.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 61E7DFB8299A5A3E001D7A3A /* Basic.storyboard */; };
61E7DFBB299A5C9D001D7A3A /* BasicViewControllers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61E7DFBA299A5C9D001D7A3A /* BasicViewControllers.swift */; };
61EC1A37299CFD7E00224FB6 /* TestUtilities in Frameworks */ = {isa = PBXBuildFile; productRef = 61EC1A36299CFD7E00224FB6 /* TestUtilities */; };
A77C62F429E4298200AC923B /* ImagesViewControllers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77C62F329E4298200AC923B /* ImagesViewControllers.swift */; };
A797A95029D5958400EE73EB /* Images.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A797A94F29D5958400EE73EB /* Images.storyboard */; };
A797A95229D59E7900EE73EB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A797A95129D59E7900EE73EB /* Assets.xcassets */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -60,6 +61,7 @@
61E7DFB6299A57A9001D7A3A /* MenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
61E7DFB8299A5A3E001D7A3A /* Basic.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Basic.storyboard; sourceTree = "<group>"; };
61E7DFBA299A5C9D001D7A3A /* BasicViewControllers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicViewControllers.swift; sourceTree = "<group>"; };
A77C62F329E4298200AC923B /* ImagesViewControllers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagesViewControllers.swift; sourceTree = "<group>"; };
A797A94F29D5958400EE73EB /* Images.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Images.storyboard; sourceTree = "<group>"; };
A797A95129D59E7900EE73EB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -156,6 +158,7 @@
61A735A929A5137400001820 /* InputViewControllers.swift */,
6196D32329AF7EB2002EACAF /* InputElements-DatePickers.storyboard */,
A797A94F29D5958400EE73EB /* Images.storyboard */,
A77C62F329E4298200AC923B /* ImagesViewControllers.swift */,
);
path = Fixtures;
sourceTree = "<group>";
Expand Down Expand Up @@ -279,6 +282,7 @@
61B3BC4B2993BE2E0032C78A /* AppDelegate.swift in Sources */,
61E7DFBB299A5C9D001D7A3A /* BasicViewControllers.swift in Sources */,
61E7DFB7299A57A9001D7A3A /* MenuViewController.swift in Sources */,
A77C62F429E4298200AC923B /* ImagesViewControllers.swift in Sources */,
61B634EB299A5DB3002BEABE /* Fixtures.swift in Sources */,
61B3BC4D2993BE2E0032C78A /* SceneDelegate.swift in Sources */,
61A735AA29A5137400001820 /* InputViewControllers.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ internal struct UIImageViewRecorder: NodeRecorder {

internal init(
tintColorProvider: @escaping (UIImageView) -> UIColor? = { imageView in
if #available(iOS 13.0, *) {
return imageView.image?.isSymbolImage == true ? imageView.tintColor : nil
if #available(iOS 13.0, *), let image = imageView.image {
return image.isSymbolImage || image.isAlwaysTemplate ? imageView.tintColor : nil
} else {
return nil
}
},
shouldRecordImagePredicate: @escaping (UIImageView) -> Bool = { imageView in
if #available(iOS 13.0, *) {
return imageView.image?.isSymbolImage == true || imageView.image?.description.isBundled == true
if #available(iOS 13.0, *), let image = imageView.image {
return image.isSymbolImage || image.isBundled || image.isAlwaysTemplate
} else {
return false
}
Expand Down Expand Up @@ -159,8 +159,12 @@ internal struct UIImageViewWireframesBuilder: NodeWireframesBuilder {
}
}

fileprivate extension String {
fileprivate extension UIImage {
var isBundled: Bool {
return contains("named(")
return description.contains("named(")
}

var isAlwaysTemplate: Bool {
return renderingMode == .alwaysTemplate
}
}