Skip to content

Commit

Permalink
Add debug extension
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Jun 8, 2023
1 parent 1e45e34 commit a248ebc
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
--swiftversion 5.8
--swiftversion 5.7
--disable preferKeyPath
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.8
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
11 changes: 11 additions & 0 deletions Sources/OversizeCore/Extensions/Color/Color+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ import SwiftUI
}
}
#endif

public extension Color {
static func random(randomOpacity: Bool = false) -> Color {
Color(
red: .random(in: 0 ... 1),
green: .random(in: 0 ... 1),
blue: .random(in: 0 ... 1),
opacity: randomOpacity ? .random(in: 0 ... 1) : 1
)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//
// Copyright © 2023 Aleksandr Romanov
// Calendar+Extension.swift, created on 02.04.2023
//

//

import Foundation

Expand Down
7 changes: 7 additions & 0 deletions Sources/OversizeCore/Extensions/URL/URL+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ public extension URL {
return urlString + "..."
}
}

public extension URL {
func fileExists() -> Bool {
let path = path.replacingOccurrences(of: "file://", with: "")
return FileManager.default.fileExists(atPath: path)
}
}
19 changes: 19 additions & 0 deletions Sources/OversizeCore/ViewModifier/Debug/ColorOverlay.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Copyright © 2023 Alexander Romanov
// File.swift, created on 24.05.2023
//

import SwiftUI

public struct DebugOverlayModifier: ViewModifier {
public func body(content: Content) -> some View {
content
.overlay(Color.random(randomOpacity: true))
}
}

public extension View {
func debugOverlay() -> some View {
modifier(DebugOverlayModifier())
}
}

0 comments on commit a248ebc

Please sign in to comment.