DynamicOverlay icon indicating copy to clipboard operation
DynamicOverlay copied to clipboard

Side attached overlays

Open milettal opened this issue 3 years ago • 3 comments

A common use case for overlays is to have them have a fixed width and be attached to the side on a regular-width device, such as an iPad or landscape iPhone. This is true for Apple Maps.

maps-landscape

Does this library currently support this configuration?

Very impressed with the library 👍🏻

milettal avatar Aug 30 '21 16:08 milettal

I know the question is a few months old, but I was able to achieve this by getting the current size class from the environment, and then adding padding to the overlay view. Here's a very basic example, but I can expand on it a little more if that would be helpful.

struct MyOverlayView: View {
    
    @Environment(\.horizontalSizeClass) var horizontalSizeClass
    
    var items = Item.makeItems(50)
    
    var body: some View {
        GeometryReader { geometry in
            VStack {
                Text("Header")
                List {
                    ForEach(items) {
                        Text($0.title)
                    }
                }
                .drivingScrollView()
            }
            .padding(.trailing, horizontalSizeClass == .regular ? geometry.size.width-375 : 0)
        }
    }
    
}

forgot avatar Dec 03 '21 03:12 forgot