99 lines
1.9 KiB
Swift
99 lines
1.9 KiB
Swift
//
|
|
// Set.swift
|
|
// MacBackend
|
|
//
|
|
// Created by david-swift on 11.10.2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
extension Set where Element == Edge {
|
|
|
|
/// All edges.
|
|
public static var all: Self {
|
|
vertical.union(horizontal)
|
|
}
|
|
|
|
/// The vertical edges.
|
|
public static var vertical: Self {
|
|
top.union(bottom)
|
|
}
|
|
|
|
/// The horizontal edges.
|
|
public static var horizontal: Self {
|
|
leading.union(trailing)
|
|
}
|
|
|
|
/// The top edge.
|
|
public static var top: Self {
|
|
[.top]
|
|
}
|
|
|
|
/// The bottom edge.
|
|
public static var bottom: Self {
|
|
[.bottom]
|
|
}
|
|
|
|
/// The leading edge.
|
|
public static var leading: Self {
|
|
[.leading]
|
|
}
|
|
|
|
/// The trailing edge.
|
|
public static var trailing: Self {
|
|
[.trailing]
|
|
}
|
|
|
|
/// The SwiftUI edge.
|
|
var swiftUI: SwiftUI.Edge.Set {
|
|
var edges: SwiftUI.Edge.Set = []
|
|
for edge in self {
|
|
switch edge {
|
|
case .top:
|
|
edges.insert(.top)
|
|
case .bottom:
|
|
edges.insert(.bottom)
|
|
case .leading:
|
|
edges.insert(.leading)
|
|
case .trailing:
|
|
edges.insert(.trailing)
|
|
}
|
|
}
|
|
return edges
|
|
}
|
|
|
|
}
|
|
|
|
extension Set where Element == Axis {
|
|
|
|
/// The vertical axis.
|
|
public static var vertical: Self {
|
|
[.vertical]
|
|
}
|
|
|
|
/// The horizontal axis.
|
|
public static var horizontal: Self {
|
|
[.horizontal]
|
|
}
|
|
|
|
/// The vertical and horizontal axes.
|
|
public static var both: Self {
|
|
[.horizontal, .vertical]
|
|
}
|
|
|
|
/// The SwiftUI axis set.
|
|
var swiftUI: SwiftUI.Axis.Set {
|
|
switch self {
|
|
case [.vertical]:
|
|
.vertical
|
|
case [.horizontal]:
|
|
.horizontal
|
|
case [.vertical, .horizontal]:
|
|
[.vertical, .horizontal]
|
|
default:
|
|
[]
|
|
}
|
|
}
|
|
|
|
}
|