|
| 1 | +import SwiftUI |
| 2 | + |
| 3 | +struct ExportOptionsView: View { |
| 4 | + @Environment(\.dismiss) var dismiss |
| 5 | + @ObservedObject var options: OptionsModel |
| 6 | + |
| 7 | + var body: some View { |
| 8 | + NavigationView { |
| 9 | + Form { |
| 10 | + Section(header: Text("Canvas Size")) { |
| 11 | + HStack { |
| 12 | + Text("Width:") |
| 13 | + TextField("Width", text: Binding( |
| 14 | + get: { String(Int(options.canvasSize.width)) }, |
| 15 | + set: { if let val = Double($0) { options.canvasSize.width = val }} |
| 16 | + )) |
| 17 | + .keyboardType(.numberPad) |
| 18 | + } |
| 19 | + |
| 20 | + HStack { |
| 21 | + Text("Height:") |
| 22 | + TextField("Height", text: Binding( |
| 23 | + get: { String(Int(options.canvasSize.height)) }, |
| 24 | + set: { if let val = Double($0) { options.canvasSize.height = val }} |
| 25 | + )) |
| 26 | + .keyboardType(.numberPad) |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + Section(header: Text("Common Dimensions")) { |
| 31 | + ScrollView(.horizontal, showsIndicators: false) { |
| 32 | + HStack(spacing: 12) { |
| 33 | + ForEach([ |
| 34 | + (1080, 1080), // Square |
| 35 | + (1080, 1920), // Story |
| 36 | + (1200, 630), // Facebook |
| 37 | + (1280, 720), // HD |
| 38 | + (1920, 1080) // Full HD |
| 39 | + ], id: \.0) { width, height in |
| 40 | + Button(action: { |
| 41 | + options.canvasSize.width = Double(width) |
| 42 | + options.canvasSize.height = Double(height) |
| 43 | + }) { |
| 44 | + VStack { |
| 45 | + Text("\(width)×\(height)") |
| 46 | + .font(.caption) |
| 47 | + Text(width == height ? "Square" : |
| 48 | + width == 1080 && height == 1920 ? "Story" : |
| 49 | + width == 1200 ? "Facebook" : |
| 50 | + width == 1280 ? "HD" : "Full HD") |
| 51 | + .font(.caption2) |
| 52 | + } |
| 53 | + .padding(8) |
| 54 | + .background(Color.blue.opacity(0.1)) |
| 55 | + .cornerRadius(8) |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | + .padding(.vertical, 4) |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + .navigationTitle("Canvas Settings") |
| 64 | + .navigationBarItems(trailing: Button("Done") { dismiss() }) |
| 65 | + } |
| 66 | + } |
| 67 | +} |
0 commit comments