<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ahmed Gado on Medium]]></title>
        <description><![CDATA[Stories by Ahmed Gado on Medium]]></description>
        <link>https://medium.com/@ahmedgado95?source=rss-17a6599d6346------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*E9B-9DtJ8qdceX_GsTQccA.jpeg</url>
            <title>Stories by Ahmed Gado on Medium</title>
            <link>https://medium.com/@ahmedgado95?source=rss-17a6599d6346------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 04:07:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahmedgado95/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Generic Navigation Coordinator with NavigationStack in SwiftUI]]></title>
            <link>https://medium.com/@ahmedgado95/generic-navigation-coordinator-with-navigationstack-in-swiftui-d8261a4d885d?source=rss-17a6599d6346------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8261a4d885d</guid>
            <dc:creator><![CDATA[Ahmed Gado]]></dc:creator>
            <pubDate>Fri, 03 Oct 2025 16:54:02 GMT</pubDate>
            <atom:updated>2025-10-03T16:54:02.906Z</atom:updated>
            <content:encoded><![CDATA[<p>SwiftUI’s NavigationStack (introduced in iOS 16) is a huge step forward compared to the old NavigationView. It gives us value-based navigation, programmatic control, and support for deep linking.</p><p>But when your app grows, navigation can quickly become messy:</p><ul><li>Different screens handling their own push/pop.</li><li>Sheets and full-screen modals sprinkled everywhere.</li><li>Hard to keep track of where navigation logic lives.</li></ul><p>That’s where the <strong>Coordinator Pattern</strong> comes in.<br> In this article, we’ll build a <strong>generic, reusable Coordinator</strong> on top of NavigationStack that centralizes navigation logic for <strong>push, pop, sheets, and full screens</strong>.</p><p>🧩 The Problem</p><p>By default, each SwiftUI view tends to handle its own navigation logic:</p><pre>NavigationLink(&quot;Go to Details&quot;) {<br>    DetailsView()<br>}<br>.sheet(isPresented: $showSheet) {<br>    InfoSheet()<br>}</pre><p>This works fine for small apps, but as your app grows:</p><ul><li>Navigation logic spreads across multiple views.</li><li>It becomes hard to manage state or restore navigation.</li><li>Adding new routes means touching multiple places.</li></ul><p>We need a <strong>single source of truth</strong> for navigation.</p><h3>🛠️ The Coordinator</h3><p>Let’s introduce a <strong>generic </strong><strong>Coordinator&lt;Route&gt;</strong> class:</p><pre>final class Coordinator&lt;Route: Hashable &amp; Identifiable&gt;: ObservableObject {<br>    @Published var path = NavigationPath()<br>    private(set) var stack: [Route] = []<br><br>    @Published var sheet: Route?<br>    @Published var fullScreen: Route?<br>    <br>    var startBuilder: () -&gt; AnyView<br>    var routeBuilder: (Route) -&gt; AnyView<br>    <br>    init(<br>        start: @escaping () -&gt; AnyView,<br>        route: @escaping (Route) -&gt; AnyView<br>    ) {<br>        self.startBuilder = start<br>        self.routeBuilder = route<br>    }<br>    <br>    func push(_ route: Route) {<br>        stack.append(route)<br>        path.append(route)<br>    }<br>    <br>    func goBack() {<br>        guard !stack.isEmpty else { return }<br>        stack.removeLast()<br>        path.removeLast()<br>    }<br>    <br>    func popTo(_ route: Route) {<br>        if let index = stack.firstIndex(of: route) {<br>            stack = Array(stack.prefix(through: index))<br>            path = NavigationPath(stack)<br>        } else {<br>            popToRoot()<br>        }<br>    }<br>    <br>    func popToRoot() {<br>        stack.removeAll()<br>        path = NavigationPath()<br>    }<br>    <br>    func presentSheet(_ route: Route) {<br>        sheet = route<br>    }<br>    <br>    func dismissSheet() {<br>        sheet = nil<br>    }<br>    <br>    func presentFullScreen(_ route: Route) {<br>        fullScreen = route<br>    }<br>    <br>    func dismissFullScreen() {<br>        fullScreen = nil<br>    }<br>}</pre><p>👉 This class centralizes <strong>all navigation logic</strong> in one place:</p><ul><li><strong>Push/Pop</strong> with a custom stack.</li><li><strong>Sheets</strong> and <strong>Full Screens</strong> with published properties.</li><li><strong>Type-safe routes</strong> using Hashable &amp; Identifiable.</li></ul><h3>🖼️ Coordinator View</h3><p>Now we need a <strong>container view</strong> that connects the Coordinator with SwiftUI’s navigation system:</p><pre>struct CoordinatorView&lt;Route: Hashable &amp; Identifiable&gt;: View {<br>    @ObservedObject var coordinator: Coordinator&lt;Route&gt;<br><br>    var body: some View {<br>        NavigationStack(path: $coordinator.path) {<br>            coordinator.startBuilder()<br>                .navigationDestination(for: Route.self) { route in<br>                    coordinator.routeBuilder(route)<br>                }<br>        }<br>        .sheet(item: $coordinator.sheet) { route in<br>            coordinator.routeBuilder(route)<br>        }<br>        .fullScreenCover(item: $coordinator.fullScreen) { route in<br>            coordinator.routeBuilder(route)<br>        }<br>    }<br>}</pre><p>This view is the <strong>entry point</strong> of your app:</p><ul><li>It uses a NavigationStack for push/pop.</li><li>It automatically handles .sheet and .fullScreenCover.</li></ul><h3>📌 Defining Routes</h3><p>We’ll define our routes using an enum.<br> Each case represents a screen in the app:</p><pre>enum Screen: Hashable, Identifiable {<br>    case home<br>    case homeDetails(String)<br>    case settings<br>    case infoSheet(String)<br>    case profileFullScreen<br>    <br>    var id: String {<br>        String(describing: self)<br>    }<br>    <br>    @ViewBuilder<br>    static func build(_ route: Screen, coordinator: Coordinator&lt;Screen&gt;) -&gt; some View {<br>        switch route {<br>        case .home:<br>            HomeView(viewModel: HomeViewModel(coordinator: coordinator))<br>        case .homeDetails(let text):<br>            HomeDetailsView(text: text)<br>        case .settings:<br>            SettingsView()<br>        case .infoSheet(let text):<br>            InfoSheet(text: text)<br>        case .profileFullScreen:<br>            ProfileView()<br>        }<br>    }<br>}</pre><p>✅ Benefits of this approach:</p><ul><li>Centralized list of all screens.</li><li>Type-safe navigation (no string-based IDs).</li><li>Easy to extend with new routes.</li></ul><h3>🚀 App Entry Point</h3><p>Now let’s plug it all together in the app entry point:</p><pre>@main<br>struct NavigationStackApp: App {<br>    @StateObject var coordinator: Coordinator&lt;Screen&gt; = {<br>        let coord = Coordinator&lt;Screen&gt;(<br>            start: { AnyView(EmptyView()) },<br>            route: { _ in AnyView(EmptyView()) }<br>        )<br>        <br>        coord.startBuilder = { AnyView(Screen.build(.home, coordinator: coord)) }<br>        coord.routeBuilder = { route in AnyView(Screen.build(route, coordinator: coord)) }<br>        <br>        return coord<br>    }()<br>    <br>    var body: some Scene {<br>        WindowGroup {<br>            CoordinatorView(coordinator: coordinator)<br>                .environmentObject(coordinator)<br>        }<br>    }<br>}</pre><p>The app now boots into .home, and all navigation flows through the Coordinator.</p><h3>🏠 Example: Home Screen</h3><p>Here’s a simple Home screen with multiple navigation actions:</p><pre><br>protocol HomeNavigation {<br>    func goToDetails()<br>    func goToSetting()<br>    func openInfoSheet()<br>    func openProfile()<br>}<br><br>class HomeViewModel: ObservableObject {<br>    @Published var title: String = &quot;🏠 Home&quot;<br>    <br>    private let navigator: HomeNavigation<br>    <br>    init(navigator: HomeNavigation) {<br>        self.navigator = navigator<br>    }<br>    <br>    func goToDetails() {<br>        navigator.goToDetails()<br>    }<br><br>    func openInfoSheet() {<br>        navigator.openInfoSheet()<br>    }<br><br>    func goToSetting() {<br>        navigator.goToSetting()<br>    }<br>    <br>    func openProfile() {<br>        navigator.openProfile()<br>    }<br>}<br><br>extension Coordinator: HomeNavigation where Route == Screen {<br>    func goToDetails() {<br>        push(.homeDetails(&quot;Home Details&quot;))<br>    }<br>    <br>    func goToSetting() {<br>        push(.settings)<br>    }<br>    <br>    func openInfoSheet() {<br>       presentSheet(.infoSheet(&quot;InfoSheet&quot;))<br>    }<br>    <br>    func openProfile() {<br>       presentFullScreen(.profileFullScreen)<br>    }<br>}<br><br><br>struct HomeView: View {<br>    @StateObject var viewModel: HomeViewModel<br><br>    var body: some View {<br>        VStack(spacing: 20) {<br>            Text(viewModel.title)<br>                .font(.title)<br><br>            Button(&quot;Go to Details&quot;) {<br>                viewModel.goToDetails()<br>            }<br>            <br>            Button(&quot;Go to Settings&quot;) {<br>                viewModel.goToSetting()<br>            }<br><br>            Button(&quot;Open Info Sheet&quot;) {<br>                viewModel.openInfoSheet()<br>            }<br><br>            Button(&quot;Profile FullScreen&quot;) {<br>                viewModel.openProfile()<br>            }<br>        }<br>        .padding()<br>    }<br>}</pre><h3>🎯 Benefits of This Approach</h3><ul><li>✅ <strong>Centralized navigation logic</strong> → no duplication across views.</li><li>✅ <strong>Reusable</strong> → works for any app structure.</li><li>✅ <strong>Type-safe</strong> → routes are enums, not strings.</li><li>✅ <strong>Scalable</strong> → easy to add/remove new screens.</li><li>✅ <strong>Cleaner Views</strong> → views focus on UI, not navigation state.</li></ul><h3>📂 Try It Yourself</h3><p>I’ve created a simple demo project on GitHub where you can try both approaches (system Launch Screen + SwiftUI Splash Screen) in action.</p><p>👉 Don’t forget to start it <a href="https://github.com/ahmedgado95/NavigationStack">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8261a4d885d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ How to Add a Launch Screen in Xcode 26 with SwiftUI (Without Storyboards)]]></title>
            <link>https://medium.com/@ahmedgado95/how-to-add-a-launch-screen-in-xcode-26-with-swiftui-without-storyboards-edb33035878a?source=rss-17a6599d6346------2</link>
            <guid isPermaLink="false">https://medium.com/p/edb33035878a</guid>
            <dc:creator><![CDATA[Ahmed Gado]]></dc:creator>
            <pubDate>Tue, 30 Sep 2025 13:10:08 GMT</pubDate>
            <atom:updated>2025-09-30T13:10:08.446Z</atom:updated>
            <content:encoded><![CDATA[<p>gives the impression that your app is loading faster and reinforces your brand identity.</p><p>In older versions of Xcode, developers relied on <strong>LaunchScreen.storyboard</strong>, but starting with <strong>Xcode 15 and now in Xcode 26</strong>, that approach has been <strong>deprecated</strong>.<br> So, if you’re building your app with <strong>SwiftUI</strong>, you’ll need to follow the new way of setting up a Launch Screen.</p><p>In this article, we’ll cover:</p><ol><li>The difference between a Launch Screen and a Splash Screen.</li><li>How to define a Launch Screen in Xcode 26.</li><li>How to create a custom Splash Screen in SwiftUI.</li><li>How to combine both for a polished user experience.</li></ol><h3>🎯 Launch Screen vs. Splash Screen</h3><p>Before we dive into the code, let’s clear up a common confusion.</p><ul><li><strong>Launch Screen (System-managed):</strong></li><li>Displayed <em>before</em> your app starts running.</li><li>Managed by iOS, defined via <strong>Info.plist</strong>.</li><li>Very limited: background color + static image/logo.</li><li>Purpose: to make app startup feel seamless.</li><li><strong>Splash Screen (App-managed):</strong></li><li>A SwiftUI view you build yourself.</li><li>Displayed <em>after</em> the app launches.</li><li>Flexible: animations, branding, custom layouts.</li></ul><p>🔑 <strong>Why do you see a white screen first?</strong><br> If you don’t provide a system Launch Screen, iOS falls back to a blank white screen until your app loads. That’s why you need both.</p><h3>🛠️ Adding a Launch Screen in Xcode 26</h3><p>This is the official way Apple recommends.</p><ol><li>Open <strong>Info.plist</strong>.</li><li>Add a new key:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5nxBm7-5oQ-21061ztxvrQ.png" /></figure><p>Go to your <strong>Assets</strong>:</p><ul><li>Add an <strong>Image Set</strong> named LaunchScreen.</li></ul><p>That’s it — you now have a basic Launch Screen that appears instantly when the app is opened.</p><h3>🖼️ Creating a Custom Splash Screen in SwiftUI</h3><p>Now let’s build a branded Splash Screen with SwiftUI that appears after the system Launch Screen.</p><pre>import SwiftUI<br><br>struct SplashScreenView: View {<br>    var body: some View {<br>        ZStack {<br>            Color.white<br>                .ignoresSafeArea()<br>            <br>            VStack {<br>                Image(systemName: &quot;bus.fill&quot;)<br>                    .resizable()<br>                    .frame(width: 100, height: 100)<br>                    .foregroundColor(.blue)<br>                <br>                Text(&quot;Gado Bus&quot;)<br>                    .font(.title)<br>                    .bold()<br>                    .padding(.top, 16)<br>            }<br>        }<br>    }<br>}</pre><p>Then in your app entry point:</p><pre>import SwiftUI<br><br>@main<br>struct LaunchScreenApp: App {<br>    @State private var showLaunchScreen = true<br>    var body: some Scene {<br>        WindowGroup {<br>            if showLaunchScreen {<br>                SplashScreenView()<br>                    .onAppear {<br>                        DispatchQueue.main.asyncAfter(deadline: .now() + 2) {<br>                            showLaunchScreen = false<br>                        }<br>                    }<br>            } else {<br>                ContentView()<br>            }<br>        }<br>    }<br>}</pre><p>This displays your Splash Screen for 2 seconds before transitioning to the main content.</p><h3>⚖️ Best of Both Worlds</h3><p>To summarize:</p><ol><li><strong>Launch Screen (Info.plist):</strong></li></ol><ul><li>Appears instantly, avoids the ugly white screen.</li><li>Should be simple (solid background + static logo).</li></ul><ol><li><strong>Splash Screen (SwiftUI):</strong></li></ol><ul><li>Shown after the app launches.</li><li>Perfect for branding, animations, and transitions.</li></ul><p>By combining them, you ensure:</p><ul><li>No white flash at startup.</li><li>A smooth transition into your beautifully designed app.</li></ul><h3>📂 Try It Yourself</h3><p>I’ve created a simple demo project on GitHub where you can try both approaches (system Launch Screen + SwiftUI Splash Screen) in action.</p><p>👉 Don’t forget to start it <a href="https://github.com/ahmedgado95/LaunchScreen/tree/main">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edb33035878a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>