I made a custom tip style without the close button assuming that was going to be the recommendation. I didn't think to use a dynamic id. I will probably end up using both approaches. But I think the dynamic id is best suited to my initial use case for the password help. Thank you!
This is my code for the custom tip style. I tried to match the metrics of the TipView() as closely as possible.
public struct TipWithoutDismissViewStyle: TipViewStyle {
var tipBackgroundColor: Color = .clear
var imageTintColor: Color = .accentColor
public func makeBody(configuration: Configuration) -> some View {
HStack(alignment: .top, spacing: 6) {
configuration.image?
.font(.system(size: 45.5))
.foregroundColor(imageTintColor)
VStack(alignment: .leading) {
configuration.title.font(.headline)
configuration.message?.font(.subheadline).foregroundStyle(.secondary)
VStack(alignment: .leading, spacing: 11) {
ForEach(configuration.actions.indices, id: \.self) { index in
Divider()
Button(action: configuration.actions[index].handler, label: {
if index == 0 {
configuration.actions[index].label().bold()
} else {
configuration.actions[index].label()
}
})
}
}
}
}.padding(.leading, 9)
.padding([.top, .bottom], 15)
.background(tipBackgroundColor)
}
public func tipBackground(_ color: Color) -> TipWithoutDismissViewStyle {
var copy = self
copy.tipBackgroundColor = color
return copy
}
public func tint(_ color: Color) -> TipWithoutDismissViewStyle {
var copy = self
copy.imageTintColor = color
return copy
}
}
Topic:
App & System Services
SubTopic:
General
Tags: