Skip to content

Commit

Permalink
Merge pull request #506 from pennlabs/Subletting-Dialogue
Browse files Browse the repository at this point in the history
Subletting dialogue completed "custom popup view"
  • Loading branch information
JHawk0224 authored Feb 23, 2024
2 parents 802b9b3 + a7b1bf7 commit 0640a24
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 1 deletion.
4 changes: 4 additions & 0 deletions PennMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +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 /* CustomPopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7DA7CDC2B64619E00CA2A60 /* CustomPopupView.swift */; };
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 */; };
Expand Down Expand Up @@ -708,6 +709,7 @@
CF29A1681FB7887E0067D946 /* PageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageCell.swift; sourceTree = "<group>"; };
CF7FCA751FAFCD9E0052F0A9 /* RoomSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSelectionViewController.swift; sourceTree = "<group>"; };
E735C9412AF81498000F7376 /* DiningSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiningSettingsView.swift; sourceTree = "<group>"; };
E7DA7CDC2B64619E00CA2A60 /* CustomPopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPopupView.swift; sourceTree = "<group>"; };
EF23946323EF4117005BA55F /* GSRGroupInviteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GSRGroupInviteCell.swift; sourceTree = "<group>"; };
EF30077123EE1380006C9CF0 /* HomeGroupInvitesCellItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeGroupInvitesCellItem.swift; sourceTree = "<group>"; };
EF30077323EE139F006C9CF0 /* HomeGroupInvitesCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeGroupInvitesCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1417,6 +1419,7 @@
6CAE434E253370B200BD0200 /* FadingScrollView.swift */,
6CAE434F253370B200BD0200 /* AlertModifier.swift */,
6C84D9E426293E680039C57F /* UIKit Views.swift */,
E7DA7CDC2B64619E00CA2A60 /* CustomPopupView.swift */,
);
path = "SwiftUI Views";
sourceTree = "<group>";
Expand Down Expand Up @@ -2370,6 +2373,7 @@
F206DDB528DE5BF0008F572F /* PreferencesViewController.swift in Sources */,
21A6B6D222162702003A357D /* GSRReservation.swift in Sources */,
2189C0A22027CE4100771C1F /* GSRRoom.swift in Sources */,
E7DA7CDD2B64619E00CA2A60 /* CustomPopupView.swift in Sources */,
2138E1F82252AFB500E4055A /* GSRLocationCell.swift in Sources */,
B654BAF21F802A050038B9D5 /* LaundryCell.swift in Sources */,
2138D55322597FCB00D67CA2 /* GSRLocationsController.swift in Sources */,
Expand Down
95 changes: 95 additions & 0 deletions PennMobile/General/SwiftUI Views/CustomPopupView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//
// CustomPopupView.swift
// PennMobile
//
// Created by Christina Qiu on 1/26/24.
// Copyright © 2024 PennLabs. All rights reserved.
//

import SwiftUI
import PennMobileShared

// 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 = ""
@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 title: String
var message: String
var button1: String?
var button2: String?
var action1: () -> Void
var action2: () -> Void
var body: some View {
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)
.padding(.vertical, 32)
.background(Color("uiCardBackground"))
.cornerRadius(12)
.shadow(color: Color.black.opacity(0.15), radius: 20, x: 0, y: 3)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
}

}
}

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}
)
}

static var previews: some View {
Self()
}
}
2 changes: 1 addition & 1 deletion PennMobile/Setup + Navigation/PennMobile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct PennMobile: App {
@UIApplicationDelegateAdaptor var delegate: AppDelegate
@ObservedObject var authManager = AuthManager()
@ObservedObject var homeViewModel = StandardHomeViewModel()

#if DEBUG
@ObservedObject var mockHomeViewModel = MockHomeViewModel()
#endif
Expand Down
15 changes: 15 additions & 0 deletions PennMobile/Setup + Navigation/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -45,6 +46,20 @@ struct RootView: View {
toast = configuration
}
}
.overlay {

Check failure on line 49 in PennMobile/Setup + Navigation/RootView.swift

View workflow job for this annotation

GitHub Actions / build

type '() -> ()' cannot conform to 'ShapeStyle'
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))
Expand Down

0 comments on commit 0640a24

Please sign in to comment.