2021-10-05 20:20:09 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
extension View {
|
|
|
|
func borderTop(height: Double, color: Color = Color(white: 0.7, opacity: 1)) -> some View {
|
|
|
|
verticalEdgeBorder(.top, height: height, color: color)
|
|
|
|
}
|
|
|
|
|
|
|
|
func borderBottom(height: Double, color: Color = Color(white: 0.7, opacity: 1)) -> some View {
|
|
|
|
verticalEdgeBorder(.bottom, height: height, color: color)
|
|
|
|
}
|
|
|
|
|
2021-11-28 14:37:55 +00:00
|
|
|
func borderLeading(width: Double, color: Color = Color(white: 0.7, opacity: 1)) -> some View {
|
|
|
|
horizontalEdgeBorder(.leading, width: width, color: color)
|
|
|
|
}
|
|
|
|
|
|
|
|
func borderTrailing(width: Double, color: Color = Color(white: 0.7, opacity: 1)) -> some View {
|
|
|
|
horizontalEdgeBorder(.trailing, width: width, color: color)
|
|
|
|
}
|
|
|
|
|
2021-10-05 20:20:09 +00:00
|
|
|
private func verticalEdgeBorder(_ edge: Alignment, height: Double, color: Color) -> some View {
|
2021-11-28 14:37:55 +00:00
|
|
|
overlay(Rectangle().frame(width: nil, height: height, alignment: .top)
|
2022-08-06 13:26:04 +00:00
|
|
|
.foregroundColor(color).ignoresSafeArea(.all, edges: .horizontal), alignment: edge)
|
2021-11-28 14:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private func horizontalEdgeBorder(_ edge: Alignment, width: Double, color: Color) -> some View {
|
|
|
|
overlay(Rectangle().frame(width: width, height: nil, alignment: .leading)
|
|
|
|
.foregroundColor(color), alignment: edge)
|
2021-10-05 20:20:09 +00:00
|
|
|
}
|
|
|
|
}
|