From 04ebaf073d7a878c7bbd7f3f5c28d508dfec27e5 Mon Sep 17 00:00:00 2001 From: christinaqiu3 Date: Fri, 26 Jan 2024 18:24:13 -0500 Subject: [PATCH 1/4] ui base added --- PennMobile.xcodeproj/project.pbxproj | 12 ++ .../General/SwiftUI Views/Dialogue.swift | 31 +++++ .../DialogueViewController.swift | 66 +++++++++++ .../SwiftUI Views/DialogueViewController.xib | 108 ++++++++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 PennMobile/General/SwiftUI Views/Dialogue.swift create mode 100644 PennMobile/General/SwiftUI Views/DialogueViewController.swift create mode 100644 PennMobile/General/SwiftUI Views/DialogueViewController.xib diff --git a/PennMobile.xcodeproj/project.pbxproj b/PennMobile.xcodeproj/project.pbxproj index 245cf25b..bb0c7622 100644 --- a/PennMobile.xcodeproj/project.pbxproj +++ b/PennMobile.xcodeproj/project.pbxproj @@ -299,6 +299,9 @@ CF29A1781FB788820067D946 /* PageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF29A1681FB7887E0067D946 /* PageCell.swift */; }; CF7FCA761FAFCD9E0052F0A9 /* RoomSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF7FCA751FAFCD9E0052F0A9 /* RoomSelectionViewController.swift */; }; E735C9422AF81498000F7376 /* DiningSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E735C9412AF81498000F7376 /* DiningSettingsView.swift */; }; + E7DA7CDD2B64619E00CA2A60 /* Dialogue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7DA7CDC2B64619E00CA2A60 /* Dialogue.swift */; }; + E7DA7CE02B64684500CA2A60 /* DialogueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7DA7CDE2B64684500CA2A60 /* DialogueViewController.swift */; }; + E7DA7CE12B64684500CA2A60 /* DialogueViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E7DA7CDF2B64684500CA2A60 /* DialogueViewController.xib */; }; EF23946423EF4117005BA55F /* GSRGroupInviteCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF23946323EF4117005BA55F /* GSRGroupInviteCell.swift */; }; EF30077223EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF30077123EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift */; }; EF30077423EE139F006C9CF0 /* HomeGroupInvitesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF30077323EE139F006C9CF0 /* HomeGroupInvitesCell.swift */; }; @@ -708,6 +711,9 @@ CF29A1681FB7887E0067D946 /* PageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageCell.swift; sourceTree = ""; }; CF7FCA751FAFCD9E0052F0A9 /* RoomSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSelectionViewController.swift; sourceTree = ""; }; E735C9412AF81498000F7376 /* DiningSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiningSettingsView.swift; sourceTree = ""; }; + E7DA7CDC2B64619E00CA2A60 /* Dialogue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dialogue.swift; sourceTree = ""; }; + E7DA7CDE2B64684500CA2A60 /* DialogueViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogueViewController.swift; sourceTree = ""; }; + E7DA7CDF2B64684500CA2A60 /* DialogueViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DialogueViewController.xib; sourceTree = ""; }; EF23946323EF4117005BA55F /* GSRGroupInviteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GSRGroupInviteCell.swift; sourceTree = ""; }; EF30077123EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeGroupInvitesCellItem.swift; sourceTree = ""; }; EF30077323EE139F006C9CF0 /* HomeGroupInvitesCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeGroupInvitesCell.swift; sourceTree = ""; }; @@ -1417,6 +1423,9 @@ 6CAE434E253370B200BD0200 /* FadingScrollView.swift */, 6CAE434F253370B200BD0200 /* AlertModifier.swift */, 6C84D9E426293E680039C57F /* UIKit Views.swift */, + E7DA7CDC2B64619E00CA2A60 /* Dialogue.swift */, + E7DA7CDE2B64684500CA2A60 /* DialogueViewController.swift */, + E7DA7CDF2B64684500CA2A60 /* DialogueViewController.xib */, ); path = "SwiftUI Views"; sourceTree = ""; @@ -2212,6 +2221,7 @@ 6CC88D7327B1BF51006896F6 /* mock_menu.json in Resources */, 6CC88D6D27B1BF51006896F6 /* sample-dining-venue.json in Resources */, 6C3F194227A32C29007BCB4F /* GoogleService-Info.plist in Resources */, + E7DA7CE12B64684500CA2A60 /* DialogueViewController.xib in Resources */, 2190FD2F1EBBC8BA00EC683C /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2370,6 +2380,7 @@ F206DDB528DE5BF0008F572F /* PreferencesViewController.swift in Sources */, 21A6B6D222162702003A357D /* GSRReservation.swift in Sources */, 2189C0A22027CE4100771C1F /* GSRRoom.swift in Sources */, + E7DA7CDD2B64619E00CA2A60 /* Dialogue.swift in Sources */, 2138E1F82252AFB500E4055A /* GSRLocationCell.swift in Sources */, B654BAF21F802A050038B9D5 /* LaundryCell.swift in Sources */, 2138D55322597FCB00D67CA2 /* GSRLocationsController.swift in Sources */, @@ -2487,6 +2498,7 @@ 21E6A109224BDFEB00DC457A /* HomeViewController + Delegates.swift in Sources */, 217A7832204D2C7E004F1227 /* HomeCellItem.swift in Sources */, 6ECB4C362ACB10D500F7379A /* HomeDiningCell.swift in Sources */, + E7DA7CE02B64684500CA2A60 /* DialogueViewController.swift in Sources */, 2189C08D2027CE2600771C1F /* RoomCell.swift in Sources */, 6C6FE1C927B9B8CB0093FD13 /* MoreCell.swift in Sources */, 6CC88D6627B1BF51006896F6 /* VariableStepLineGraphView.swift in Sources */, diff --git a/PennMobile/General/SwiftUI Views/Dialogue.swift b/PennMobile/General/SwiftUI Views/Dialogue.swift new file mode 100644 index 00000000..95574095 --- /dev/null +++ b/PennMobile/General/SwiftUI Views/Dialogue.swift @@ -0,0 +1,31 @@ +// +// Dialogue.swift +// PennMobile +// +// Created by Christina Qiu on 1/26/24. +// Copyright © 2024 PennLabs. All rights reserved. +// + +#if canImport(SwiftUI) +import SwiftUI +import PennMobileShared +#endif + +struct Dialogue: View { + var body: some View { + GeometryReader { geo in + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + .frame(width: geo.size.width-48, height: 70, alignment: .center) + .font(Font(UIFont.primaryInformationFont)) + .foregroundColor(.black) + .background(.red) + Button(<#PrimitiveButtonStyleConfiguration#>) + .buttonBorderShape(.roundedRectangle) + }.frame(alignment: .center) + + } +} + +#Preview { + Dialogue() +} diff --git a/PennMobile/General/SwiftUI Views/DialogueViewController.swift b/PennMobile/General/SwiftUI Views/DialogueViewController.swift new file mode 100644 index 00000000..4b1ce149 --- /dev/null +++ b/PennMobile/General/SwiftUI Views/DialogueViewController.swift @@ -0,0 +1,66 @@ +// +// DialogueViewController.swift +// PennMobile +// +// Created by Christina Qiu on 1/26/24. +// Copyright © 2024 PennLabs. All rights reserved. +// + +import UIKit + +class DialogueViewController: UIViewController { + @IBOutlet weak var backView: UIView! + @IBOutlet weak var contentView: UIView! + @IBAction func Button1(_ sender: UIButton) { + hide() + } + @IBAction func Button2(_ sender: UIButton) { + } + + init(){ + super.init(nibName: "DialogueViewController", bundle: nil) + self.modalPresentationStyle = .overFullScreen + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func viewDidLoad() { + super.viewDidLoad() + + configView() + } + + + func configView(){ + self.view.backgroundColor = .clear + self.backView.background = .black.withAlphaComponent(.6) + self.backView.alpha = 0 + self.contentView.alpha = 0 + self.contentView.layer.cornerRadius=10 + } + + func appear(sender: UIViewController) { + sender.present(self, animated:false) { + self.show() + } + } + + private func show() { + UIView.animate(withDuration: 1, delay: 0.1) { + self.backView.alpha = 1 + self.contentView.alpha = 1 + } + } + + func hide() { + UIView.animate(withDuration: 1, delay: 0.0, options: .curveEaseOut) { + self.backView.alpha = 0 + self.contentView.alpha = 0 + } completion: { _ in + self.dismiss(animated: false) + self.removeFromParent() + } + } +} diff --git a/PennMobile/General/SwiftUI Views/DialogueViewController.xib b/PennMobile/General/SwiftUI Views/DialogueViewController.xib new file mode 100644 index 00000000..ef1bcc1d --- /dev/null +++ b/PennMobile/General/SwiftUI Views/DialogueViewController.xib @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 421a22f4890d308b554326b34b9c79bb323811dc Mon Sep 17 00:00:00 2001 From: christinaqiu3 Date: Fri, 26 Jan 2024 18:25:03 -0500 Subject: [PATCH 2/4] fixed errors --- PennMobile/General/SwiftUI Views/DialogueViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PennMobile/General/SwiftUI Views/DialogueViewController.swift b/PennMobile/General/SwiftUI Views/DialogueViewController.swift index 4b1ce149..eb6bce54 100644 --- a/PennMobile/General/SwiftUI Views/DialogueViewController.swift +++ b/PennMobile/General/SwiftUI Views/DialogueViewController.swift @@ -35,7 +35,7 @@ class DialogueViewController: UIViewController { func configView(){ self.view.backgroundColor = .clear - self.backView.background = .black.withAlphaComponent(.6) + self.backView.backgroundColor = .black.withAlphaComponent(0.6) self.backView.alpha = 0 self.contentView.alpha = 0 self.contentView.layer.cornerRadius=10 From 2a036826a4f2054073b20d170afffb773ca7cebf Mon Sep 17 00:00:00 2001 From: christinaqiu3 Date: Sun, 28 Jan 2024 13:30:59 -0500 Subject: [PATCH 3/4] Dialogue component finished --- PennMobile.xcodeproj/project.pbxproj | 8 +- .../SwiftUI Views/CustomPopupView.swift | 109 ++++++++++++++++++ .../General/SwiftUI Views/Dialogue.swift | 31 ----- .../Setup + Navigation/PennMobile.swift | 6 +- 4 files changed, 118 insertions(+), 36 deletions(-) create mode 100644 PennMobile/General/SwiftUI Views/CustomPopupView.swift delete mode 100644 PennMobile/General/SwiftUI Views/Dialogue.swift diff --git a/PennMobile.xcodeproj/project.pbxproj b/PennMobile.xcodeproj/project.pbxproj index bb0c7622..535d231a 100644 --- a/PennMobile.xcodeproj/project.pbxproj +++ b/PennMobile.xcodeproj/project.pbxproj @@ -299,7 +299,7 @@ CF29A1781FB788820067D946 /* PageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF29A1681FB7887E0067D946 /* PageCell.swift */; }; CF7FCA761FAFCD9E0052F0A9 /* RoomSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF7FCA751FAFCD9E0052F0A9 /* RoomSelectionViewController.swift */; }; E735C9422AF81498000F7376 /* DiningSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E735C9412AF81498000F7376 /* DiningSettingsView.swift */; }; - E7DA7CDD2B64619E00CA2A60 /* Dialogue.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7DA7CDC2B64619E00CA2A60 /* Dialogue.swift */; }; + E7DA7CDD2B64619E00CA2A60 /* CustomPopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7DA7CDC2B64619E00CA2A60 /* CustomPopupView.swift */; }; E7DA7CE02B64684500CA2A60 /* DialogueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7DA7CDE2B64684500CA2A60 /* DialogueViewController.swift */; }; E7DA7CE12B64684500CA2A60 /* DialogueViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E7DA7CDF2B64684500CA2A60 /* DialogueViewController.xib */; }; EF23946423EF4117005BA55F /* GSRGroupInviteCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF23946323EF4117005BA55F /* GSRGroupInviteCell.swift */; }; @@ -711,7 +711,7 @@ CF29A1681FB7887E0067D946 /* PageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageCell.swift; sourceTree = ""; }; CF7FCA751FAFCD9E0052F0A9 /* RoomSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSelectionViewController.swift; sourceTree = ""; }; E735C9412AF81498000F7376 /* DiningSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiningSettingsView.swift; sourceTree = ""; }; - E7DA7CDC2B64619E00CA2A60 /* Dialogue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dialogue.swift; sourceTree = ""; }; + E7DA7CDC2B64619E00CA2A60 /* CustomPopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPopupView.swift; sourceTree = ""; }; E7DA7CDE2B64684500CA2A60 /* DialogueViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogueViewController.swift; sourceTree = ""; }; E7DA7CDF2B64684500CA2A60 /* DialogueViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DialogueViewController.xib; sourceTree = ""; }; EF23946323EF4117005BA55F /* GSRGroupInviteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GSRGroupInviteCell.swift; sourceTree = ""; }; @@ -1423,7 +1423,7 @@ 6CAE434E253370B200BD0200 /* FadingScrollView.swift */, 6CAE434F253370B200BD0200 /* AlertModifier.swift */, 6C84D9E426293E680039C57F /* UIKit Views.swift */, - E7DA7CDC2B64619E00CA2A60 /* Dialogue.swift */, + E7DA7CDC2B64619E00CA2A60 /* CustomPopupView.swift */, E7DA7CDE2B64684500CA2A60 /* DialogueViewController.swift */, E7DA7CDF2B64684500CA2A60 /* DialogueViewController.xib */, ); @@ -2380,7 +2380,7 @@ F206DDB528DE5BF0008F572F /* PreferencesViewController.swift in Sources */, 21A6B6D222162702003A357D /* GSRReservation.swift in Sources */, 2189C0A22027CE4100771C1F /* GSRRoom.swift in Sources */, - E7DA7CDD2B64619E00CA2A60 /* Dialogue.swift in Sources */, + E7DA7CDD2B64619E00CA2A60 /* CustomPopupView.swift in Sources */, 2138E1F82252AFB500E4055A /* GSRLocationCell.swift in Sources */, B654BAF21F802A050038B9D5 /* LaundryCell.swift in Sources */, 2138D55322597FCB00D67CA2 /* GSRLocationsController.swift in Sources */, diff --git a/PennMobile/General/SwiftUI Views/CustomPopupView.swift b/PennMobile/General/SwiftUI Views/CustomPopupView.swift new file mode 100644 index 00000000..91d9bbb5 --- /dev/null +++ b/PennMobile/General/SwiftUI Views/CustomPopupView.swift @@ -0,0 +1,109 @@ +// +// CustomPopupView.swift +// PennMobile +// +// Created by Christina Qiu on 1/26/24. +// Copyright © 2024 PennLabs. All rights reserved. +// + +#if canImport(SwiftUI) +import SwiftUI +import PennMobileShared +#endif + +// Global state for the popup +class PopupManager: ObservableObject { + @Published var isShown: Bool = false + @Published var image: Image = Image(systemName: "star") + @Published var title: String = "" + @Published var message: String = "" + // Add more properties as needed for buttons and actions +} +// Popup View +struct CustomPopupView: View { + @Binding var isShown: Bool + var image: Image + var title: String + var message: String + var confirmAction: () -> Void + var body: some View { + ZStack { + // Scrim + Color(hex: 0x5F5F64) + .opacity(0.2) + .edgesIgnoringSafeArea(.all) + + VStack(spacing: 18) { + // Optional image + image + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 50, height: 50) + .foregroundColor(.blue) + Text(title).font(.headline) + Text(message) + .font(.subheadline) + .multilineTextAlignment(.leading) + Button(action: confirmAction) { + Text("Confirm") + .foregroundColor(.white) + .padding() + .frame(maxWidth: 300) + .background(RoundedRectangle(cornerRadius: 50).fill(Color.blue)) + } + .padding(.horizontal, 24) + Button("Cancel") { + isShown = false + } + } + .frame(maxWidth: 280) + .padding(.horizontal, 24) + .padding(.vertical, 32) + .background(Color.white) + .cornerRadius(12) + .shadow(color: Color.black.opacity(0.15), radius: 20, x: 0, y: 3) + } + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) + + } +} +// Usage in ContentView +struct ContentView: View { + @EnvironmentObject var popupManager: PopupManager + var body: some View { + ZStack { + // Your app’s content goes here + if popupManager.isShown { + CustomPopupView(isShown: $popupManager.isShown, + image: popupManager.image, + title: popupManager.title, + message: popupManager.message, + confirmAction: { + // Define the confirm action here + popupManager.isShown = false + }) + .transition(.scale) + } + } + } +} + +extension Color { + init(hex: Int, alpha: Double = 1.0) { + self.init( + red: Double((hex >> 16) & 0xFF) / 255.0, + green: Double((hex >> 8) & 0xFF) / 255.0, + blue: Double(hex & 0xFF) / 255.0, + opacity: alpha + ) + } +} + +#Preview { + + CustomPopupView(isShown: .constant(true), + image: Image(systemName: "star"), + title: "Sample Title", + message: "This is a sample message. Text text text text text text.", + confirmAction: {}) +} diff --git a/PennMobile/General/SwiftUI Views/Dialogue.swift b/PennMobile/General/SwiftUI Views/Dialogue.swift deleted file mode 100644 index 95574095..00000000 --- a/PennMobile/General/SwiftUI Views/Dialogue.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// Dialogue.swift -// PennMobile -// -// Created by Christina Qiu on 1/26/24. -// Copyright © 2024 PennLabs. All rights reserved. -// - -#if canImport(SwiftUI) -import SwiftUI -import PennMobileShared -#endif - -struct Dialogue: View { - var body: some View { - GeometryReader { geo in - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) - .frame(width: geo.size.width-48, height: 70, alignment: .center) - .font(Font(UIFont.primaryInformationFont)) - .foregroundColor(.black) - .background(.red) - Button(<#PrimitiveButtonStyleConfiguration#>) - .buttonBorderShape(.roundedRectangle) - }.frame(alignment: .center) - - } -} - -#Preview { - Dialogue() -} diff --git a/PennMobile/Setup + Navigation/PennMobile.swift b/PennMobile/Setup + Navigation/PennMobile.swift index 3d34c32d..9c5af8b7 100644 --- a/PennMobile/Setup + Navigation/PennMobile.swift +++ b/PennMobile/Setup + Navigation/PennMobile.swift @@ -14,7 +14,8 @@ struct PennMobile: App { @UIApplicationDelegateAdaptor var delegate: AppDelegate @ObservedObject var authManager = AuthManager() @ObservedObject var homeViewModel = StandardHomeViewModel() - + @StateObject var popupManager = PopupManager() + #if DEBUG @ObservedObject var mockHomeViewModel = MockHomeViewModel() #endif @@ -53,6 +54,9 @@ struct PennMobile: App { .environmentObject(mockHomeViewModel) #endif .accentColor(Color("navigation")) + + ContentView() + .environmentObject(popupManager) } .onChange(of: authManager.state.isLoggedIn) { _ in homeViewModel.clearData() From a7b1bf7eb174735b3df9aaa277a806150b64ce93 Mon Sep 17 00:00:00 2001 From: christinaqiu3 Date: Sun, 18 Feb 2024 13:57:00 -0500 Subject: [PATCH 4/4] made customizable button/image --- PennMobile.xcodeproj/project.pbxproj | 8 -- .../SwiftUI Views/CustomPopupView.swift | 130 ++++++++---------- .../DialogueViewController.swift | 66 --------- .../SwiftUI Views/DialogueViewController.xib | 108 --------------- .../Setup + Navigation/PennMobile.swift | 4 - PennMobile/Setup + Navigation/RootView.swift | 15 ++ 6 files changed, 73 insertions(+), 258 deletions(-) delete mode 100644 PennMobile/General/SwiftUI Views/DialogueViewController.swift delete mode 100644 PennMobile/General/SwiftUI Views/DialogueViewController.xib diff --git a/PennMobile.xcodeproj/project.pbxproj b/PennMobile.xcodeproj/project.pbxproj index 535d231a..9a7574c9 100644 --- a/PennMobile.xcodeproj/project.pbxproj +++ b/PennMobile.xcodeproj/project.pbxproj @@ -300,8 +300,6 @@ CF7FCA761FAFCD9E0052F0A9 /* RoomSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF7FCA751FAFCD9E0052F0A9 /* RoomSelectionViewController.swift */; }; E735C9422AF81498000F7376 /* DiningSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E735C9412AF81498000F7376 /* DiningSettingsView.swift */; }; E7DA7CDD2B64619E00CA2A60 /* CustomPopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7DA7CDC2B64619E00CA2A60 /* CustomPopupView.swift */; }; - E7DA7CE02B64684500CA2A60 /* DialogueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7DA7CDE2B64684500CA2A60 /* DialogueViewController.swift */; }; - E7DA7CE12B64684500CA2A60 /* DialogueViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E7DA7CDF2B64684500CA2A60 /* DialogueViewController.xib */; }; EF23946423EF4117005BA55F /* GSRGroupInviteCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF23946323EF4117005BA55F /* GSRGroupInviteCell.swift */; }; EF30077223EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF30077123EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift */; }; EF30077423EE139F006C9CF0 /* HomeGroupInvitesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF30077323EE139F006C9CF0 /* HomeGroupInvitesCell.swift */; }; @@ -712,8 +710,6 @@ CF7FCA751FAFCD9E0052F0A9 /* RoomSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSelectionViewController.swift; sourceTree = ""; }; E735C9412AF81498000F7376 /* DiningSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiningSettingsView.swift; sourceTree = ""; }; E7DA7CDC2B64619E00CA2A60 /* CustomPopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPopupView.swift; sourceTree = ""; }; - E7DA7CDE2B64684500CA2A60 /* DialogueViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogueViewController.swift; sourceTree = ""; }; - E7DA7CDF2B64684500CA2A60 /* DialogueViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DialogueViewController.xib; sourceTree = ""; }; EF23946323EF4117005BA55F /* GSRGroupInviteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GSRGroupInviteCell.swift; sourceTree = ""; }; EF30077123EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeGroupInvitesCellItem.swift; sourceTree = ""; }; EF30077323EE139F006C9CF0 /* HomeGroupInvitesCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeGroupInvitesCell.swift; sourceTree = ""; }; @@ -1424,8 +1420,6 @@ 6CAE434F253370B200BD0200 /* AlertModifier.swift */, 6C84D9E426293E680039C57F /* UIKit Views.swift */, E7DA7CDC2B64619E00CA2A60 /* CustomPopupView.swift */, - E7DA7CDE2B64684500CA2A60 /* DialogueViewController.swift */, - E7DA7CDF2B64684500CA2A60 /* DialogueViewController.xib */, ); path = "SwiftUI Views"; sourceTree = ""; @@ -2221,7 +2215,6 @@ 6CC88D7327B1BF51006896F6 /* mock_menu.json in Resources */, 6CC88D6D27B1BF51006896F6 /* sample-dining-venue.json in Resources */, 6C3F194227A32C29007BCB4F /* GoogleService-Info.plist in Resources */, - E7DA7CE12B64684500CA2A60 /* DialogueViewController.xib in Resources */, 2190FD2F1EBBC8BA00EC683C /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2498,7 +2491,6 @@ 21E6A109224BDFEB00DC457A /* HomeViewController + Delegates.swift in Sources */, 217A7832204D2C7E004F1227 /* HomeCellItem.swift in Sources */, 6ECB4C362ACB10D500F7379A /* HomeDiningCell.swift in Sources */, - E7DA7CE02B64684500CA2A60 /* DialogueViewController.swift in Sources */, 2189C08D2027CE2600771C1F /* RoomCell.swift in Sources */, 6C6FE1C927B9B8CB0093FD13 /* MoreCell.swift in Sources */, 6CC88D6627B1BF51006896F6 /* VariableStepLineGraphView.swift in Sources */, diff --git a/PennMobile/General/SwiftUI Views/CustomPopupView.swift b/PennMobile/General/SwiftUI Views/CustomPopupView.swift index 91d9bbb5..966a8922 100644 --- a/PennMobile/General/SwiftUI Views/CustomPopupView.swift +++ b/PennMobile/General/SwiftUI Views/CustomPopupView.swift @@ -6,10 +6,8 @@ // Copyright © 2024 PennLabs. All rights reserved. // -#if canImport(SwiftUI) import SwiftUI import PennMobileShared -#endif // Global state for the popup class PopupManager: ObservableObject { @@ -17,93 +15,81 @@ class PopupManager: ObservableObject { @Published var image: Image = Image(systemName: "star") @Published var title: String = "" @Published var message: String = "" + @Published var button1: String = "" + @Published var button2: String = "" + @Published var action1: () -> Void = {} + @Published var action2: () -> Void = {} // Add more properties as needed for buttons and actions } // Popup View struct CustomPopupView: View { @Binding var isShown: Bool - var image: Image + var image: Image? var title: String var message: String - var confirmAction: () -> Void + var button1: String? + var button2: String? + var action1: () -> Void + var action2: () -> Void var body: some View { - ZStack { - // Scrim - Color(hex: 0x5F5F64) - .opacity(0.2) - .edgesIgnoringSafeArea(.all) - - VStack(spacing: 18) { - // Optional image - image - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 50, height: 50) - .foregroundColor(.blue) - Text(title).font(.headline) - Text(message) - .font(.subheadline) - .multilineTextAlignment(.leading) - Button(action: confirmAction) { - Text("Confirm") - .foregroundColor(.white) - .padding() - .frame(maxWidth: 300) - .background(RoundedRectangle(cornerRadius: 50).fill(Color.blue)) + if isShown { + ZStack { + // Scrim + Color.black + .opacity(0.2) + .edgesIgnoringSafeArea(.all) + + VStack(spacing: 18) { + // Optional image + image? + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 50, height: 50) + .foregroundColor(Color("navigation")) + Text(title).font(.headline) + Text(message) + .font(.subheadline) + .multilineTextAlignment(.leading) + Button(action: action1) { + Text(button1 != nil ? button1! : "Confirm") + .foregroundColor(.white) + .padding() + .frame(maxWidth: 300) + .background(RoundedRectangle(cornerRadius: 50).fill(Color("navigation"))) + } + .padding(.horizontal, 24) + if button2 != nil { + Button(action: action2) { + Text(button2!) + } + } } + .frame(maxWidth: 280) .padding(.horizontal, 24) - Button("Cancel") { - isShown = false - } + .padding(.vertical, 32) + .background(Color("uiCardBackground")) + .cornerRadius(12) + .shadow(color: Color.black.opacity(0.15), radius: 20, x: 0, y: 3) } - .frame(maxWidth: 280) - .padding(.horizontal, 24) - .padding(.vertical, 32) - .background(Color.white) - .cornerRadius(12) - .shadow(color: Color.black.opacity(0.15), radius: 20, x: 0, y: 3) + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) } - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) } } -// Usage in ContentView -struct ContentView: View { - @EnvironmentObject var popupManager: PopupManager - var body: some View { - ZStack { - // Your app’s content goes here - if popupManager.isShown { - CustomPopupView(isShown: $popupManager.isShown, - image: popupManager.image, - title: popupManager.title, - message: popupManager.message, - confirmAction: { - // Define the confirm action here - popupManager.isShown = false - }) - .transition(.scale) - } - } - } -} -extension Color { - init(hex: Int, alpha: Double = 1.0) { - self.init( - red: Double((hex >> 16) & 0xFF) / 255.0, - green: Double((hex >> 8) & 0xFF) / 255.0, - blue: Double(hex & 0xFF) / 255.0, - opacity: alpha +struct CustomPopupView_Previews: PreviewProvider, View { + @State private var isShown = true + + var body: some View { + CustomPopupView(isShown: $isShown, title: "Sample title", message: "This is a sample message. Text text text text text text.", + button1: "See My Listings", + button2: "Cancel", + action1: {isShown = false}, + action2: {isShown = false} ) } -} - -#Preview { - CustomPopupView(isShown: .constant(true), - image: Image(systemName: "star"), - title: "Sample Title", - message: "This is a sample message. Text text text text text text.", - confirmAction: {}) + static var previews: some View { + Self() + } } diff --git a/PennMobile/General/SwiftUI Views/DialogueViewController.swift b/PennMobile/General/SwiftUI Views/DialogueViewController.swift deleted file mode 100644 index eb6bce54..00000000 --- a/PennMobile/General/SwiftUI Views/DialogueViewController.swift +++ /dev/null @@ -1,66 +0,0 @@ -// -// DialogueViewController.swift -// PennMobile -// -// Created by Christina Qiu on 1/26/24. -// Copyright © 2024 PennLabs. All rights reserved. -// - -import UIKit - -class DialogueViewController: UIViewController { - @IBOutlet weak var backView: UIView! - @IBOutlet weak var contentView: UIView! - @IBAction func Button1(_ sender: UIButton) { - hide() - } - @IBAction func Button2(_ sender: UIButton) { - } - - init(){ - super.init(nibName: "DialogueViewController", bundle: nil) - self.modalPresentationStyle = .overFullScreen - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - override func viewDidLoad() { - super.viewDidLoad() - - configView() - } - - - func configView(){ - self.view.backgroundColor = .clear - self.backView.backgroundColor = .black.withAlphaComponent(0.6) - self.backView.alpha = 0 - self.contentView.alpha = 0 - self.contentView.layer.cornerRadius=10 - } - - func appear(sender: UIViewController) { - sender.present(self, animated:false) { - self.show() - } - } - - private func show() { - UIView.animate(withDuration: 1, delay: 0.1) { - self.backView.alpha = 1 - self.contentView.alpha = 1 - } - } - - func hide() { - UIView.animate(withDuration: 1, delay: 0.0, options: .curveEaseOut) { - self.backView.alpha = 0 - self.contentView.alpha = 0 - } completion: { _ in - self.dismiss(animated: false) - self.removeFromParent() - } - } -} diff --git a/PennMobile/General/SwiftUI Views/DialogueViewController.xib b/PennMobile/General/SwiftUI Views/DialogueViewController.xib deleted file mode 100644 index ef1bcc1d..00000000 --- a/PennMobile/General/SwiftUI Views/DialogueViewController.xib +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PennMobile/Setup + Navigation/PennMobile.swift b/PennMobile/Setup + Navigation/PennMobile.swift index 9c5af8b7..6da7230b 100644 --- a/PennMobile/Setup + Navigation/PennMobile.swift +++ b/PennMobile/Setup + Navigation/PennMobile.swift @@ -14,7 +14,6 @@ struct PennMobile: App { @UIApplicationDelegateAdaptor var delegate: AppDelegate @ObservedObject var authManager = AuthManager() @ObservedObject var homeViewModel = StandardHomeViewModel() - @StateObject var popupManager = PopupManager() #if DEBUG @ObservedObject var mockHomeViewModel = MockHomeViewModel() @@ -54,9 +53,6 @@ struct PennMobile: App { .environmentObject(mockHomeViewModel) #endif .accentColor(Color("navigation")) - - ContentView() - .environmentObject(popupManager) } .onChange(of: authManager.state.isLoggedIn) { _ in homeViewModel.clearData() diff --git a/PennMobile/Setup + Navigation/RootView.swift b/PennMobile/Setup + Navigation/RootView.swift index b0dc54d5..f119c325 100644 --- a/PennMobile/Setup + Navigation/RootView.swift +++ b/PennMobile/Setup + Navigation/RootView.swift @@ -11,6 +11,7 @@ import SwiftUI struct RootView: View { @EnvironmentObject var authManager: AuthManager @State var toast: ToastConfiguration? + @StateObject var popupManager = PopupManager() var isOnLogoutScreen: Bool { switch authManager.state { @@ -45,6 +46,20 @@ struct RootView: View { toast = configuration } } + .overlay { + if popupManager.isShown { + CustomPopupView(isShown: $popupManager.isShown, + image: popupManager.image, + title: popupManager.title, + message: popupManager.message, + confirmAction: { + // Define the confirm action here + popupManager.isShown = false + }) + .transition(.scale) + } + } + .environmentObject(popupManager) .task(id: toast?.id) { if toast != nil { try? await Task.sleep(for: .seconds(5))