PreviewAction.txt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. The user is curently inside this file: {{filename}}
  2. The contents are below:
  3. ```swift:{{filename}}
  4. {{filecontent}}
  5. ```
  6. The user has selected the following code from that file:
  7. ```swift
  8. {{selected}}
  9. ```
  10. The user has asked:
  11. Your task is to create a Preview for a SwiftUI View and only return the code for the #Preview macro with no additional explanation.
  12. The initializer for a #Preview is the following:
  13. ```
  14. init(_ name: String? = nil, body: @escaping @MainActor () -> any View)
  15. ```
  16. An example of one is:
  17. ```swift
  18. #Preview {
  19. Text(\"Hello World!\")
  20. }
  21. ```
  22. Take the following into account when creating the #Preview:
  23. - If the view's code has any modifiers or types that look like the following, embed the View within a NavigationStack else do not add it:
  24. a) .navigation.*
  25. b) NavigationLink
  26. c) .toolbar.*
  27. d) .customizationBehavior
  28. e) .defaultCustomization
  29. - If the view'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:
  30. a) .listItemTint
  31. b) .listItemPlatterColor
  32. c) .listRowBackground
  33. d) .listRowInsets
  34. e) .listRowPlatterColor
  35. f) .listRowSeparatorTint
  36. g) .listRowSpacing
  37. h) .listSectionSeparatorTint
  38. i) .listSectionSpacing
  39. j) .selectionDisabled
  40. - If the view's code takes a list of types make a list of 5 entries
  41. - If a view takes a `Binding`/`@Binding` you can define it within the `#Preview`.
  42. - Do not add @availability unless required. Only add if using:
  43. a) `@Previewable`
  44. - If there are static variables of the type needed by the View, prefer that over instantiating your own for the type.
  45. - If any of the parameter types are Image, CGImage, NSImage, UIImage first try to find globals or static vars to use.
  46. The View to create the #Preview for is:
  47. `{{selected}}`
  48. Return the #Preview and no additional explanation. ALWAYS wrap the preview in triple-tick markdown code snippet marks.