feat: Adding improvements to pressure estimations feature.

This commit is contained in:
2024-06-12 10:29:33 -04:00
parent da8a8638c7
commit 9a145b3290
7 changed files with 239 additions and 89 deletions

View File

@@ -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)