🎉 first commit

This commit is contained in:
2023-07-13 11:56:17 +02:00
parent 92e03bc310
commit 3ad6ee9134
8 changed files with 328 additions and 32 deletions

View File

@ -0,0 +1,32 @@
//
// TextFieldExtensions.swift
// Luto
//
// Created by Pierre Boulc'h on 06/07/2023.
//
import Foundation
import SwiftUI
struct OvalTextFieldStyle: TextFieldStyle {
func _body(configuration: TextField<Self._Label>) -> some View {
configuration
.textFieldStyle(.plain)
.colorMultiply(.gray)
.padding(10)
.tint(.gray)
.foregroundColor(.black)
.background(.white)
.cornerRadius(20)
.shadow(color: .accentColor, radius: 2)
}
}
extension NSTextField {
open override var focusRingType: NSFocusRingType {
get { .none }
set { }
}
}

View File

@ -0,0 +1,31 @@
//
// ViewExtensions.swift
// Luto
//
// Created by Pierre Boulc'h on 12/07/2023.
//
import Foundation
import SwiftUI
extension View {
func border(width: CGFloat, edges: [Edge], color: Color) -> some View {
overlay(EdgeBorder(width: width, edges: edges).foregroundColor(color))
}
}
struct EdgeBorder: Shape {
var width: CGFloat
var edges: [Edge]
func path(in rect: CGRect) -> Path {
edges.map { edge -> Path in
switch edge {
case .top: return Path(.init(x: rect.minX, y: rect.minY, width: rect.width, height: width))
case .bottom: return Path(.init(x: rect.minX, y: rect.maxY - width, width: rect.width, height: width))
case .leading: return Path(.init(x: rect.minX, y: rect.minY, width: width, height: rect.height))
case .trailing: return Path(.init(x: rect.maxX - width, y: rect.minY, width: width, height: rect.height))
}
}.reduce(into: Path()) { $0.addPath($1) }
}
}