Skip to content

[FirebaseAI] Move ProgressOverlay to GenerativeAIUIComponents #1736

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import SwiftUI

public struct ProgressOverlay: View {
let message: String

public init(message: String = "Loading...") {
self.message = message
}

public var body: some View {
ZStack {
Color.black.opacity(0.3)
.ignoresSafeArea()

ZStack {
RoundedRectangle(cornerRadius: 16)
.fill(Material.ultraThinMaterial)
.frame(width: 120, height: 100)
.shadow(radius: 8)
Comment on lines +26 to +33

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The view uses several hardcoded numbers for styling (e.g., 0.3, 16, 120, 100, 8). Extracting these into private static constants will improve readability and make future UI tweaks easier.

private enum Style {
    static let backgroundOpacity: CGFloat = 0.3
    static let cornerRadius: CGFloat = 16
    static let frameWidth: CGFloat = 120
    static let frameHeight: CGFloat = 100
    static let shadowRadius: CGFloat = 8
    static let stackSpacing: CGFloat = 12
    static let progressScale: CGFloat = 1.5
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to extract these styling values into constants, or is it fine to keep them for now?


VStack(spacing: 12) {
ProgressView()
.scaleEffect(1.5)

Text(message)
.font(.subheadline)
.foregroundColor(.secondary)
}
}
}
}
}

#Preview {
ProgressOverlay()
}
25 changes: 0 additions & 25 deletions firebaseai/ImagenScreen/ImagenScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,6 @@ struct ImagenScreen: View {
}
}

struct ProgressOverlay: View {
var body: some View {
ZStack {
Color.black.opacity(0.3)
.ignoresSafeArea()

ZStack {
RoundedRectangle(cornerRadius: 16)
.fill(Material.ultraThinMaterial)
.frame(width: 120, height: 100)
.shadow(radius: 8)

VStack(spacing: 12) {
ProgressView()
.scaleEffect(1.5)

Text("Loading...")
.font(.subheadline)
.foregroundColor(.secondary)
}
}
}
}
}

#Preview {
ImagenScreen(firebaseService: FirebaseAI.firebaseAI())
}