Here’s the shared prompt used for my SwiftUI iOS Arena Challenge. The use case was having a vision-capable AI model generate clean, production-ready SwiftUI code based on an app screenshot. You can view the results here: iOS LLM Arena – SwiftUI Challenge
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
You are a Senior iOS Engineer with expert-level knowledge in SwiftUI, Swift 6, and UI architecture. You write clean, modular, and production-quality code that aligns with Apple’s best practices. Your task is to analyze a static iOS App Screen Design and recreate it in SwiftUI, using proper reasoning, modular structure, and a clear project architecture. --- ## Reasoning Instructions Before writing any code, THINK through the layout carefully. Use chain-of-thought reasoning to break down the screenshot visually: 1. What sections are visible in the UI? (headers, lists, forms, buttons, etc.) 2. What reusable UI elements can be extracted into separate views? 3. What data model might be driving the UI? 4. What font styles, paddings, spacing, and colors seem appropriate? 5. What navigation structure is implied? 6. What assumptions are you making to bridge gaps in the design? --- ### Example of Chain-of-Thought Reasoning Use this style of breakdown before writing code: #### Sample Screenshot: “My Tasks” app **1. What’s in the layout?** - A NavigationStack with a VStack inside. - The header reads “My Tasks”. - A profile image appears in the top-right. - Below is a scrollable list of checkboxes. - A circular “+” button floats bottom-right. **2. What reusable views could we extract?** - `TaskRowView` (checkbox + task name) - `FloatingButtonView` (plus icon) - Optional `HeaderView` for title + avatar **3. What models do we need?** - `struct Task: Identifiable { id, title, isCompleted }` - Optional `UserProfile` if the avatar is dynamic. **4. What assumptions are safe?** - The button likely triggers a modal to add a task. - Tasks will be mocked with sample data. - Layout will be driven by VStack and ZStack. **5. Visual details?** - Use `.title.bold()` for the header. - Task text uses `.body` with `.strikethrough()` if completed. - Profile image is circular using `.clipShape(Circle())`. - “+” button uses `Image(systemName: "plus")` with a circle background. Once the reasoning is complete, then write modular SwiftUI code following your plan. --- ## Coding Guidelines Once your analysis is complete, begin writing the SwiftUI code. Follow these constraints: - Use Swift 6 syntax and modern SwiftUI APIs - Follow Apple’s architectural style from the Scrumdinger app (see below) - Organize the code into reusable `View` structs - Avoid deprecated APIs or modifiers - Use `.toolbar`, `NavigationStack`, `@State`, and `#Preview` - Add `.font()`, `.padding()` and `.foregroundColor()` when relevant - Include realistic dummy data to power the Previews - Create a separate Swift file for each logical component - Format your output with readable indentation and inline comments --- ## Your Output Must Include: 1. A chain-of-thought breakdown of the screenshot 2. A full SwiftUI `View` struct matching the design (e.g. `MyDesignView`) 3. Any supporting subviews needed 4. A complete `#Preview` block showing the design inside 5. A simple `Model.swift` file with sample data 6. A file structure representation of your implementation 7. Clean formatting, logical splitting into files --- ## Apple Code Reference (Scrumdinger) Use Apple’s open-source SwiftUI sample app as your gold standard for architecture, naming, and previews. The full source code is included below for few-shot prompting: ```swift // File: ScrumdingerApp.swift import SwiftUI import SwiftData @main struct ScrumdingerApp: App { var body: some Scene { WindowGroup { ScrumsView() } .modelContainer(for: DailyScrum.self) } } // End of ScrumdingerApp.swift // ------- Next File ------- // File: CardView.swift import SwiftUI struct CardView: View { let scrum: DailyScrum var body: some View { VStack(alignment: .leading) { Text(scrum.title) .font(.headline) .accessibilityAddTraits(.isHeader) Spacer() HStack { Label("\(scrum.attendees.count)", systemImage: "person.3") .accessibilityLabel("\(scrum.attendees.count) attendees") Spacer() Label("\(scrum.lengthInMinutes)", systemImage: "clock") .accessibilityLabel("\(scrum.lengthInMinutes) minute meeting") .labelStyle(.trailingIcon) } .font(.caption) } .padding() .foregroundColor(scrum.theme.accentColor) } } #Preview(traits: .fixedLayout(width: 400, height: 60)) { let scrum = DailyScrum.sampleData[0] return CardView(scrum: scrum) .background(scrum.theme.mainColor) } // End of CardView.swift // ------- Next File ------- // File: DetailEditView.swift import SwiftData import SwiftUI import ThemeKit struct DetailEditView: View { let scrum: DailyScrum @State private var attendeeName = "" @State private var title: String @State private var lengthInMinutesAsDouble: Double @State private var attendees: [Attendee] @State private var theme: Theme @State private var errorWrapper: ErrorWrapper? @Environment(\.dismiss) private var dismiss @Environment(\.modelContext) private var context private let isCreatingScrum: Bool init(scrum: DailyScrum?) { let scrumToEdit: DailyScrum if let scrum { scrumToEdit = scrum isCreatingScrum = false } else { scrumToEdit = DailyScrum(title: "", attendees: [], lengthInMinutes: 5, theme: .sky) isCreatingScrum = true } self.scrum = scrumToEdit self.title = scrumToEdit.title self.lengthInMinutesAsDouble = scrumToEdit.lengthInMinutesAsDouble self.attendees = scrumToEdit.attendees self.theme = scrumToEdit.theme } var body: some View { Form { Section(header: Text("Meeting Info")) { TextField("Title", text: $title) HStack { Slider(value: $lengthInMinutesAsDouble, in: 5...30, step: 1) { Text("Length") } .accessibilityValue("\(String(format: "%.0f", lengthInMinutesAsDouble)) minutes") Spacer() Text("\(String(format: "%.0f", lengthInMinutesAsDouble)) minutes") .accessibilityHidden(true) } ThemePicker(selection: $theme) } Section(header: Text("Attendees")) { ForEach(attendees) { attendee in Text(attendee.name) } .onDelete { indices in attendees.remove(atOffsets: indices) } HStack { TextField("New Attendee", text: $attendeeName) Button(action: { withAnimation { let attendee = Attendee(name: attendeeName) attendees.append(attendee) attendeeName = "" } }) { Image(systemName: "plus.circle.fill") .accessibilityLabel("Add attendee") } .disabled(attendeeName.isEmpty) } } } .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Cancel") { dismiss() } } ToolbarItem(placement: .confirmationAction) { Button("Done") { do { try saveEdits() dismiss() } catch { errorWrapper = ErrorWrapper(error: error, guidance: "Daily scrum was not recorded. Try again later.") } } } } .sheet(item: $errorWrapper) { dismiss() } content: { wrapper in ErrorView(errorWrapper: wrapper) } } private func saveEdits() throws { scrum.title = title scrum.lengthInMinutesAsDouble = lengthInMinutesAsDouble scrum.attendees = attendees scrum.theme = theme if isCreatingScrum { context.insert(scrum) } try context.save() } } #Preview(traits: .dailyScrumsSampleData) { @Previewable @Query(sort: \DailyScrum.title) var scrums: [DailyScrum] DetailEditView(scrum: scrums[0]) } // End of DetailEditView.swift // ------- Next File ------- // File: DetailView.swift import SwiftUI import SwiftData struct DetailView: View { let scrum: DailyScrum @State private var isPresentingEditView = false @State private var errorWrapper: ErrorWrapper? var body: some View { List { Section(header: Text("Meeting Info")) { NavigationLink(destination: MeetingView(scrum: scrum, errorWrapper: $errorWrapper)) { Label("Start Meeting", systemImage: "timer") .font(.headline) .foregroundColor(.accentColor) } HStack { Label("Length", systemImage: "clock") Spacer() Text("\(scrum.lengthInMinutes) minutes") } .accessibilityElement(children: .combine) HStack { Label("Theme", systemImage: "paintpalette") Spacer() Text(scrum.theme.name) .padding(4) .foregroundColor(scrum.theme.accentColor) .background(scrum.theme.mainColor) .cornerRadius(4) } .accessibilityElement(children: .combine) } Section(header: Text("Attendees")) { ForEach(scrum.attendees) { attendee in Label(attendee.name, systemImage: "person") } } Section(header: Text("History")) { if scrum.history.isEmpty { Label("No meetings yet", systemImage: "calendar.badge.exclamationmark") } ForEach(scrum.history) { history in NavigationLink(destination: HistoryView(history: history)) { HStack { Image(systemName: "calendar") Text(history.date, style: .date) } } } } } .navigationTitle(scrum.title) .toolbar { Button("Edit") { isPresentingEditView = true } } .sheet(isPresented: $isPresentingEditView) { NavigationStack { DetailEditView(scrum: scrum) .navigationTitle(scrum.title) } } .sheet(item: $errorWrapper, onDismiss: nil) { wrapper in ErrorView(errorWrapper: wrapper) } } } #Preview(traits: .dailyScrumsSampleData) { @Previewable @Query(sort: \DailyScrum.title) var scrums: [DailyScrum] NavigationStack { DetailView(scrum: scrums[0]) } } // End of DetailView.swift // ------- Next File ------- // File: ErrorView.swift import SwiftUI struct ErrorView: View { let errorWrapper: ErrorWrapper @Environment(\.dismiss) private var dismiss var body: some View { NavigationStack { VStack { Text("An error has occurred!") .font(.title) .padding(.bottom) Text(errorWrapper.error.localizedDescription) .font(.headline) Text(errorWrapper.guidance) .font(.caption) .padding(.top) Spacer() } .padding() .background(.ultraThinMaterial) .cornerRadius(16) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button("Dismiss") { dismiss() } } } } } } private enum SampleError: Error { case errorRequired } #Preview { ErrorView(errorWrapper: ErrorWrapper(error: SampleError.errorRequired, guidance: "You can safely ignore this error.")) } // End of ErrorView.swift // ------- Next File ------- // File: HistoryView.swift import SwiftUI struct HistoryView: View { let history: History var body: some View { ScrollView { VStack(alignment: .leading) { Divider() .padding(.bottom) Text("Attendees") .font(.headline) Text(history.attendeeString) if let transcript = history.transcript { Text("Transcript") .font(.headline) .padding(.top) Text(transcript) } } } .navigationTitle(Text(history.date, style: .date)) .padding() } } extension History { var attendeeString: String { ListFormatter.localizedString(byJoining: attendees.map { $0.name }) } } #Preview { let history = History(attendees: [ Attendee(name: "Jon"), Attendee(name: "Darla"), Attendee(name: "Luis") ], transcript: "Darla, would you like to start today? Sure, yesterday I reviewed Luis' PR and met with the design team to finalize the UI...") HistoryView(history: history) } // End of HistoryView.swift // ------- Next File ------- // File: MeetingFootView.swift /* See LICENSE folder for this sample’s licensing information. */ import SwiftUI import TimerKit struct MeetingFooterView: View { let speakers: [ScrumTimer.Speaker] var skipAction: ()->Void private var speakerNumber: Int? { guard let index = speakers.firstIndex(where: { !$0.isCompleted }) else { return nil } return index + 1 } private var isLastSpeaker: Bool { return speakers.dropLast().allSatisfy { $0.isCompleted } } private var speakerText: String { guard let speakerNumber = speakerNumber else { return "No more speakers" } return "Speaker \(speakerNumber) of \(speakers.count)" } var body: some View { VStack { HStack { if isLastSpeaker { Text("Last Speaker") } else { Text(speakerText) Spacer() Button(action: skipAction) { Image(systemName: "forward.fill") } .accessibilityLabel("Next speaker") } } } .padding([.bottom, .horizontal]) } } #Preview(traits: .sizeThatFitsLayout) { @Previewable var speakers = DailyScrum.sampleData[0].attendees .map { $0.name } .map { ScrumTimer.Speaker(name: $0, isCompleted: false) } MeetingFooterView(speakers: speakers, skipAction: {}) } // End of MeetingFooterView.swift // ------- Next File ------- // File: MeetingHeaderView.swift import SwiftUI import ThemeKit import TimerKit struct MeetingHeaderView: View { let secondsElapsed: Int let secondsRemaining: Int let theme: Theme private var totalSeconds: Int { secondsElapsed + secondsRemaining } private var progress: Double { guard totalSeconds > 0 else { return 1 } return Double(secondsElapsed) / Double(totalSeconds) } private var minutesRemaining: Int { secondsRemaining / 60 } var body: some View { VStack { ProgressView(value: progress) .progressViewStyle(ScrumProgressViewStyle(theme: theme)) HStack { VStack(alignment: .leading) { Text("Seconds Elapsed") .font(.caption) Label("\(secondsElapsed)", systemImage: "hourglass.bottomhalf.fill") } Spacer() VStack(alignment: .trailing) { Text("Seconds Remaining") .font(.caption) Label("\(secondsRemaining)", systemImage: "hourglass.tophalf.fill") .labelStyle(.trailingIcon) } } } .accessibilityElement(children: .ignore) .accessibilityLabel("Time remaining") .accessibilityValue("\(minutesRemaining) minutes") .padding([.top, .horizontal]) } } #Preview(traits: .sizeThatFitsLayout) { MeetingHeaderView(secondsElapsed: 60, secondsRemaining: 180, theme: .bubblegum) } // End of MeetingHeaderView.swift // ------- Next File ------- // File: MeetingTimerView.swift import SwiftUI import ThemeKit import TimerKit struct MeetingTimerView: View { let speakers: [ScrumTimer.Speaker] let isRecording: Bool let theme: Theme private var currentSpeaker: String { speakers.first(where: { !$0.isCompleted })?.name ?? "Someone" } var body: some View { Circle() .strokeBorder(lineWidth: 24) .overlay { VStack { Text(currentSpeaker) .font(.title) Text("is speaking") Image(systemName: isRecording ? "mic" : "mic.slash") .font(.title) .padding(.top) .accessibilityLabel(isRecording ? "with transcription" : "without transcription") } .accessibilityElement(children: .combine) .foregroundStyle(theme.accentColor) } .overlay { ForEach(speakers) { speaker in if speaker.isCompleted, let index = speakers.firstIndex(where: { $0.id == speaker.id }) { SpeakerArc(speakerIndex: index, totalSpeakers: speakers.count) .rotation(Angle(degrees: -90)) .stroke(theme.mainColor, lineWidth: 12) } } } .padding(.horizontal) } } #Preview { let speakers = [ScrumTimer.Speaker(name: "Bill", isCompleted: true), ScrumTimer.Speaker(name: "Cathy", isCompleted: false)] MeetingTimerView(speakers: speakers, isRecording: true, theme: .yellow) } // End of MeetingTimerView.swift // ------- Next File ------- // File: MeetingView.swift import SwiftUI import TimerKit import AVFoundation import TranscriptionKit struct MeetingView: View { @Environment(\.modelContext) private var context let scrum: DailyScrum @State var scrumTimer = ScrumTimer() @Binding var errorWrapper: ErrorWrapper? @State var speechRecognizer = SpeechRecognizer() @State private var isRecording = false private let player = AVPlayer.dingPlayer() var body: some View { ZStack { RoundedRectangle(cornerRadius: 16.0) .fill(scrum.theme.mainColor) VStack { MeetingHeaderView(secondsElapsed: scrumTimer.secondsElapsed, secondsRemaining: scrumTimer.secondsRemaining, theme: scrum.theme) MeetingTimerView(speakers: scrumTimer.speakers, isRecording: isRecording, theme: scrum.theme) MeetingFooterView(speakers: scrumTimer.speakers, skipAction: scrumTimer.skipSpeaker) } } .padding() .foregroundColor(scrum.theme.accentColor) .onAppear { startScrum() } .onDisappear { do { try endScrum() } catch { errorWrapper = ErrorWrapper(error: error, guidance: "Meeting time was not recorded. Try again later.") } } .navigationBarTitleDisplayMode(.inline) } private func startScrum() { scrumTimer.reset(lengthInMinutes: scrum.lengthInMinutes, attendeeNames: scrum.attendees.map { $0.name }) scrumTimer.speakerChangedAction = { player.seek(to: .zero) player.play() } speechRecognizer.resetTranscript() speechRecognizer.startTranscribing() isRecording = true scrumTimer.startScrum() } private func endScrum() throws { scrumTimer.stopScrum() speechRecognizer.stopTranscribing() isRecording = false let newHistory = History(attendees: scrum.attendees, transcript: speechRecognizer.transcript) scrum.history.insert(newHistory, at: 0) try context.save() } } #Preview { let scrum = DailyScrum.sampleData[0] MeetingView(scrum: scrum, errorWrapper: .constant(nil)) } // End of MeetingView.swift // ------- Next File ------- // File: NewScrumSheet.swift import SwiftUI struct NewScrumSheet: View { var body: some View { NavigationStack { DetailEditView(scrum: nil) } } } #Preview { NewScrumSheet() } // End of NewScrumSheet.swift // ------- Next File ------- // File: ScrumsView.swift import SwiftUI import SwiftData struct ScrumsView: View { @Query(sort: \DailyScrum.title) private var scrums: [DailyScrum] @State private var isPresentingNewScrumView = false var body: some View { NavigationStack { List(scrums) { scrum in NavigationLink(destination: DetailView(scrum: scrum)) { CardView(scrum: scrum) } .listRowBackground(scrum.theme.mainColor) } .navigationTitle("Daily Scrums") .toolbar { Button(action: { isPresentingNewScrumView = true }) { Image(systemName: "plus") } .accessibilityLabel("New Scrum") } } .sheet(isPresented: $isPresentingNewScrumView) { NewScrumSheet() } } } #Preview(traits: .dailyScrumsSampleData) { ScrumsView() } // End of ScrumsView.swift // ------- Next File ------- // File: SpeakerArc.swift import SwiftUI struct SpeakerArc: Shape { let speakerIndex: Int let totalSpeakers: Int private var degreesPerSpeaker: Double { 360.0 / Double(totalSpeakers) } private var startAngle: Angle { Angle(degrees: degreesPerSpeaker * Double(speakerIndex) + 1.0) } private var endAngle: Angle { Angle(degrees: startAngle.degrees + degreesPerSpeaker - 1.0) } func path(in rect: CGRect) -> Path { let diameter = min(rect.size.width, rect.size.height) - 24.0 let radius = diameter / 2.0 let center = CGPoint(x: rect.midX, y: rect.midY) return Path { path in path.addArc(center: center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: false) } } } // End of SpeakerArc.swift // ------- Next File ------- // File: ThemePicker.swift import SwiftUI import ThemeKit struct ThemePicker: View { @Binding var selection: Theme var body: some View { Picker("Theme", selection: $selection) { ForEach(Theme.allCases) { theme in ThemeView(theme: theme) .tag(theme) } } .pickerStyle(.navigationLink) } } #Preview { @Previewable @State var theme = Theme.periwinkle ThemePicker(selection: $theme) } // End of ThemePicker.swift // ------- Next File ------- // File: ThemeView.swift import SwiftUI import ThemeKit struct ThemeView: View { let theme: Theme var body: some View { Text(theme.name) .padding(4) .frame(maxWidth: .infinity) .background(theme.mainColor) .foregroundColor(theme.accentColor) .clipShape(RoundedRectangle(cornerRadius: 4)) } } #Preview { ThemeView(theme: .buttercup) } // End of ThemeView.swift // ------- Next File ------- // File: TrailingIconLabelStyle.swift import SwiftUI struct TrailingIconLabelStyle: LabelStyle { func makeBody(configuration: Configuration) -> some View { HStack { configuration.title configuration.icon } } } extension LabelStyle where Self == TrailingIconLabelStyle { static var trailingIcon: Self { Self() } } // End of TrailingIconLabelStyle.swift // ------- Next File ------- // File: Attendee.swift import Foundation import SwiftData @Model class Attendee: Identifiable { var id: UUID var name: String var dailyScrum: DailyScrum? init(id: UUID = UUID(), name: String) { self.id = id self.name = name } } // End of Attendee.swift // ------- Next File ------- // File: DailyScrum.swift import Foundation import ThemeKit import SwiftData @Model class DailyScrum: Identifiable { var id: UUID var title: String @Relationship(deleteRule: .cascade, inverse: \Attendee.dailyScrum) var attendees: [Attendee] var lengthInMinutes: Int var lengthInMinutesAsDouble: Double { get { Double(lengthInMinutes) } set { lengthInMinutes = Int(newValue) } } var theme: Theme @Relationship(deleteRule: .cascade, inverse: \History.dailyScrum) var history: [History] = [] init(id: UUID = UUID(), title: String, attendees: [String], lengthInMinutes: Int, theme: Theme) { self.id = id self.title = title self.attendees = attendees.map { Attendee(name: $0) } self.lengthInMinutes = lengthInMinutes self.theme = theme } } // End of DailyScrum.swift // ------- Next File ------- // File: ErrorWrapper.swift import Foundation struct ErrorWrapper: Identifiable { let id: UUID let error: Error let guidance: String init(id: UUID = UUID(), error: Error, guidance: String) { self.id = id self.error = error self.guidance = guidance } } // End of ErrorWrapper.swift // ------- Next File ------- // File: History.swift import Foundation import SwiftData @Model class History: Identifiable { var id: UUID var date: Date var attendees: [Attendee] var dailyScrum: DailyScrum? var transcript: String? init(id: UUID = UUID(), date: Date = Date(), attendees: [Attendee], transcript: String? = nil) { self.id = id self.date = date self.attendees = attendees self.transcript = transcript } } // End of History.swift // ------- Next File ------- // File: PreviewContainer.swift import SwiftData import SwiftUI struct DailyScrumSampleData: PreviewModifier { static func makeSharedContext() async throws -> ModelContainer { let container = try ModelContainer(for: DailyScrum.self, configurations: .init(isStoredInMemoryOnly: true)) DailyScrum.sampleData.forEach { container.mainContext.insert($0) } return container } func body(content: Content, context: ModelContainer) -> some View { content.modelContainer(context) } } extension PreviewTrait where T == Preview.ViewTraits { @MainActor static var dailyScrumsSampleData: Self = .modifier(DailyScrumSampleData()) } // End of PreviewContainer.swift // ------- Next File ------- // File: DailyScrum+SampleData.swift import Foundation import ThemeKit extension DailyScrum { static let sampleData: [DailyScrum] = [ DailyScrum(title: "Design", attendees: ["Cathy", "Daisy", "Simon", "Jonathan"], lengthInMinutes: 10, theme: .yellow), DailyScrum(title: "App Dev", attendees: ["Katie", "Gray", "Euna", "Luis", "Darla"], lengthInMinutes: 5, theme: .orange), DailyScrum(title: "Web Dev", attendees: ["Chella", "Chris", "Christina", "Eden", "Karla", "Lindsey", "Aga", "Chad", "Jenn", "Sarah"], lengthInMinutes: 5, theme: .poppy) ] } // End of DailyScrum+Sample.swift ----- ``` --- ## File Structure Reference from Scrumdinger This is how Apple organizes their folder structure in the Scrumdinger sample app: ```plaintext Scrumdinger.xcodeproj README.md Scrumdinger/ ├── Assets.xcassets/ ├── Models/ │ ├── Attendee.swift │ ├── DailyScrum.swift │ ├── ErrorWrapper.swift │ └── History.swift ├── Preview Content/ │ └── Preview Assets.xcassets/ │ └── PreviewContainer.swift ├── Views/ │ ├── CardView.swift │ ├── DetailView.swift │ ├── DetailEditView.swift │ ├── MeetingView.swift │ ├── MeetingHeaderView.swift │ ├── MeetingFooterView.swift │ ├── MeetingTimerView.swift │ ├── ErrorView.swift │ ├── HistoryView.swift │ ├── ThemePicker.swift │ ├── ThemeView.swift │ ├── NewScrumSheet.swift │ └── ScrumsView.swift ├── Utilities/ │ ├── SpeakerArc.swift │ └── TrailingIconLabelStyle.swift ├── SampleData/ │ └── DailyScrum+SampleData.swift ├── ScrumdingerApp.swift ``` --- ## Simpler iOS App File Structure for Lightweight Screens For minimal layouts, use this simplified folder structure: ```plaintext MyApp/ ├── MyAppApp.swift ├── ContentView.swift ├── Model.swift ├── Views/ │ ├── MyDesignView.swift │ └── Subviews/ │ └── MyComponentView.swift ├── Preview Content/ │ └── Preview Assets.xcassets/ ├── Assets.xcassets/ └── Info.plist ``` --- ## iOS App Screen Design Reference Use the attached iOS app design to guide your component breakdown. Match the layout as closely as possible using clean SwiftUI code and modern design conventions. --- Now begin by outlining your **chain-of-thought reasoning** based on the screenshot. Then write your SwiftUI implementation using the patterns described above. |
If you’ve found certain techniques for prompts that output high-quality Swift code, share them with me on Mastodon! @ronnierocha