init: init proj
This commit is contained in:
36
DDYSClient/Utilities/Extensions.swift
Normal file
36
DDYSClient/Utilities/Extensions.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - URL Extensions
|
||||
|
||||
extension URL {
|
||||
var isHLS: Bool {
|
||||
pathExtension.lowercased() == "m3u8" || absoluteString.contains(".m3u8")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - String Extensions
|
||||
|
||||
extension String {
|
||||
var trimmed: String {
|
||||
trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
|
||||
func extractNumbers() -> [Int] {
|
||||
components(separatedBy: CharacterSet.decimalDigits.inverted)
|
||||
.compactMap { Int($0) }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - View Extensions
|
||||
|
||||
extension View {
|
||||
@ViewBuilder
|
||||
func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
|
||||
if condition {
|
||||
transform(self)
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user