From 23e573afc355118ba56f4208eb790608f3276c60 Mon Sep 17 00:00:00 2001 From: haibo Date: Mon, 28 Jul 2025 17:22:38 -0700 Subject: [PATCH 1/2] reuse ProgressOverlay in GenerativeAIUIComponents --- .../ProgressOverlay.swift | 46 +++++++++++++++++++ firebaseai/ImagenScreen/ImagenScreen.swift | 25 ---------- 2 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 firebaseai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/ProgressOverlay.swift diff --git a/firebaseai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/ProgressOverlay.swift b/firebaseai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/ProgressOverlay.swift new file mode 100644 index 000000000..f8eba0820 --- /dev/null +++ b/firebaseai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/ProgressOverlay.swift @@ -0,0 +1,46 @@ +// 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 { + public init() {} + + 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) + + VStack(spacing: 12) { + ProgressView() + .scaleEffect(1.5) + + Text("Loading...") + .font(.subheadline) + .foregroundColor(.secondary) + } + } + } + } +} + +#Preview { + ProgressOverlay() +} diff --git a/firebaseai/ImagenScreen/ImagenScreen.swift b/firebaseai/ImagenScreen/ImagenScreen.swift index f8e7a088a..3bb9d64d5 100644 --- a/firebaseai/ImagenScreen/ImagenScreen.swift +++ b/firebaseai/ImagenScreen/ImagenScreen.swift @@ -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()) } From ec3905d291379f39b302ed7672030e9356bf98a9 Mon Sep 17 00:00:00 2001 From: haibo Date: Mon, 28 Jul 2025 17:34:40 -0700 Subject: [PATCH 2/2] custom loading label in progressoverlay --- .../GenerativeAIUIComponents/ProgressOverlay.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/firebaseai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/ProgressOverlay.swift b/firebaseai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/ProgressOverlay.swift index f8eba0820..f371616aa 100644 --- a/firebaseai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/ProgressOverlay.swift +++ b/firebaseai/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/ProgressOverlay.swift @@ -15,7 +15,11 @@ import SwiftUI public struct ProgressOverlay: View { - public init() {} + let message: String + + public init(message: String = "Loading...") { + self.message = message + } public var body: some View { ZStack { @@ -32,7 +36,7 @@ public struct ProgressOverlay: View { ProgressView() .scaleEffect(1.5) - Text("Loading...") + Text(message) .font(.subheadline) .foregroundColor(.secondary) }