From efed84505fc4a6be6206628cdd8fde218b880242 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Thu, 13 Apr 2023 16:34:31 +0100 Subject: [PATCH 01/14] REPLAY-1523 Add text alignment support --- .../NodeRecorders/UILabelRecorder.swift | 2 +- .../Writer/Models/SRDataModels+UIKit.swift | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 DatadogSessionReplay/Sources/Writer/Models/SRDataModels+UIKit.swift diff --git a/DatadogSessionReplay/Sources/Recorder/ViewTreeSnapshotProducer/ViewTreeSnapshot/NodeRecorders/UILabelRecorder.swift b/DatadogSessionReplay/Sources/Recorder/ViewTreeSnapshotProducer/ViewTreeSnapshot/NodeRecorders/UILabelRecorder.swift index 5ad80be18d..59ca4dbb9b 100644 --- a/DatadogSessionReplay/Sources/Recorder/ViewTreeSnapshotProducer/ViewTreeSnapshot/NodeRecorders/UILabelRecorder.swift +++ b/DatadogSessionReplay/Sources/Recorder/ViewTreeSnapshotProducer/ViewTreeSnapshot/NodeRecorders/UILabelRecorder.swift @@ -49,7 +49,7 @@ internal class UILabelRecorder: NodeRecorder { attributes: attributes, text: label.text ?? "", textColor: label.textColor?.cgColor, - textAlignment: nil, + textAlignment: .init(textAlignment: label.textAlignment), font: label.font, fontScalingEnabled: label.adjustsFontSizeToFitWidth, textObfuscator: textObfuscator(context), diff --git a/DatadogSessionReplay/Sources/Writer/Models/SRDataModels+UIKit.swift b/DatadogSessionReplay/Sources/Writer/Models/SRDataModels+UIKit.swift new file mode 100644 index 0000000000..9560f3a8c4 --- /dev/null +++ b/DatadogSessionReplay/Sources/Writer/Models/SRDataModels+UIKit.swift @@ -0,0 +1,30 @@ +// +// File.swift +// +// +// Created by Maciej Burda on 13/04/2023. +// + +import UIKit + +extension SRTextPosition.Alignment { + init(textAlignment: NSTextAlignment) { + self.vertical = .center + switch textAlignment { + case .left: + self.horizontal = .left + case .center: + self.horizontal = .center + case .right: + self.horizontal = .right + case .justified: + self.horizontal = .left + default: + if UIApplication.shared.userInterfaceLayoutDirection == .leftToRight { + self.horizontal = .left + } else { + self.horizontal = .right + } + } + } +} From a335bbec4a7b61021134e7ef92865ee3507575af Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Fri, 14 Apr 2023 11:24:08 +0100 Subject: [PATCH 02/14] REPLAY-1523 Update snapshot --- .../SRSnapshotTests/SRHost/Fixtures/Basic.storyboard | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DatadogSessionReplay/SRSnapshotTests/SRHost/Fixtures/Basic.storyboard b/DatadogSessionReplay/SRSnapshotTests/SRHost/Fixtures/Basic.storyboard index 27b18b9e11..483b0e1cf7 100644 --- a/DatadogSessionReplay/SRSnapshotTests/SRHost/Fixtures/Basic.storyboard +++ b/DatadogSessionReplay/SRSnapshotTests/SRHost/Fixtures/Basic.storyboard @@ -1,8 +1,9 @@ - + - + + @@ -79,7 +80,7 @@ -