Skip to content

Commit 29389e6

Browse files
committed
Update ContentView.swift
1 parent e569dee commit 29389e6

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

openai-async-image-swiftui-example/ContentView.swift

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,34 @@ import SwiftUI
1111
struct ContentView: View {
1212

1313
@State var text: String = "Sun"
14-
1514
@State var imageText: String = "Sun"
1615

17-
var customImageTpl : some View{
18-
OpenAIAsyncImage(prompt: $imageText, size: .dpi1024){ state in
19-
switch state{
20-
case .loaded(let image) :
21-
image
22-
.resizable()
23-
.scaledToFill()
24-
case .loadError(let error) : Text(error.localizedDescription)
25-
case .loading : ProgressView()
16+
var customImageTpl: some View {
17+
OpenAIAsyncImage(prompt: $imageText, size: .dpi1024) { state in
18+
switch state {
19+
case .loaded(let image):
20+
image
21+
.resizable()
22+
.scaledToFill()
23+
case .loadError(let error):
24+
Text(error.localizedDescription)
25+
.padding()
26+
case .loading:
27+
ProgressView()
2628
}
2729
}
2830
}
2931

30-
var defaultImageTpl: some View{
32+
var defaultImageTpl: some View {
3133
OpenAIAsyncImage(prompt: .constant("Sun"))
32-
.frame(width: 125, height: 125)
33-
.padding(.top, 75)
34-
.padding(.trailing, 20)
34+
.frame(width: 125, height: 125)
35+
.padding(.top, 75)
36+
.padding(.trailing, 20)
3537
}
3638

3739
var body: some View {
3840
VStack {
39-
HStack{
41+
HStack {
4042
Spacer()
4143
defaultImageTpl
4244
}
@@ -53,20 +55,15 @@ struct ContentView: View {
5355
}
5456
.background(customImageTpl)
5557
.ignoresSafeArea()
56-
5758
}
5859
}
5960

60-
6161
fileprivate struct RoundedTextFieldStyle: TextFieldStyle {
6262
func _body(configuration: TextField<Self._Label>) -> some View {
6363
configuration
6464
.padding(.vertical)
6565
.padding(.horizontal, 24)
66-
.background(
67-
.ultraThinMaterial
68-
)
66+
.background(.ultraThinMaterial)
6967
.clipShape(Capsule(style: .continuous))
7068
}
7169
}
72-

0 commit comments

Comments
 (0)