struct ContentView: View {
   @State private var path = NavigationPath()
   @State private var picture: UIImage?

   var body: some View {
      NavigationStack(path: $path) {
         VStack {
            HStack {
               if let picture {
                  let photo = Image(uiImage: picture)
                  ShareLink("Share Picture", item: photo, preview: SharePreview("Photo", image: photo))
                     .buttonStyle(.glass)
               }
               Spacer()
               NavigationLink(value: "Open Picker", label: {
                  Text("Get Picture")
               })
               .buttonStyle(.glassProminent)
               .padding()
               .navigationDestination(for: String.self) { _ in
                  ImagePicker { newpicture in
                     if let newpicture {
                        let width = newpicture.size.width / 3
                        let height = newpicture.size.height / 3
                        picture = newpicture.preparingThumbnail(of: CGSize(width: width, height: height))
                     }
                     path.removeLast()
                  }
                  .ignoresSafeArea()
               }
            }
            Image(uiImage: picture ?? UIImage(named: "nopicture")!)
               .resizable()
               .scaledToFit()
            Spacer()
         }.padding()
      }.statusBarHidden()
   }
}