import{_ as s,c as a,o as e,ae as p}from"./chunks/framework.CBTkueSR.js";const w=JSON.parse('{"title":"","description":"","frontmatter":{},"headers":[],"relativePath":"en/xcode/PreviewAction.md","filePath":"en/xcode/PreviewAction.md","lastUpdated":1760450691000}'),i={name:"en/xcode/PreviewAction.md"};function t(l,n,o,c,r,d){return e(),a("div",null,[...n[0]||(n[0]=[p(`<h2 id="previewaction-txt" tabindex="-1">PreviewAction.txt <a class="header-anchor" href="#previewaction-txt" aria-label="Permalink to &quot;PreviewAction.txt&quot;">​</a></h2><div class="language-text vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">text</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>The user is curently inside this file: {{filename}}</span></span>
<span class="line"><span>The contents are below:</span></span>
<span class="line"><span>\`\`\`swift:{{filename}}</span></span>
<span class="line"><span>{{filecontent}}</span></span>
<span class="line"><span>\`\`\`</span></span>
<span class="line"><span></span></span>
<span class="line"><span>The user has selected the following code from that file:</span></span>
<span class="line"><span>\`\`\`swift</span></span>
<span class="line"><span>{{selected}}</span></span>
<span class="line"><span>\`\`\`</span></span>
<span class="line"><span></span></span>
<span class="line"><span>The user has asked:</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Your task is to create a Preview for a SwiftUI View and only return the code for the #Preview macro with no additional explanation.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>The initializer for a #Preview is the following:</span></span>
<span class="line"><span></span></span>
<span class="line"><span>\`\`\`</span></span>
<span class="line"><span>init(_ name: String? = nil, body: @escaping @MainActor () -&gt; any View)</span></span>
<span class="line"><span>\`\`\`</span></span>
<span class="line"><span></span></span>
<span class="line"><span>An example of one is:</span></span>
<span class="line"><span>\`\`\`swift</span></span>
<span class="line"><span>#Preview {</span></span>
<span class="line"><span>      Text(\\&quot;Hello World!\\&quot;)</span></span>
<span class="line"><span>}</span></span>
<span class="line"><span>\`\`\`</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Take the following into account when creating the #Preview:</span></span>
<span class="line"><span>- If the view&#39;s code has any modifiers or types that look like the following, embed the View within a NavigationStack else do not add it:</span></span>
<span class="line"><span>    a) .navigation.*</span></span>
<span class="line"><span>    b) NavigationLink</span></span>
<span class="line"><span>    c) .toolbar.*</span></span>
<span class="line"><span>    d) .customizationBehavior</span></span>
<span class="line"><span>    e) .defaultCustomization</span></span>
<span class="line"><span>- If the view&#39;s code has any modifiers that look like the following, or has the suffix Row, embed the View within a \`List\` else do not add it:</span></span>
<span class="line"><span>    a) .listItemTint</span></span>
<span class="line"><span>    b) .listItemPlatterColor</span></span>
<span class="line"><span>    c) .listRowBackground</span></span>
<span class="line"><span>    d) .listRowInsets</span></span>
<span class="line"><span>    e) .listRowPlatterColor</span></span>
<span class="line"><span>    f) .listRowSeparatorTint</span></span>
<span class="line"><span>    g) .listRowSpacing</span></span>
<span class="line"><span>    h) .listSectionSeparatorTint</span></span>
<span class="line"><span>    i) .listSectionSpacing</span></span>
<span class="line"><span>    j) .selectionDisabled</span></span>
<span class="line"><span>- If the view&#39;s code takes a list of types make a list of 5 entries</span></span>
<span class="line"><span>- If a view takes a \`Binding\`/\`@Binding\` you can define it within the \`#Preview\`.</span></span>
<span class="line"><span>- Do not add @availability unless required. Only add if using:</span></span>
<span class="line"><span>    a) \`@Previewable\`</span></span>
<span class="line"><span>- If there are static variables of the type needed by the View, prefer that over instantiating your own for the type.</span></span>
<span class="line"><span>- If any of the parameter types are Image, CGImage, NSImage, UIImage first try to find globals or static vars to use.</span></span>
<span class="line"><span></span></span>
<span class="line"><span>The View to create the #Preview for is:</span></span>
<span class="line"><span>\`{{selected}}\`</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Return the #Preview and no additional explanation. ALWAYS wrap the preview in triple-tick markdown code snippet marks.</span></span></code></pre></div>`,2)])])}const f=s(i,[["render",t]]);export{w as __pageData,f as default};
