Skip to content

Commit 2f5d9bf

Browse files
committed
checkpoint
1 parent 4823ac2 commit 2f5d9bf

File tree

6 files changed

+524
-356
lines changed

6 files changed

+524
-356
lines changed

Power Editor/Models/Options.swift

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ enum Tool: String,CaseIterable {
2121
class OptionsModel: ObservableObject {
2222
@Published var maintainAspectRatio: Bool = true
2323
@Published var activeTool: Tool = .move
24+
@Published var canvasSize: CGSize = CGSize(width: 1000, height: 1000)
2425
}
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
}

Power Editor/Views/MainView.swift

+11-9
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ let iconSize: CGFloat = 25
1313
struct MainView: View {
1414
@State private var isSidebarVisible: Bool = false
1515
@State private var layers: [Layer] = [
16-
Layer(name: "Blue Layer",position: CGPoint(x:10,y:10), content: .color(.red)),
16+
Layer(name: "Red Layer",
17+
position: CGPoint(x: 10, y: 10),
18+
size: CGSize(width:200,height:200),
19+
content: .color(.red)
20+
),
1721
Layer(
18-
name: "Text Layer",
19-
position: CGPoint(x: UIScreen.main.bounds.width/2-100, y: UIScreen.main.bounds.width/2-50),
20-
size: CGSize(width: 200, height:100),
22+
name: "Text Layer",
23+
position: CGPoint(x: 400, y: 450),
24+
size: CGSize(width: 200, height: 100),
2125
content: .text("💪 Power Editor")
2226
),
2327
Layer(
24-
name: "Red Layer",
25-
position:CGPoint(
26-
x:UIScreen.main.bounds.width-110,
27-
y:UIScreen.main.bounds.width-110
28-
),
28+
name: "Blue Layer",
29+
position: CGPoint(x: 790, y: 790),
30+
size: CGSize(width: 200, height: 200),
2931
content: .color(.blue)
3032
)
3133
]

0 commit comments

Comments
 (0)