-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from Juanpe/debug_system
Debug system
- Loading branch information
Showing
22 changed files
with
229 additions
and
170 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
// Copyright © 2018 SkeletonView. All rights reserved. | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
enum SkeletonEnvironmentKey: String { | ||
case debugMode = "SKELETON_DEBUG" | ||
} | ||
|
||
extension Dictionary { | ||
subscript (_ key: SkeletonEnvironmentKey) -> Value? { | ||
return self[key.rawValue as! Key] | ||
} | ||
} | ||
|
||
func printSkeletonHierarchy(in view: UIView) { | ||
skeletonLog(view.skeletonHierarchy()) | ||
} | ||
|
||
func skeletonLog(_ message: String) { | ||
if let _ = ProcessInfo.processInfo.environment[.debugMode] { | ||
print(message) | ||
} | ||
} | ||
|
||
extension UIView { | ||
|
||
public var skeletonDescription: String { | ||
var description = "<\(type(of: self)): \(Unmanaged.passUnretained(self).toOpaque())" | ||
let subSkeletons = subviewsSkeletonables | ||
if subSkeletons.count != 0 { | ||
description += " | (\(subSkeletons.count)) subSkeletons" | ||
} | ||
if isSkeletonable { | ||
description += " | ☠️ " | ||
} | ||
return description + ">" | ||
} | ||
|
||
public func skeletonHierarchy(index: Int = 0) -> String { | ||
var description = index == 0 ? "\n ⬇⬇ ☠️ Root view hierarchy with Skeletons ⬇⬇ \n" : "" | ||
description += "\(index == 0 ? "\n" : 3.whitespaces) \(skeletonDescription) \n" | ||
subviewsToSkeleton.forEach { | ||
description += (index + 2).whitespaces | ||
description += $0.skeletonHierarchy(index: index + 1) | ||
} | ||
return description | ||
} | ||
} |
Oops, something went wrong.