feat: Adding improvements to pressure estimations feature.
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
import SwiftUI
|
||||
|
||||
public struct DeleteButton: View {
|
||||
let action: () -> Void
|
||||
|
||||
public init(action: @escaping () -> Void) {
|
||||
self.action = action
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
Button(role: .destructive, action: action) {
|
||||
Label("Delete", systemImage: "trash")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct DoneButton: View {
|
||||
|
||||
let action: () -> Void
|
||||
@@ -15,6 +29,24 @@ public struct DoneButton: View {
|
||||
}
|
||||
}
|
||||
|
||||
public struct EditButton: View {
|
||||
|
||||
@Environment(\.editButtonStyle) private var style
|
||||
|
||||
let action: () -> Void
|
||||
|
||||
public init(action: @escaping () -> Void) {
|
||||
self.action = action
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
Button(action: action) {
|
||||
Label("Edit", systemImage: "square.and.pencil")
|
||||
}
|
||||
.buttonStyle(style)
|
||||
}
|
||||
}
|
||||
|
||||
public struct InfoButton: View {
|
||||
|
||||
@Environment(\.infoButtonStyle) private var infoButtonStyle
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import SwiftUI
|
||||
|
||||
#warning("Remove button types and just make styles stand-alone")
|
||||
|
||||
/// A name space for edit button styles.
|
||||
public enum EditButtonType { }
|
||||
|
||||
/// A name space for info button styles.
|
||||
public enum InfoButtonType { }
|
||||
|
||||
@@ -119,6 +124,10 @@ private struct ResetButtonStyleKey: EnvironmentKey {
|
||||
extension EnvironmentValues {
|
||||
// @Entry var infoButtonStyle: AnyButtonStyle<InfoButtonType> = AnyButtonStyle.default
|
||||
|
||||
@Entry var editButtonStyle = MainActor.assumeIsolated {
|
||||
AnyPrimitiveButtonStyle<EditButtonType>(DefaultInfoButtonStyle(labelStyle: .automatic))
|
||||
}
|
||||
|
||||
var infoButtonStyle: AnyPrimitiveButtonStyle<InfoButtonType> {
|
||||
get { self[InfoButtonStyleKey.self] }
|
||||
set { self[InfoButtonStyleKey.self] = newValue }
|
||||
@@ -137,6 +146,16 @@ extension EnvironmentValues {
|
||||
|
||||
extension View {
|
||||
|
||||
/// Sets the button style for the ``EditButton`` type.
|
||||
public func editButtonStyle(_ style: AnyPrimitiveButtonStyle<EditButtonType>) -> some View {
|
||||
environment(\.editButtonStyle, style)
|
||||
}
|
||||
|
||||
/// Sets the button style for the ``EditButton`` type.
|
||||
public func editButtonStyle<S: PrimitiveButtonStyle>(_ style: S) -> some View {
|
||||
editButtonStyle(AnyPrimitiveButtonStyle(style))
|
||||
}
|
||||
|
||||
/// Sets the button style for the ``InfoButton`` type.
|
||||
public func infoButtonStyle(_ style: AnyPrimitiveButtonStyle<InfoButtonType>) -> some View {
|
||||
environment(\.infoButtonStyle, style)
|
||||
|
||||
Reference in New Issue
Block a user