Skip to content

Commit

Permalink
♻️ Update screen capture default name
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt committed May 31, 2023
1 parent 18459ca commit b37a22f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ extension UIViewController {
if name != "ViewController" {
name = name.replacingOccurrences(of: "ViewController", with: "")
}
if name.starts(with: "UIHostingController<") {
name = "UIHostingController"
}
return name
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@

import UIKit

private var screenNameDateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd_HH:mm:ss"
return formatter
}()

private extension UIViewController {
var viewControllerForName: UIViewController {
if let navigationController = self as? UINavigationController,
Expand All @@ -32,16 +26,14 @@ private extension UIViewController {
}

internal extension UIView {
func screenCaptureDisplayName(at timestamp: Date) -> String {
var name = ""
if let window = self as? UIWindow,
let root = window.rootViewController {
func screenCaptureDisplayName() -> String {
let name: String
if let window = self as? UIWindow, let root = window.rootViewController {
name = root.viewControllerForName.displayName
} else {
name = String(describing: self.classForCoder)
}

name += " (\(screenNameDateFormatter.string(from: timestamp)))"
return name
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/AppcuesKit/Presentation/Debugger/UIDebugger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ extension UIDebugger: DebugViewDelegate {
let timestamp = Date()
var capture = Capture(
appId: config.applicationID,
displayName: window.screenCaptureDisplayName(at: timestamp),
displayName: window.screenCaptureDisplayName(),
screenshotImageUrl: nil,
layout: layout,
metadata: Capture.Metadata(insets: Capture.Insets(window.safeAreaInsets)),
Expand Down

0 comments on commit b37a22f

Please sign in to comment.