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

Redrawing of views #55

Closed
iankoex opened this issue Jan 27, 2022 · 4 comments
Closed

Redrawing of views #55

iankoex opened this issue Jan 27, 2022 · 4 comments

Comments

@iankoex
Copy link

iankoex commented Jan 27, 2022

Changing how the view is shown would prevent reloading of the content.

public func body(content: Content) -> some View {
        Group {
            main(content: content)
        }
        .valueChanged(value: isPresented) { isPresented in
            appearAction(isPresented: isPresented)
        }
    }
    
    private func main(content: Content) -> some View {
        ZStack {
            content
                .frameGetter($presenterContentRect)
            
            if showContent {
                backgroundColor
                    .applyIf(closeOnTapOutside) { view in
                        view.contentShape(Rectangle())
                    }
                    .addTapIfNotTV(if: closeOnTapOutside) {
                        dismiss()
                    }
                    .edgesIgnoringSafeArea(.all)
                    .opacity(currentBackgroundOpacity)
                    .animation(animation)
            }
        }
        .overlay(sheet())
    }
@f3dm76
Copy link
Collaborator

f3dm76 commented Jan 28, 2022

Hello @iankoex, sorry, I'm confused - is this piece of code a proposed change to the lib? I mean, do you want me to include this into project to prevent reloading of the content? Why would you want to prevent content reloading? Would you please specify what problem exactly you are having, what is the desired behaviour, and what is the proposed solution, as is customary.

@iankoex
Copy link
Author

iankoex commented Jan 28, 2022

If the popup is triggered in a scrollview, the content in this case the scrollview reloads. This makes the scrollview go to the top, offset of zero. The snippet above does not reload the content. The desired behaviour is that when the popup is shown, the scrollview maintains its position(offset).

@f3dm76
Copy link
Collaborator

f3dm76 commented Feb 8, 2022

Hey again @iankoex, got your point, however your suggested solution kind of beats the purpose of lazy load - .overlay(sheet()) is called in any case in your scenario. Keeping in mind your described problem, I restructured a little. I included my solution into 1.0.4 release, please give it a go, and do let me know if that didn't fix your problem. Have a great day!

@f3dm76
Copy link
Collaborator

f3dm76 commented Mar 3, 2022

Hello @iankoex, it's been a while so I'm gonna this issue, but please do let me know if the problem is not fixed. Have a good day!

@f3dm76 f3dm76 closed this as completed Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants