Last active
September 27, 2025 20:08
-
-
Save igavrysh/fa8f059b6fcb35fce017438f58543537 to your computer and use it in GitHub Desktop.
iOS 26.0 update for video#29 from Nick channel Swiftful Thinking https://www.youtube.com/watch?v=5QDvfNQF304
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // 029PopoverBootcamp.swift | |
| // SwiftfulThinkingBeta | |
| // | |
| // Created by new on 9/27/25. | |
| // | |
| // Nick from Swiftful Thinking | |
| // https://www.youtube.com/watch?v=5QDvfNQF304 | |
| // | |
| import SwiftUI | |
| struct PopoverBootcamp: View { | |
| @State var showNewScreen: Bool = false | |
| @State private var screenSize: CGSize = CGSize(width: 100, height: 100) | |
| // METHOD 3 - ANIMATION OFFSET -- UPDATED TO SUPPORT iOS 26.0 | |
| var body: some View { | |
| ZStack { | |
| Color.orange | |
| .edgesIgnoringSafeArea(.all) | |
| VStack { | |
| Button("BUTTON") { | |
| withAnimation(.spring()) { | |
| showNewScreen.toggle() | |
| } | |
| } | |
| .font(.largeTitle) | |
| Spacer() | |
| } | |
| NewScreen(showNewScreen: $showNewScreen) | |
| .padding(.top, 100) | |
| .offset(x: 0, y: showNewScreen ? 0 : UIScreen.current?.bounds.size.height ?? 0) | |
| } | |
| } | |
| var body1: some View { | |
| ZStack { | |
| Color.orange | |
| .edgesIgnoringSafeArea(.all) | |
| VStack { | |
| Button("BUTTON") { | |
| showNewScreen.toggle() | |
| } | |
| .font(.largeTitle) | |
| Spacer() | |
| } | |
| // METHOD 1 - SHEET | |
| // .sheet(isPresented: $showNewScreen) { | |
| // NewScreen() | |
| // } | |
| // METHOD 2 - TRANSITION | |
| // ZStack { | |
| // if showNewScreen { | |
| // NewScreen(showNewScreen: $showNewScreen) | |
| // .padding(.top, 100) | |
| // .transition(.move(edge: .bottom)) | |
| // .animation(.spring()) | |
| // } | |
| // } | |
| // METHOD 3 - ANIMATION OFFSET -- COUPLE DEPRECATED WARNINGS AS OF SEPT 2025 | |
| // .offset(x: 0, y: showNewScreen ? 0 : UIScreen.main.bounds.height) | |
| // 'main' was deprecated in iOS 26.0: Use a UIScreen instance found through context instead | |
| // (i.e, view.window.windowScene.screen), or for properties like UIScreen.scale with trait | |
| // equivalents, use a traitCollection found through context. | |
| // .animation(.spring()) | |
| // 'animation' was deprecated in iOS 15.0: Use withAnimation or animation(_:value:) instead. | |
| // NewScreen(showNewScreen: $showNewScreen) | |
| // .padding(.top, 100) | |
| // .offset(x: 0, y: showNewScreen ? 0 : UIScreen.main.bounds.height) | |
| // .animation(.spring()) | |
| } | |
| } | |
| } | |
| extension UIWindow { | |
| static var current: UIWindow? { | |
| for scene in UIApplication.shared.connectedScenes { | |
| guard let windowScene = scene as? UIWindowScene else { continue } | |
| for window in windowScene.windows { | |
| if window.isKeyWindow { return window } | |
| } | |
| } | |
| return nil | |
| } | |
| } | |
| extension UIScreen { | |
| static var current: UIScreen? { | |
| UIWindow.current?.screen | |
| } | |
| } | |
| struct NewScreen: View { | |
| @Environment(\.presentationMode) var presentationMode | |
| @Binding var showNewScreen: Bool | |
| var body: some View { | |
| let v: PresentationMode | |
| ZStack(alignment: .topLeading) { | |
| Color.purple | |
| .edgesIgnoringSafeArea(.all) | |
| Button(action: { | |
| // presentationMode.wrappedValue.dismiss() | |
| let t = presentationMode.wrappedValue | |
| showNewScreen.toggle() | |
| }, label: { | |
| Image(systemName: "xmark") | |
| .foregroundColor(.white) | |
| .font(.largeTitle) | |
| .padding(20) | |
| }) | |
| } | |
| } | |
| } | |
| struct PopoverBootcamp_Previews: PreviewProvider { | |
| static var previews: some View { | |
| PopoverBootcamp() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment