-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Refactor the UI layout of ImagenScreen to solve the navigation flicker #1719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ struct ImagenScreen: View { | |
var focusedField: FocusedField? | ||
|
||
var body: some View { | ||
ZStack { | ||
ScrollView { | ||
VStack { | ||
InputField("Enter a prompt to generate an image", text: $viewModel.userInput) { | ||
Image( | ||
|
@@ -44,28 +44,24 @@ struct ImagenScreen: View { | |
.focused($focusedField, equals: .message) | ||
.onSubmit { sendOrStop() } | ||
|
||
ScrollView { | ||
let spacing: CGFloat = 10 | ||
LazyVGrid(columns: [ | ||
GridItem(.fixed(UIScreen.main.bounds.width / 2 - spacing), spacing: spacing), | ||
GridItem(.fixed(UIScreen.main.bounds.width / 2 - spacing), spacing: spacing), | ||
], spacing: spacing) { | ||
ForEach(viewModel.images, id: \.self) { image in | ||
Image(uiImage: image) | ||
.resizable() | ||
.aspectRatio(contentMode: .fill) | ||
.frame(width: UIScreen.main.bounds.width / 2 - spacing, | ||
height: UIScreen.main.bounds.width / 2 - spacing) | ||
.cornerRadius(12) | ||
.clipped() | ||
} | ||
let spacing: CGFloat = 10 | ||
LazyVGrid(columns: [ | ||
GridItem(.fixed(UIScreen.main.bounds.width / 2 - spacing), spacing: spacing), | ||
GridItem(.fixed(UIScreen.main.bounds.width / 2 - spacing), spacing: spacing), | ||
], spacing: spacing) { | ||
ForEach(viewModel.images, id: \.self) { image in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’ve tried to generate images multiple times in |
||
Image(uiImage: image) | ||
.resizable() | ||
.aspectRatio(contentMode: .fill) | ||
.frame(width: UIScreen.main.bounds.width / 2 - spacing, | ||
height: UIScreen.main.bounds.width / 2 - spacing) | ||
YoungHypo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.cornerRadius(12) | ||
.clipped() | ||
} | ||
.padding(.horizontal, spacing) | ||
} | ||
.padding(.horizontal, spacing) | ||
} | ||
if viewModel.inProgress { | ||
ProgressOverlay() | ||
} | ||
.overlay(viewModel.inProgress ? ProgressOverlay() : nil) | ||
} | ||
.navigationTitle("Imagen example") | ||
.onAppear { | ||
|
Uh oh!
There was an error while loading. Please reload this page.