<?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 Asheesh Verma on Medium]]></title>
        <description><![CDATA[Stories by Asheesh Verma on Medium]]></description>
        <link>https://medium.com/@asheeshverma?source=rss-45060e2d4497------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mSKyuBiKweUkM_Ap.</url>
            <title>Stories by Asheesh Verma on Medium</title>
            <link>https://medium.com/@asheeshverma?source=rss-45060e2d4497------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 13:16:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@asheeshverma/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[SwiftUI: State and Binding]]></title>
            <link>https://medium.com/@asheeshverma/swiftui-state-and-binding-e2723cdf81bf?source=rss-45060e2d4497------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2723cdf81bf</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[state]]></category>
            <category><![CDATA[binding]]></category>
            <dc:creator><![CDATA[Asheesh Verma]]></dc:creator>
            <pubDate>Sat, 17 Sep 2022 04:31:42 GMT</pubDate>
            <atom:updated>2022-09-17T04:31:42.373Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BXAL3BldB1bUPmf9" /><figcaption>Photo by <a href="https://unsplash.com/@danbuckophotography?utm_source=medium&amp;utm_medium=referral">Dan Bucko</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Both @State and @Binding are property wrappers.</p><h4>@State</h4><ul><li>A State property is connected to the view.</li><li>It is used to <strong>update the value of a variable every time</strong>.</li><li>If we change the property state then SwiftUI will automatically<strong> reload the body of the view</strong>.</li><li>All the fields marked as State are <strong>stored in special separated memory</strong>, where only the corresponding view can access and update them.</li></ul><h4>@Binding</h4><ul><li>A property wrapper type that can <strong>read and write a value owned by a source of truth</strong>.</li><li>Using this, you can access the state property of another view.</li><li>Use a binding to create a two-way connection between a property that stores data, and a view that displays and changes the data.</li></ul><p>For example, <strong>a button that toggles between play and pause can create a binding to a property of its parent view</strong> using the Binding property wrapper.</p><p><strong>PlayButton View:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78acd7f777e68db7c4eb2123b41e6e90/href">https://medium.com/media/78acd7f777e68db7c4eb2123b41e6e90/href</a></iframe><p><strong>PlayerView:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f80deb08397a83cba659bcdb99047bd2/href">https://medium.com/media/f80deb08397a83cba659bcdb99047bd2/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*dyi9-EexEvzZA8jksxTrRA.gif" /></figure><p>When PlayerView initialises PlayButton, it passes a binding of its state property into the button’s binding property.</p><p>Applying the $ prefix to a property wrapped value returns its <a href="https://developer.apple.com/documentation/swiftui/state/projectedvalue">projectedValue</a>, which for a state property wrapper returns a binding to the value.</p><p>Whenever the user taps the PlayButton, the PlayerView updates its isPlaying state.</p><p><strong>Github Code:</strong></p><p><a href="https://github.com/asheesh5391/SwiftUIStateAndBinding">GitHub - asheesh5391/SwiftUIStateAndBinding</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2723cdf81bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SwiftUI: LazyVGrid and LazyHGrid for CollectionView]]></title>
            <link>https://medium.com/@asheeshverma/swiftui-lazyvgrid-and-lazyhgrid-for-collectionview-a6638a1c217b?source=rss-45060e2d4497------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6638a1c217b</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[collectionview]]></category>
            <category><![CDATA[gridview]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Asheesh Verma]]></dc:creator>
            <pubDate>Sun, 28 Aug 2022 05:01:08 GMT</pubDate>
            <atom:updated>2022-08-28T05:01:08.198Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YiUO_xzyvlqYvgNc" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>LazyVGrid</strong> and <strong>LazyHGrid</strong> are a container view that arranges child views in a grid structure.</p><p><strong>LazyVGrid</strong> arranges its child views in <strong>Vertical</strong>(<strong>V) direction.<br>LazyHGrid</strong> arranges its child views in <strong>Horizontal</strong>(H<strong>) direction.</strong></p><h3><strong>Steps required to create a grid layout:</strong></h3><ol><li>Using <strong>GridItem </strong>declare rows or columns based on the grid you want to use.</li><li>Choose <strong>LazyVGrid</strong> or <strong>LazyHGrid</strong> based on the direction you want.</li><li>Subview a grid view in <strong>ScrollView</strong>. The grid view is to arrange its child views in a grid structure, not for scrollable.</li><li>Subview the <strong>element(Image, Text etc)</strong> which you want to use within grid.</li></ol><h3>Example of <strong>LazyVGrid with 2 Columns:</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4a23e23acbb14ba34dd70e0d9a94aa1/href">https://medium.com/media/c4a23e23acbb14ba34dd70e0d9a94aa1/href</a></iframe><p><strong>// 5</strong> <strong>.onAppear(perform: getFlavors) </strong>is triggered when a view appears on the screen and get the data for collection view or grid view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/1*mrN7Q5dXhdEFfI1THpbbHA.png" /><figcaption><strong>LazyVGrid with 2 Columns</strong></figcaption></figure><h3>Example of LazyHGrid with 2 rows:</h3><p><strong>Use LazyHGrid(</strong>LazyVGrid(columns: columns, spacing: 20)<strong>) instead LazyVGrid(</strong>LazyHGrid(rows: rows, spacing: 20)<strong>)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/1*1MiHP8-OpOhQF7gRB_-Iog.png" /><figcaption><strong>LazyHGrid with 2 Rows</strong></figcaption></figure><h3>About GridItem</h3><p>Every column in a grid has to be defined using <strong><em>GridItem</em></strong> data structure.<br><strong><em>GridItem</em></strong> type allows us to specify <strong>size</strong>, <strong>alignment</strong>, and <strong>spacing</strong> for every column.</p><h4><strong>Size</strong></h4><p>The size of the grid item.<br>We can define <strong>width of a column item</strong> in <strong>LazyVGrid</strong> and <strong>height of a row item</strong> in <strong>LazyHGrid</strong> using <strong>three</strong> predefine <strong>size</strong> enum.</p><p>GridItem(.fixed(100))<br>GridItem(.flexible()) or GridItem(.flexible(minimum: 10, maximum: 100))<br>GridItem(.adaptive(minimum: 0))</p><h4>Alignment</h4><p>The alignment to use for this grid item. By default, each item will <strong>centre align</strong> within a row/column.</p><p>GridItem(.fixed(100), alignment: .top)<br>GridItem(.fixed(100), alignment: .bottom)<br>GridItem(.fixed(100), alignment: .center)<br>GridItem(.fixed(100), alignment: .topLeading)<br>GridItem(.fixed(100), alignment: .bottomTrailing)</p><h4>Spacing</h4><p>The spacing to use between this and the next item.</p><p>GridItem(.fixed(50))<br>GridItem(.fixed(50), spacing: 10)<br>GridItem(.fixed(50), spacing: 20)<br>GridItem(.fixed(50), spacing: 30)<br>GridItem(.fixed(50), spacing: 40)</p><h3>Conclusion:</h3><p><strong>There is no such collection view component in SwiftUI. </strong>Instead, you will use <strong>a</strong> <strong>List/LazyVGrid/LazyHGrid</strong> component to render lists of content or grid of component like collection view.</p><p>Thats it for now. I hope you enjoyed this piece and you have learned how to create CollectionView in SwiftUI</p><h4>Source Code</h4><p><a href="https://github.com/asheesh5391/LazyVGridAndLazyHGrid">GitHub - asheesh5391/LazyVGridAndLazyHGrid</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6638a1c217b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>