Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicator is showing up many more times than one #16

Open
blockiindahood opened this issue Jul 15, 2022 · 10 comments
Open

Indicator is showing up many more times than one #16

blockiindahood opened this issue Jul 15, 2022 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@blockiindahood
Copy link

Details

  • iOS Version 16.0 beta 3
  • Framework Version 1.6.4
  • Installed via Manually

Describe the Bug
As soon as the Indicator got fired one time, anything you do on the UI triggers many more times.

RPReplay_Final1657907183.mov
@blockiindahood blockiindahood added the bug Something isn't working label Jul 15, 2022
@LouisTay
Copy link

LouisTay commented Sep 3, 2022

A workaround:

showIndicator = true
try? await Task.sleep(nanoseconds: 10)
showIndicator = false

@gongzhang
Copy link

Hi @ivanvorobei , long time no see 😄

I just re-implement the SwiftUI support for SPIndicator. And you can find it here. I believe the commit will fix this issue.

What's more, the new implementation also supports multi-window iPad app. The indicator always come up at correct window when using SwiftUI modifier. However, I have to deprecate the old APIs.

@ivanvorobei
Copy link
Owner

Is it for swiftui version or uikit? sorry for delay

@gongzhang
Copy link

@ivanvorobei Totally fine :) It's a fix for the current SwiftUI implementation.

@ivanvorobei
Copy link
Owner

@gongzhang can you make PR ?

@gongzhang
Copy link

@ivanvorobei Thanks! But I don't have the dev environment right now. You can also cherrypick gongzhang@38108b1

@bootuz
Copy link

bootuz commented Sep 13, 2023

Have similar issue

@bootuz
Copy link

bootuz commented Sep 16, 2023

A workaround:

showIndicator = true
try? await Task.sleep(nanoseconds: 10)
showIndicator = false

@LouisTay where should I place this? can you show an example?

@AsadFarooq5777
Copy link

facing similar issue

@Behtold
Copy link

Behtold commented Mar 17, 2024

My crutch:

extension View {
    public func mySPIndicator(
        isPresent: Binding<Bool>,
        title: String,
        duration: TimeInterval = 2.0,
        presentSide: SPIndicatorPresentSide = .top,
        dismissByDrag: Bool = true,
        preset: SPIndicatorIconPreset = .done,
        haptic: SPIndicatorHaptic = .none,
        completion: (()-> Void)? = nil
    ) -> some View {
        let now = Date().timeIntervalSince1970
       
        let present = (startShow > now - duration && title == currentTitle)
            ? Binding(get: { return false }, set: {_,_ in }) : isPresent
        if isPresent.wrappedValue {
            startShow = now
            currentTitle = title
        }
        let indicatorView = SPIndicatorView(title: title, preset: preset)
        indicatorView.presentSide = presentSide
        indicatorView.dismissByDrag = dismissByDrag
        indicatorView.completion = completion
        return SPIndicator(isPresent: present, indicatorView: indicatorView, duration: duration, haptic: haptic)
    }
}

fileprivate var startShow: TimeInterval = Date().timeIntervalSince1970
fileprivate var currentTitle: String?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants