Feat: Working on pressure estimations feature
This commit is contained in:
@@ -14,7 +14,11 @@ public struct InfoButton: View {
|
||||
Button(action: action) {
|
||||
Label("Info", systemImage: "info.circle")
|
||||
}
|
||||
.buttonStyle(infoButtonStyle)
|
||||
.buttonStyle(.plain)
|
||||
.labelStyle(.iconOnly)
|
||||
.font(.title2)
|
||||
.foregroundStyle(Color.accentColor)
|
||||
// .buttonStyle(infoButtonStyle)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,48 +1,74 @@
|
||||
import ComposableArchitecture
|
||||
import SwiftUI
|
||||
|
||||
@Reducer
|
||||
public struct InfoViewFeature {
|
||||
|
||||
public init() { }
|
||||
|
||||
@ObservableState
|
||||
public struct State: Equatable {
|
||||
let titleText: String
|
||||
let bodyText: String
|
||||
|
||||
public init(
|
||||
title titleText: String,
|
||||
body bodyText: String
|
||||
) {
|
||||
self.titleText = titleText
|
||||
self.bodyText = bodyText
|
||||
}
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
case dismissButtonTapped
|
||||
}
|
||||
|
||||
@Dependency(\.dismiss) var dismiss
|
||||
|
||||
public var body: some ReducerOf<Self> {
|
||||
Reduce { _, action in
|
||||
switch action {
|
||||
case .dismissButtonTapped:
|
||||
return .run { _ in await self.dismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct InfoView: View {
|
||||
let headingText: String
|
||||
let bodyText: String
|
||||
let store: StoreOf<InfoViewFeature>
|
||||
|
||||
|
||||
public init(heading headingText: String, body bodyText: String) {
|
||||
self.headingText = headingText
|
||||
self.bodyText = bodyText
|
||||
public init(store: StoreOf<InfoViewFeature>) {
|
||||
self.store = store
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack(spacing: 40) {
|
||||
|
||||
ZStack {
|
||||
Text(headingText)
|
||||
.font(.headline)
|
||||
.bold()
|
||||
.foregroundStyle(Color.white)
|
||||
.padding()
|
||||
}
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.foregroundStyle(Color.orange.opacity(0.6))
|
||||
}
|
||||
|
||||
|
||||
ZStack {
|
||||
Text(bodyText)
|
||||
.font(.callout)
|
||||
.padding()
|
||||
}
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.foregroundStyle(Color.secondary.opacity(0.3))
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
|
||||
Text(store.bodyText)
|
||||
.font(.callout)
|
||||
.padding()
|
||||
Spacer()
|
||||
}
|
||||
.navigationTitle(store.titleText)
|
||||
.padding(.horizontal)
|
||||
.navigationBarBackButtonHidden()
|
||||
.toolbar {
|
||||
Button("Done") {
|
||||
store.send(.dismissButtonTapped)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
InfoView(heading: "Generic Info View", body: "Explain what this view does here...")
|
||||
InfoView(
|
||||
store: Store(
|
||||
initialState: InfoViewFeature.State(
|
||||
title: "Generic Info View",
|
||||
body: "Explain what this view does here..."
|
||||
),
|
||||
reducer: InfoViewFeature.init
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public struct DefaultInfoButtonStyle: PrimitiveButtonStyle {
|
||||
public func makeBody(configuration: Configuration) -> some View {
|
||||
configuration.label
|
||||
.buttonStyle(.plain)
|
||||
.font(.title2)
|
||||
.foregroundStyle(Color.accentColor)
|
||||
.labelStyle(.iconOnly)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user