0

I'm working on a location-based app and when the user taps a marker, the app should present a detail view as a sheet containing images. If the user clicks on an image I want to show that image in a full-screen view like Twitter.

I'm using SwiftUI, not UIKit.

DetailView.swift

WebImage(url: URL(string: location.logo))
                    .resizable()
                    .indicator(.activity)
                    .animation(.easeInOut(duration: 0.5))
                    .transition(.fade)
                    .scaledToFit()
                    .frame(width: 150, height: 150, alignment: .center)
                    .onTapGesture {
                       self.isOpened.toggle()
                    }
                    .sheet(isPresented: $isOpened) {
                        Text("Test")
                            .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
                            .background(Color.red)
                            .edgesIgnoringSafeArea(.all)
                    }

Screenshot

As you can understand I wanna show this view which has a red background as a full screen.

Paulw11
  • 108,386
  • 14
  • 159
  • 186

1 Answers1

0

The simplest way is by presenting your view as an overlay on your main view: .overlay(self.showModal ? yourSecondView() : nil)

you should toggle your showModal to show the overly or not

Another solution is to implement some extension for UIViewController to present your view in full screen

Mac3n
  • 4,189
  • 3
  • 16
  • 29