mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 14:56:15 +00:00
71 lines
1.3 KiB
Swift
71 lines
1.3 KiB
Swift
//
|
|
// ViewModifiers.swift
|
|
// NearFuture
|
|
//
|
|
// Created by neon443 on 13/06/2025.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
|
|
extension View {
|
|
func hapticHeavy(trigger: any Equatable) -> some View {
|
|
#if canImport(UIKit)
|
|
if #available(iOS 17, *) {
|
|
self.modifier(sensoryFeedback(.impact(weight: .heavy, intensity: 1), trigger: trigger)) as! Self
|
|
} else {
|
|
self
|
|
}
|
|
#else
|
|
self
|
|
#endif
|
|
}
|
|
}
|
|
|
|
struct glassButton: ViewModifier {
|
|
func body(content: Content) -> some View {
|
|
#if swift(>=6.2)
|
|
content.buttonStyle(.glass)
|
|
#else
|
|
content.buttonStyle(.borderedProminent)
|
|
.clipShape(RoundedRectangle(cornerRadius: 15))
|
|
.tint(.two)
|
|
#endif
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func hapticSucess(trigger: any Equatable) -> some View {
|
|
#if canImport(UIKit)
|
|
if #available(iOS 17, *) {
|
|
self.modifier(sensoryFeedback(.success, trigger: trigger)) as! Self
|
|
} else {
|
|
self
|
|
}
|
|
#else
|
|
self
|
|
#endif
|
|
}
|
|
}
|
|
struct navigationInlineLarge: ViewModifier {
|
|
func body(content: Content) -> some View {
|
|
#if os(macOS)
|
|
content
|
|
.toolbarTitleDisplayMode(.inlineLarge)
|
|
#else
|
|
content
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
#endif
|
|
}
|
|
}
|
|
|
|
struct presentationSizeForm: ViewModifier {
|
|
func body(content: Content) -> some View {
|
|
if #available(iOS 18, macOS 15, *) {
|
|
content.presentationSizing(.form)
|
|
} else {
|
|
content
|
|
}
|
|
}
|
|
}
|