<?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 Didik Maulana Ardiansyah on Medium]]></title>
        <description><![CDATA[Stories by Didik Maulana Ardiansyah on Medium]]></description>
        <link>https://medium.com/@didikmaulana?source=rss-937bda32a727------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oDqouzkgljqQcTGDlbGI-w.png</url>
            <title>Stories by Didik Maulana Ardiansyah on Medium</title>
            <link>https://medium.com/@didikmaulana?source=rss-937bda32a727------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:00:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@didikmaulana/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[Flutter: The Easy Way to Handle Data Models Using Freezed]]></title>
            <link>https://blog.stackademic.com/flutter-the-easy-way-to-handle-data-models-using-freezed-ab3ee057f42c?source=rss-937bda32a727------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab3ee057f42c</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter-freezed]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Didik Maulana Ardiansyah]]></dc:creator>
            <pubDate>Tue, 05 Nov 2024 03:40:07 GMT</pubDate>
            <atom:updated>2024-11-12T01:11:09.189Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JYhcMmE-0O1u-7NFqMJV4g.png" /></figure><p>Hey Flutter developer! Tired of writing tons of boring code just to handle your data? Let’s learn how Freezed can make your life easier. No more manual JSON parsing, no more bugs from mutable state — just clean, simple data handling that actually makes sense.</p><h3>Quick Setup</h3><p>Drop these lines in your pubspec.yaml and you&#39;re ready to go:</p><pre>dependencies:<br>  freezed_annotation: ^2.4.4<br>  json_annotation: ^4.9.0<br><br>dev_dependencies:<br>  build_runner: ^2.4.13<br>  freezed: ^2.5.7<br>  json_serializable: ^6.8.0</pre><h3>JSON Handling: The Good Parts 🎯</h3><h4>1. Basic JSON Example</h4><p>Let’s start with something you’ll use every day — handling API responses:</p><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;<br><br>part &#39;user.freezed.dart&#39;;<br>part &#39;user.g.dart&#39;;<br><br>@freezed<br>class User with _$User {<br>  const factory User({<br>    required int id,<br>    required String name,<br>    @JsonKey(name: &#39;email_address&#39;) required String email,<br>    @Default(false) bool isPremium,<br>  }) = _User;<br><br>  factory User.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$UserFromJson(json);<br>}<br><br>// Example usage for simple JSON<br>void main() {<br>  final jsonData = {<br>    &#39;id&#39;: 1,<br>    &#39;name&#39;: &#39;Didik Maulana Ardiansyah&#39;,<br>    &#39;email_address&#39;: &#39;didikmaulana@gmail.com&#39;,<br>    &#39;isPremium&#39;: true<br>  };<br><br>  final user = User.fromJson(jsonData);<br>  print(user.name);<br>  <br>  // Convert back to JSON<br>  final jsonMap = user.toJson();<br>}</pre><h4>2. Nested JSON Objects</h4><p>Handling nested JSON like a pro:</p><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;<br><br>part &#39;order.freezed.dart&#39;;<br>part &#39;order.g.dart&#39;;<br><br>part &#39;product.freezed.dart&#39;;<br>part &#39;product.g.dart&#39;;<br><br>@freezed<br>class Order with _$Order {<br>  const factory Order({<br>    required String orderId,<br>    required User customer,<br>    required List&lt;Product&gt; items,<br>    required Address shippingAddress,<br>  }) = _Order;<br><br>  factory Order.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$OrderFromJson(json);<br>}<br><br>@freezed<br>class Product with _$Product {<br>  const factory Product({<br>    required String id,<br>    required String name,<br>    required double price,<br>    @Default(0) int quantity,<br>  }) = _Product;<br><br>  factory Product.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$ProductFromJson(json);<br>}<br><br>// Example usage with nested JSON:<br>final orderJson = {<br>  &#39;orderId&#39;: &#39;order_1&#39;,<br>  &#39;customer&#39;: {<br>    &#39;id&#39;: 1,<br>    &#39;name&#39;: &#39;Didik Maulana Ardiansyah&#39;,<br>    &#39;email_address&#39;: &#39;didikmaulana@gmail.com&#39;,<br>    &#39;isPremium&#39;: true<br>  },<br>  &#39;items&#39;: [<br>    {<br>      &#39;id&#39;: &#39;prod_1&#39;,<br>      &#39;name&#39;: &#39;iPhone 16 Pro&#39;,<br>      &#39;price&#39;: 99.99,<br>      &#39;quantity&#39;: 2<br>    }<br>  ],<br>  &#39;shippingAddress&#39;: {<br>    &#39;street&#39;: &#39;Jl Gatot Subroto&#39;,<br>    &#39;city&#39;: &#39;Jakarta&#39;,<br>    &#39;zipCode&#39;: &#39;12345&#39;<br>  }<br>};<br><br>final order = Order.fromJson(orderJson);</pre><h3>Pro Tips for Clean Data Handling 🚀</h3><h4>1. Smart Defaults</h4><pre>@freezed<br>class Settings with _$Settings {<br>  const factory Settings({<br>    // Smart defaults that make sense<br>    @Default(&#39;en_US&#39;) String language,<br>    @Default(true) bool pushNotifications,<br>    @Default(&lt;String&gt;[]) List&lt;String&gt; recentSearches,<br>    // Optional fields with null safety<br>    DateTime? lastLoginDate,<br>  }) = _Settings;<br><br>  factory Settings.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$SettingsFromJson(json);<br>}</pre><h4>2. Custom JSON Keys for Messy APIs</h4><pre>@freezed<br>class ApiResponse with _$ApiResponse {<br>  const factory ApiResponse({<br>    @JsonKey(name: &#39;status_code&#39;) required int statusCode,<br>    @JsonKey(name: &#39;message_text&#39;) required String message,<br>    @JsonKey(name: &#39;data_payload&#39;) required Map&lt;String, dynamic&gt; data,<br>    // Convert string timestamps to DateTime<br>    @JsonKey(<br>      name: &#39;timestamp&#39;,<br>      fromJson: _dateTimeFromString,<br>      toJson: _dateTimeToString,<br>    )<br>    required DateTime timestamp,<br>  }) = _ApiResponse;<br><br>  factory ApiResponse.fromJson(Map&lt;String, dynamic&gt; json) =&gt; <br>    _$ApiResponseFromJson(json);<br>}<br><br>DateTime _dateTimeFromString(String str) =&gt; DateTime.parse(str);<br>String _dateTimeToString(DateTime date) =&gt; date.toIso8601String(</pre><h4>3. Handling Optional Fields Gracefully</h4><pre>@freezed<br>class UserProfile with _$UserProfile {<br>  const factory UserProfile({<br>    required String id,<br>    required String name,<br>    // Optional fields with smart null handling<br>    String? bio,<br>    String? avatarUrl,<br>    @Default(&lt;String&gt;[]) List&lt;String&gt; interests,<br>    // Complex default value<br>    @Default(ThemeSettings()) ThemeSettings themeSettings,<br>  }) = _UserProfile;<br><br>  factory UserProfile.fromJson(Map&lt;String, dynamic&gt; json) =&gt; <br>    _$UserProfileFromJson(json);<br>}</pre><h4>4. API Response Wrapper Pattern</h4><pre>@freezed<br>class ApiResult&lt;T&gt; with _$ApiResult&lt;T&gt; {<br>  const factory ApiResult.success(T data) = Success&lt;T&gt;;<br>  const factory ApiResult.error(String message) = Error&lt;T&gt;;<br>  const factory ApiResult.loading() = Loading&lt;T&gt;;<br>}<br><br>// Usage example:<br>Future&lt;ApiResult&lt;List&lt;Product&gt;&gt;&gt; fetchProducts() async {<br>  try {<br>    final response = await dio.get(&#39;/products&#39;);<br>    final products = (response.data as List)<br>        .map((json) =&gt; Product.fromJson(json))<br>        .toList();<br>    return ApiResult.success(products);<br>  } catch (e) {<br>    return ApiResult.error(e.toString());<br>  }<br>}<br><br>// In your UI:<br>final result = await fetchProducts();<br>result.when(<br>  success: (products) =&gt; displayProducts(products),<br>  error: (message) =&gt; showError(message),<br>  loading: () =&gt; showLoadingSpinner(),<br>);</pre><h4>5. Using CopyWith</h4><pre>final user = User(<br>  id: &quot;1&quot;,<br>  name: &quot;Didik Maulana Ardiansyah&quot;,<br>  email: &quot;didikmaulana@gmail.com&quot;<br>);<br><br>// Create a new user with updated name<br>final updatedUser = user.copyWith(name: &quot;Tim Cook&quot;);</pre><h3>Quick Tips for Daily Use 🎯</h3><h4>1. Auto-generate All Files</h4><p>Run the following command in terminal:</p><pre># One-time build<br>flutter pub run build_runner build<br><br># Watch for changes (during development)<br>flutter pub run build_runner watch<br><br># Force rebuild when stuck<br>flutter pub run build_runner build --delete-conflicting-outputs</pre><h4>2. VS Code Snippets</h4><p>Create snippets for common Freezed patterns:</p><pre>{<br>	&quot;Freezed Class&quot;: {<br>	  &quot;prefix&quot;: &quot;fzd&quot;,<br>	  &quot;body&quot;: [<br>		&quot;import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;&quot;,<br>		&quot;&quot;,<br>		&quot;part &#39;${1:filename}.freezed.dart&#39;;&quot;,<br>		&quot;part &#39;${1:filename}.g.dart&#39;;&quot;,<br>		&quot;&quot;,<br>		&quot;@freezed&quot;,<br>		&quot;class ${2:ClassName} with _$${2:ClassName} {&quot;,<br>		&quot;  const factory ${2:ClassName}({&quot;,<br>		&quot;    required ${3:String} ${4:field},&quot;,<br>		&quot;  }) = _${2:ClassName};&quot;,<br>		&quot;&quot;,<br>		&quot;  factory ${2:ClassName}.fromJson(Map&lt;String, dynamic&gt; json) =&gt;&quot;, <br>		&quot;    _$${2:ClassName}FromJson(json);&quot;,<br>		&quot;}&quot;<br>	  ]<br>	}<br>  }</pre><h3>When to Use Freezed? ✨</h3><p>✅ Perfect for:</p><ul><li>Data models that need JSON serialization</li><li>State management</li><li>API responses</li><li>Complex object structures</li><li>When immutability is important</li></ul><p>❌ Maybe skip it for:</p><ul><li>Simple one-off classes</li><li>Classes that need to be mutable</li><li>When you don’t need JSON serialization or immutability</li></ul><h3>Wrapping Up</h3><p>Freezed is like having a smart code generator that writes all the boring stuff for you. It helps you write safer, cleaner code with less effort. Start small, maybe with just one model, and you’ll quickly see why so many Flutter developers love it!</p><blockquote>Remember: The best code is the code you don’t have to write. Let Freezed handle the repetitive stuff while you focus on building awesome features!</blockquote><h3>Stackademic 🎓</h3><p>Thank you for reading until the end. Before you go:</p><ul><li>Please consider <strong>clapping</strong> and <strong>following</strong> the writer! 👏</li><li>Follow us <a href="https://twitter.com/stackademichq"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/stackademic"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/c/stackademic"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://differ.blog/"><strong>Create a free AI-powered blog on Differ.</strong></a></li><li>More content at <a href="https://stackademic.com/"><strong>Stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab3ee057f42c" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/flutter-the-easy-way-to-handle-data-models-using-freezed-ab3ee057f42c">Flutter: The Easy Way to Handle Data Models Using Freezed</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Github Copilot in Xcode]]></title>
            <link>https://medium.com/@didikmaulana/github-copilot-in-xcode-b1d550622823?source=rss-937bda32a727------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1d550622823</guid>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Didik Maulana Ardiansyah]]></dc:creator>
            <pubDate>Tue, 05 Nov 2024 03:30:54 GMT</pubDate>
            <atom:updated>2024-11-05T03:30:54.006Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8RgTOakZrlqxGFr1.png" /></figure><p>Hey there, iOS developers! 👋 If you’ve been curious about bringing AI-powered code suggestions into your Xcode workflow, you’re in the right place. Today, I’ll walk you through setting up GitHub Copilot in Xcode — it’s easier than you might think!</p><h3>What is GitHub Copilot?</h3><p>Before we dive in, let’s quickly cover what Copilot brings to the table. Think of it as your AI pair programmer that:</p><ul><li>Suggests whole lines or blocks of code as you type</li><li>Understands your coding context and project structure</li><li>Works with Swift, Objective-C, and other languages supported in Xcode</li></ul><h3>Prerequisites</h3><p>Before we start, make sure you have:</p><ul><li>Xcode 8+ or later installed.</li><li>A GitHub account and an active GitHub Copilot subscription.</li><li>macOS 12.0 (Monterey) or later.</li></ul><h3>Installation Steps</h3><h4>1. Download the Extension</h4><p>First, grab the GitHub Copilot extension from GitHub’s official repository:</p><ol><li>Download the dmg from <a href="https://github.com/github/CopilotForXcode/releases/latest/download/GitHubCopilotForXcode.dmg">the latest release</a>.</li><li>Extract the downloaded file</li></ol><h4>2. Install the Extension</h4><p>Now let’s get that extension into Xcode:</p><ol><li>Open the extracted folder</li><li>Double-click on CopilotForXcode.app</li><li>Click “Open” if you see a security warning</li><li>Follow the installation prompts</li><li>The app will appear in your menu bar with the GitHub Copilot icon</li></ol><h4>3. Grant Required Permissions</h4><p>The extension requires two specific permissions to function properly:</p><p><strong>Accessibility Permission</strong></p><ul><li>You’ll be automatically prompted to enable this when you first start the extension</li><li>Follow the system prompts to grant access</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/0*4Ipvs6c_egAbtmiJ.png" /><figcaption>Github Copilot for Xcode Extension</figcaption></figure><h4>Xcode Source Editor Permission</h4><ol><li>Open the GitHub Copilot extension application</li><li>Click <strong>Extension Permission</strong> and click <strong>Xcode Source Editor</strong></li><li>Enable GitHub Copilot and click <strong>Done</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/0*yctNVyzHKk_dg8hg.png" /><figcaption>Xcode Source Editor</figcaption></figure><blockquote><strong>Important</strong>: After granting these permissions, restart Xcode. You’ll see a new “GitHub Copilot” item in the “Editor” menu.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*EE3oiq_rK5Fbjvib.png" /><figcaption>Github Copilot in Xcode Editor menu.</figcaption></figure><h4>4. Sign in to GitHub</h4><p>Time to authenticate your GitHub account:</p><ol><li>Open the GitHub Copilot extension application</li><li>Click <strong>Login to GitHub</strong></li><li>Follow the prompts to authorize the extension</li><li>Once authenticated, you’ll see a confirmation message</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E9cC7-RGuAsXFKkM.png" /><figcaption>Github Copilot Connection</figcaption></figure><h4>5. Try Your First Copilot Suggestion</h4><p>Let’s make sure everything is working:</p><p>1. Open Xcode and create a new Swift file</p><p>2. Add this comment and type the function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qJiQoiPlw5ICQumB.png" /></figure><p>3. Copilot should suggest a complete function implementation.</p><p>4. Press ⌥ + Tab to accept full suggestion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*laJf6deoDcKhr25x.png" /></figure><p>5. If you see suggestions appearing, congratulations! Copilot is working correctly.</p><h3>Pro Tips</h3><p>Here are some tips to get the most out of Copilot:</p><h4>1. Managing Updates</h4><ul><li>Click Check for Updates from the menu item or in the settings application</li><li>Restart Xcode after installing updates for them to take effect</li></ul><h4>2. Optimize Xcode Settings</h4><p>Disable Predictive code completion to avoid conflicts</p><ul><li>Go to Xcode &gt; Preferences</li><li>Navigate to Text Editing &gt; Editing</li><li>Uncheck Predictive code completion</li></ul><h4>3. Keyboard Shortcuts</h4><ul><li>Press Tab to accept the first line of a suggestion</li><li>Hold Option to view the full suggestion</li><li>Press Option + Tab to accept the full suggestion</li></ul><h4>4. Writing Effective Comments</h4><ul><li>Be descriptive in your comments for better suggestions</li><li>Include expected input/output in your comments</li><li>Use natural language as if explaining to another developer</li></ul><h4>5. Contextual Awareness</h4><ul><li>Keep related code visible in the editor</li><li>Include relevant import statements</li><li>Structure your code logically for better suggestions</li></ul><h3>Pricing and Subscription</h3><p>Remember that GitHub Copilot is a paid service: (as of November 2024)</p><ul><li>Free for verified students and teachers</li><li>Free for popular open source project maintainers</li><li>$10/month or $100/year for individual developers</li><li>Enterprise pricing available for teams</li></ul><h3>Additional Resources</h3><p>Need more help? Check out these official resources:</p><ul><li>Official extension repository and latest releases — <a href="https://github.com/github/CopilotForXcode">GitHub Copilot for Xcode Repository</a></li><li>Having issues? Visit the <a href="https://github.com/github/CopilotForXcode/issues">Copilot for Xcode Issues</a> page</li><li>Want to learn more about Copilot? See the <a href="https://docs.github.com/en/copilot/overview-of-github-copilot">GitHub Copilot Overview</a></li><li>Need subscription help? Visit <a href="https://docs.github.com/en/billing/managing-billing-for-github-copilot">Copilot Billing</a></li></ul><h3>Conclusion</h3><p>GitHub Copilot for Xcode is a powerful tool that can significantly speed up your iOS development workflow. While it’s not meant to replace human developers, it’s an excellent assistant for handling boilerplate code, suggesting implementations, and learning new patterns.</p><p>Give it a try, and you might be surprised at how it enhances your coding experience. Happy coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1d550622823" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SwiftUI: Using Zoom Navigation Transition]]></title>
            <link>https://medium.com/@didikmaulana/swiftui-using-zoom-navigation-transition-d8d58d081e10?source=rss-937bda32a727------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8d58d081e10</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[navigation]]></category>
            <dc:creator><![CDATA[Didik Maulana Ardiansyah]]></dc:creator>
            <pubDate>Tue, 05 Nov 2024 03:07:45 GMT</pubDate>
            <atom:updated>2024-11-05T03:07:45.954Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVQfwgOPqMdu4a9tPz-65A.png" /></figure><p>Hey there, fellow iOS developers! Today I want to share something cool I’ve been working on — implementing that smooth, satisfying zoom transition you see in apps like Instagram when tapping on an image. You know the one — where the thumbnail elegantly expands into a full-screen view? Let’s break down how to create this effect in SwiftUI using new approach.</p><h3>Understanding Navigation Transitions</h3><p>SwiftUI’s navigation transitions recently got a significant update, making fluid animations much more accessible. By combining NavigationStack with matched geometry effects, we can create seamless transitions that give your app that premium feel.</p><h3>System Requirements</h3><p>Before we dive in, let’s cover the requirements to implement this feature:</p><ol><li><strong>Xcode 16.0 or later</strong></li><li><strong>Minimum OS Versions:</strong></li></ol><ul><li>iOS 18.0+</li><li>iPadOS 18.0+</li><li>macOS 15.0+</li><li>tvOS 18.0+</li><li>watchOS 11.0+</li><li>visionOS 2.0+</li></ul><h3>Step-by-Step Implementation</h3><p>Let’s break down the implementation into manageable steps. We’ll create a grid view of images that zoom smoothly into a detail view when tapped.</p><h4>1. Gallery View (ContentView)</h4><pre>import SwiftUI<br><br>struct ContentView: View {<br>    <br>    @Namespace private var namespace<br>    <br>    let imageUrls = [<br>        &quot;https://picsum.photos/id/10/300/300&quot;,<br>        &quot;https://picsum.photos/id/11/300/300&quot;,<br>        &quot;https://picsum.photos/id/12/300/300&quot;,<br>        &quot;https://picsum.photos/id/13/300/300&quot;,<br>        &quot;https://picsum.photos/id/14/300/300&quot;,<br>        &quot;https://picsum.photos/id/15/300/300&quot;,<br>        &quot;https://picsum.photos/id/16/300/300&quot;,<br>        &quot;https://picsum.photos/id/17/300/300&quot;,<br>        &quot;https://picsum.photos/id/18/300/300&quot;,<br>        &quot;https://picsum.photos/id/19/300/300&quot;,<br>        &quot;https://picsum.photos/id/20/300/300&quot;,<br>        &quot;https://picsum.photos/id/21/300/300&quot;<br>    ]<br>    <br>    let columns = [<br>        GridItem(.flexible(), spacing: 12),<br>        GridItem(.flexible(), spacing: 12)<br>    ]<br>    <br>    var body: some View {<br>        NavigationStack {<br>            ScrollView {<br>                LazyVGrid(columns: columns, spacing: 12) {<br>                    ForEach(imageUrls.indices, id: \.self) { index in<br>                        NavigationLink {<br>                            DetailView(imageUrl: imageUrls[index])<br>                                .navigationTransition(<br>                                    .zoom(sourceID: &quot;image-\(index)&quot;, in: namespace)<br>                                )<br>                        } label: {<br>                            AsyncImage(url: URL(string: imageUrls[index])) { image in<br>                                image<br>                                    .resizable()<br>                                    .aspectRatio(contentMode: .fill)<br>                            } placeholder: {<br>                                Rectangle()<br>                                    .fill(.gray.opacity(0.2))<br>                                    .overlay {<br>                                        ProgressView()<br>                                    }<br>                            }<br>                            .frame(height: 120)<br>                            .clipShape(RoundedRectangle(cornerRadius: 12))<br>                            .matchedTransitionSource(id: &quot;image-\(index)&quot;, in: namespace)<br>                        }<br>                    }<br>                }<br>                .padding()<br>            }<br>            .navigationTitle(&quot;Gallery&quot;)<br>        }<br>    }<br>}<br><br>#Preview {<br>    ContentView()<br>}</pre><h4>2. DetailView</h4><pre>import SwiftUI<br><br>struct DetailView: View {<br>   let imageUrl: String<br>   <br>   var body: some View {<br>       ScrollView {<br>           VStack(spacing: 0) {<br>               AsyncImage(url: URL(string: imageUrl)) { image in<br>                   image<br>                       .resizable()<br>                       .aspectRatio(contentMode: .fill)<br>               } placeholder: {<br>                   Rectangle()<br>                       .fill(.gray.opacity(0.2))<br>               }<br>               .frame(height: 400)<br>               <br>               VStack(alignment: .leading, spacing: 16) {<br>                   Text(&quot;Lorem ipsum dolor sit amet&quot;)<br>                       .font(.title)<br>                       .fontWeight(.bold)<br>                   <br>                   Text(&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&quot;)<br>                       .font(.body)<br>                       .foregroundStyle(.secondary)<br>               }<br>               .padding()<br>           }<br>       }<br>   }<br>}<br><br>#Preview {<br>    DetailView()<br>}</pre><h3>Core Concepts Explained</h3><h4>1. Namespace</h4><pre>@Namespace private var namespace</pre><p>The namespace creates a shared context for the transition animation. It’s like giving both views (gallery and detail) a common reference point so SwiftUI knows which views to animate between.</p><h4>2. Transition Source and Destination</h4><pre>// In Gallery View<br>.matchedTransitionSource(id: &quot;image-\(index)&quot;, in: namespace)<br><br>// In Navigation Link<br>.navigationTransition(.zoom(sourceID: &quot;image-\(index)&quot;, in: namespace))</pre><p>These two modifiers are the heart of the zoom transition:</p><ul><li>matchedTransitionSource marks the starting point of the animation</li><li>navigationTransition defines how the view should animate when navigating</li></ul><h4>3. Navigation Stack</h4><p>The NavigationStack wrapper enables the custom transition while maintaining standard navigation behavior. This means you get the zoom animation while keeping familiar navigation gestures and behaviors.</p><h3>The Final Result</h3><p>The end product is a polished gallery where tapping any image triggers a smooth zoom transition to its detail view. The thumbnail gracefully expands while the additional content slides in from below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*0jWmVLnmJDsWvTdDWe1mjg.gif" /><figcaption>The final preview</figcaption></figure><h3>Key Takeaways</h3><p>This zoom transition API demonstrates Apple’s commitment to providing developers with powerful tools for creating engaging user experiences. The implementation is straightforward, yet the impact on user experience is significant.</p><p>Whether you’re building a photo gallery, product catalog, or any app that transitions between grid and detail views, this transition adds that extra layer of polish users expect from modern apps.</p><p>Feel free to experiment with the animation parameters or adapt the layout to match your app’s design. The possibilities are endless!</p><p>Let me know in the comments if you’ve found interesting ways to customize this transition or have ideas for improving it. Happy coding! 🚀</p><blockquote>“Design is not just what it looks like and feels like. Design is how it works.” — Steve Jobs</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8d58d081e10" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>