Dux icon indicating copy to clipboard operation
Dux copied to clipboard

Question: Is there a way to apply tab to a tab bar Item?

Open javalnanda opened this issue 3 years ago • 2 comments

How can we highlight the center tab in a TabView to show the tip on top of it?

javalnanda avatar Feb 23 '22 11:02 javalnanda

Sharing the current workaround I used to place a fake view on top of the tab bar item if it helps someone. The width of the view is determined by dividing the screen width by the number of tabs and the height is determined by gReader.safeAreaInsets.bottom

fakeLearnTabItemView(for: gReader.safeAreaInsets.bottom)
                    .position(x: gReader.frame(in: .local).midX, y: gReader.frame(in: .local).maxY + (gReader.safeAreaInsets.bottom / 2))
private func fakeLearnTabItemView(for height: CGFloat) -> some View {
        HStack {
            Spacer()
            Color.clear.frame(width: UIScreen.main.bounds.size.width/3, height: height, alignment: .bottom)
                .duxTag(Tags.learn)
            Spacer()
        }
        .frame(alignment: .bottom)
    }

javalnanda avatar Feb 24 '22 06:02 javalnanda

Thanks for sharing the workaround! I think something like this is the best way to do it right now, but there should be better support for this in the library. Will look into more when I can

jakeheis avatar Feb 24 '22 15:02 jakeheis