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

Regarding the problem that PageContentView will be reloaded when you slide it left or right. #706

Open
lijl opened this issue Mar 25, 2024 · 4 comments

Comments

@lijl
Copy link

lijl commented Mar 25, 2024

image

I used the swiftUI component. After loading, sliding the testview left or right will reload, so the interface will be re-requested every time, which is a very bad experience. How to make testview not reload?

@lijl
Copy link
Author

lijl commented Mar 25, 2024

@rechsteiner

@yiweiwoshiniya
Copy link

me too

@rechsteiner
Copy link
Owner

Hi! Can you try targeting the 4.0 branch directly and see it works for you there? There's a fix there which should handle this

@yiweiwoshiniya
Copy link

yiweiwoshiniya commented Sep 20, 2024

@lijl can you work?
@rechsteiner 4.0 not work for me. a new view will be generated.

Podfile: pod 'Parchment', '~> 4.0.0'
PageView {
getPages()
}
.menuItemSize(.selfSizing(estimatedWidth: 50, height: 40))
.menuItemLabelSpacing(0)
.menuItemSpacing(32)
.menuInsets(.init(top: 0, leading: 16, bottom: 0, trailing: 16))
.indicatorOptions(.visible(height: 3, zIndex: Int.max, spacing: .zero, insets: .zero))
.indicatorColor(Color.primary)
.borderColor(Color.separator)
.borderOptions(.visible(height: 1, zIndex: Int.max - 1, insets: .zero))

func getPages() -> [Page] {
    var pages = [Page]()
    for tab in viewModel.investModel?.tabs ?? [] {
        pages.append(
            Page(header: { state in
                Text(tab.name ?? "")
                    .fixedSize()
                    .font(Font.h6())
                    .foregroundColor(state.isSelected ? Color.primary : Color.text2)
            }, content: {
                switch tab.typeE {
                case .aaa:
                    TestA()
                case .bbb:
                    TestB()
                case .ccc:
                    TestC()
                default:
                    TestD()       
         }
                
            })
        )
        
    }
    
    return pages
}

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

3 participants