try Tips.resetDatastore()
try Tips.configure(
[
// Reset which tips have been shown and what parameters have been tracked, useful during testing and for this sample project
.datastoreLocation(.applicationDefault),
// When should the tips be presented? If you use .immediate, they'll all be presented whenever a screen with a tip appears.
// You can adjust this on per tip level as well
.displayFrequency(.immediate)
]
)
struct UserTip: Tip {
static let hoverEvent: Event = Event(id: "hoverEvent")
@Parameter var isHovering: Bool = false
static var tipCountKey = "UserTipCount"
var title: Text
var message: Text?
var image: Image?
var tipShownLimit: Int
var options: [Option] {
// Show this tip 5 times.
[
Tips.MaxDisplayCount(5),
Tips.IgnoresDisplayFrequency(true)
]
}
var rules: [Rule] {
#Rule($isHovering) {
$0 == true
}
}
}
struct ShowPopoverTip: View {
@State private var tip = UserTip(
title: Text("the title"),
message: Text("the message here"),
image: Image(systemName: "volleyball.fill"),
tipShownLimit: 10
)
var body: some View {
Button(action: {
}) {
Text("Hover over me")
}
.popoverTip(tip)
.onAppear {
}
.onHover { hovering in
if hovering {
tip.isHovering = true
print("tip.status: \(tip.status)")
print("tip.isHovering: \(tip.isHovering)")
print("tip.shouldDisplay: \(tip.shouldDisplay)")
}else{
tip.isHovering = false
print("tip.isHovering: \(tip.isHovering)")
}
}
}
}
The popover only works once, even though I have set it to Tips.MaxDisplayCount(5) Either the Tip is getting invalidated or popovers only show once.
debug output:
tip.isHovering: true
tip.shouldDisplay: false
tip.isHovering: false
tip.status: pending
tip.isHovering: true
tip.shouldDisplay: false
tip.isHovering: false
btw, if I remove the Tips.resetDatastore(), it still shows once each time I launch the app.