rechsteiner / Parchment

A paging view with a highly customizable menu ✨
MIT License
3.37k stars 419 forks source link

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

Open lijl opened 6 months ago

lijl commented 6 months ago
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 commented 6 months ago

@rechsteiner

yiweiwoshiniya commented 6 months ago

me too

rechsteiner commented 6 months ago

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 commented 3 weeks ago

@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
}