Skip to content

Commit

Permalink
Merge branch 'release-4.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
jevonmao committed Dec 25, 2022
2 parents 721fecd + 783d50a commit 18bc2f0
Show file tree
Hide file tree
Showing 18 changed files with 794 additions and 169 deletions.
52 changes: 46 additions & 6 deletions SMHS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
621F5CA3266AAB0F006EBE8F /* CalendarEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621F5CA2266AAB0F006EBE8F /* CalendarEvent.swift */; };
621F5CA5266AAB35006EBE8F /* CalendarManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621F5CA4266AAB35006EBE8F /* CalendarManager.swift */; };
621F5CA7266ACF05006EBE8F /* SelectedDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621F5CA6266ACF05006EBE8F /* SelectedDateView.swift */; };
6225B4D128A1C166008999D3 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = 6225B4D028A1C166008999D3 /* FirebaseDatabase */; };
622C8D7C288CFB98001A94D3 /* Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 622C8D7B288CFB98001A94D3 /* Comparable.swift */; };
622C8D7D288CFB98001A94D3 /* Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 622C8D7B288CFB98001A94D3 /* Comparable.swift */; };
622CC3902851613D003F33D6 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62D1E512263DF778004DBFAD /* WidgetKit.framework */; };
Expand Down Expand Up @@ -148,8 +149,6 @@
629BE8BD2636444400BC49AD /* ScheduleWeek.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629BE8BC2636444400BC49AD /* ScheduleWeek.swift */; };
629BE8BF2636489600BC49AD /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629BE8BE2636489600BC49AD /* Array.swift */; };
629EC8352645D50900E236DC /* TodayViewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629EC8342645D50900E236DC /* TodayViewViewModel.swift */; };
62A11A7B26E6A105007F7241 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 62382B5A26E69FE600BF8918 /* GoogleService-Info.plist */; };
62A11A7C26E6A106007F7241 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 62382B5A26E69FE600BF8918 /* GoogleService-Info.plist */; };
62A11A7F26E6CBDE007F7241 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A11A7E26E6CBDE007F7241 /* Constants.swift */; };
62A11A8926EE9F4A007F7241 /* TeamsJoinBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A11A8826EE9F4A007F7241 /* TeamsJoinBanner.swift */; };
62A11A8E26F99FA4007F7241 /* OnboardingFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A11A8D26F99FA4007F7241 /* OnboardingFeature.swift */; };
Expand Down Expand Up @@ -259,6 +258,13 @@
62FCFFF128161DB200D3E1CA /* Endpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62F43CC7268902380009CD34 /* Endpoint.swift */; };
62FCFFF3281CCF5600D3E1CA /* DeveloperTapGesture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62FCFFF2281CCF5600D3E1CA /* DeveloperTapGesture.swift */; };
62FCFFF4281CCF5600D3E1CA /* DeveloperTapGesture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62FCFFF2281CCF5600D3E1CA /* DeveloperTapGesture.swift */; };
F203BBFB28A1AF960002DAD9 /* BannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F203BBF628A1AF960002DAD9 /* BannerView.swift */; };
F203BBFC28A1AF960002DAD9 /* BannerDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F203BBF728A1AF960002DAD9 /* BannerDetailView.swift */; };
F203BBFD28A1AF960002DAD9 /* BannerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F203BBF828A1AF960002DAD9 /* BannerExtensions.swift */; };
F203BBFE28A1AF960002DAD9 /* BannersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F203BBF928A1AF960002DAD9 /* BannersView.swift */; };
F203BBFF28A1AF960002DAD9 /* Banner.swift in Sources */ = {isa = PBXBuildFile; fileRef = F203BBFA28A1AF960002DAD9 /* Banner.swift */; };
F2297A4A28A56D690032EF99 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = F2297A4928A56D690032EF99 /* FirebaseDatabase */; };
F2297A4C28A56EC90032EF99 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = F2297A4B28A56EC90032EF99 /* GoogleService-Info.plist */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -325,7 +331,6 @@
62328C9526476E42000F26ED /* ProgressRingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressRingView.swift; sourceTree = "<group>"; };
62353A512638894500207C15 /* ScheduleListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleListView.swift; sourceTree = "<group>"; };
62382B5426E6994D00BF8918 /* AnnoucementBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnnoucementBanner.swift; sourceTree = "<group>"; };
62382B5A26E69FE600BF8918 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
623A7F17264EEBF700FF3F28 /* SearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchView.swift; sourceTree = "<group>"; };
623A7F1A264EED2700FF3F28 /* InformationCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InformationCard.swift; sourceTree = "<group>"; };
623A7F22264F595400FF3F28 /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -466,6 +471,12 @@
62F5FCFE26B4876600E821D5 /* LoadingAnimatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingAnimatable.swift; sourceTree = "<group>"; };
62F5FD0026B49A2D00E821D5 /* Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
62FCFFF2281CCF5600D3E1CA /* DeveloperTapGesture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperTapGesture.swift; sourceTree = "<group>"; };
F203BBF628A1AF960002DAD9 /* BannerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BannerView.swift; sourceTree = "<group>"; };
F203BBF728A1AF960002DAD9 /* BannerDetailView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BannerDetailView.swift; sourceTree = "<group>"; };
F203BBF828A1AF960002DAD9 /* BannerExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BannerExtensions.swift; sourceTree = "<group>"; };
F203BBF928A1AF960002DAD9 /* BannersView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BannersView.swift; sourceTree = "<group>"; };
F203BBFA28A1AF960002DAD9 /* Banner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Banner.swift; sourceTree = "<group>"; };
F2297A4B28A56EC90032EF99 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -501,6 +512,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
6225B4D128A1C166008999D3 /* FirebaseDatabase in Frameworks */,
623D596B27024D43001D05F7 /* Kingfisher in Frameworks */,
62382B5926E69FCC00BF8918 /* FirebaseRemoteConfig in Frameworks */,
6261DF2527121E3D009F6234 /* FirebaseMessaging in Frameworks */,
Expand Down Expand Up @@ -797,7 +809,7 @@
isa = PBXGroup;
children = (
6261DF2827122329009F6234 /* SMHSSchedule (iOS).entitlements */,
62382B5A26E69FE600BF8918 /* GoogleService-Info.plist */,
F2297A4B28A56EC90032EF99 /* GoogleService-Info.plist */,
6263E83026BCEA69009EC880 /* ElegantCalendar.xcassets */,
62D1E55B263F17E9004DBFAD /* Settings.bundle */,
62C9E887263BD2AC00CCA5C5 /* Assets */,
Expand Down Expand Up @@ -867,6 +879,7 @@
626A2293260037C400903C39 /* Views */ = {
isa = PBXGroup;
children = (
F203BBF528A1AF960002DAD9 /* Banners */,
6287EA6226548BA7007B41CB /* Components */,
629BE8B8263642BC00BC49AD /* ScheduleListView.swift */,
626A2294260037D000903C39 /* TodayView */,
Expand Down Expand Up @@ -1204,6 +1217,18 @@
path = JSON;
sourceTree = "<group>";
};
F203BBF528A1AF960002DAD9 /* Banners */ = {
isa = PBXGroup;
children = (
F203BBF628A1AF960002DAD9 /* BannerView.swift */,
F203BBF728A1AF960002DAD9 /* BannerDetailView.swift */,
F203BBF828A1AF960002DAD9 /* BannerExtensions.swift */,
F203BBF928A1AF960002DAD9 /* BannersView.swift */,
F203BBFA28A1AF960002DAD9 /* Banner.swift */,
);
path = Banners;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -1294,6 +1319,7 @@
6261DF20271124DF009F6234 /* FirebaseCrashlytics */,
6261DF2427121E3D009F6234 /* FirebaseMessaging */,
62CCF9D4288F1C0400FA85C7 /* SwiftUIX */,
6225B4D028A1C166008999D3 /* FirebaseDatabase */,
);
productName = "SMHS Schedule";
productReference = 626A2265260035F100903C39 /* SMHS.app */;
Expand Down Expand Up @@ -1430,7 +1456,6 @@
62D1E55C263F17E9004DBFAD /* Settings.bundle in Resources */,
626183AB2637168E001C4AD4 /* Assets.xcassets in Resources */,
6263E83126BCEA69009EC880 /* ElegantCalendar.xcassets in Resources */,
62A11A7C26E6A106007F7241 /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -1441,9 +1466,9 @@
626A2270260035F200903C39 /* Preview Assets.xcassets in Resources */,
6260B0FD2832D85F007DBD3E /* JsonResponses in Resources */,
62D1E55D263F17E9004DBFAD /* Settings.bundle in Resources */,
62A11A7B26E6A105007F7241 /* GoogleService-Info.plist in Resources */,
6263E83226BCEA69009EC880 /* ElegantCalendar.xcassets in Resources */,
626A226D260035F200903C39 /* Assets.xcassets in Resources */,
F2297A4C28A56EC90032EF99 /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1647,6 +1672,7 @@
623D595726FAF3D9001D05F7 /* GradesDetailViewModel.swift in Sources */,
62B227DA265D9A430023A7E6 /* FeaturesStatementView.swift in Sources */,
6201D9E72810C89B00EBC375 /* GradesRubric.swift in Sources */,
F203BBFC28A1AF960002DAD9 /* BannerDetailView.swift in Sources */,
62626390264DC5E3004146CE /* DeveloperSettingsView.swift in Sources */,
624F79F4264FA13500B93C63 /* NewsSelectionButtons.swift in Sources */,
62FCFFF028161DB100D3E1CA /* Endpoint.swift in Sources */,
Expand Down Expand Up @@ -1698,14 +1724,17 @@
624F7A002651A4E600B93C63 /* HapticsManager.swift in Sources */,
6287EA6A26558081007B41CB /* CustomScheduleView.swift in Sources */,
62583EA5286D214700349962 /* Match.swift in Sources */,
F203BBFF28A1AF960002DAD9 /* Banner.swift in Sources */,
62D3211C2649F2BD00C99C42 /* NewsDetailedView.swift in Sources */,
62D32122264A4C6700C99C42 /* ClassPeriod.swift in Sources */,
626183EF263718FC001C4AD4 /* UserDefaultWrapper.swift in Sources */,
62CCF9D7288F1FAB00FA85C7 /* TestSwiftUIX.swift in Sources */,
621F5C8D2669FBA0006EBE8F /* SchoolMapDirections.swift in Sources */,
621385EF265C60D500F4806C /* InformationCardItem.swift in Sources */,
62583EA4286D214700349962 /* Utils.swift in Sources */,
F203BBFB28A1AF960002DAD9 /* BannerView.swift in Sources */,
62626393264DCFA0004146CE /* PeriodEditSettingsView.swift in Sources */,
F203BBFE28A1AF960002DAD9 /* BannersView.swift in Sources */,
623A7F18264EEBF700FF3F28 /* SearchView.swift in Sources */,
62328C9826476ED9000F26ED /* ProgressRingView.swift in Sources */,
6211915F27EEF144008BD312 /* Calendar.swift in Sources */,
Expand All @@ -1715,6 +1744,7 @@
62A11A8926EE9F4A007F7241 /* TeamsJoinBanner.swift in Sources */,
624F79EF264F87BE00B93C63 /* SearchResultView.swift in Sources */,
621F5C842669F2D5006EBE8F /* TodayHeroView.swift in Sources */,
F203BBFD28A1AF960002DAD9 /* BannerExtensions.swift in Sources */,
62B227C2265CC1D20023A7E6 /* WhyStatementView.swift in Sources */,
626A229C260039AB00903C39 /* ScheduleDetailView.swift in Sources */,
626183DF263718CA001C4AD4 /* ScheduleDay.swift in Sources */,
Expand Down Expand Up @@ -2426,6 +2456,11 @@
package = 621F5C8E266A9479006EBE8F /* XCRemoteSwiftPackageReference "ElegantCalendar" */;
productName = ElegantCalendar;
};
6225B4D028A1C166008999D3 /* FirebaseDatabase */ = {
isa = XCSwiftPackageProductDependency;
package = 624B06DA26D3521B001C2EAE /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseDatabase;
};
62382B5826E69FCC00BF8918 /* FirebaseRemoteConfig */ = {
isa = XCSwiftPackageProductDependency;
package = 624B06DA26D3521B001C2EAE /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
Expand Down Expand Up @@ -2511,6 +2546,11 @@
package = 62E3BF04264270AE00E1FF88 /* XCRemoteSwiftPackageReference "swiftui-visual-effects" */;
productName = SwiftUIVisualEffects;
};
F2297A4928A56D690032EF99 /* FirebaseDatabase */ = {
isa = XCSwiftPackageProductDependency;
package = 624B06DA26D3521B001C2EAE /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseDatabase;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 626A225D260035F100903C39 /* Project object */;
Expand Down
84 changes: 84 additions & 0 deletions Sources/SMHS (iOS)/Views/Banners/Banner.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// Banner.swift
// SMHS (iOS)
//
// Created by Lampeh on 7.08.2022.
//

import Foundation
import SwiftUI
import FirebaseDatabase
import Alamofire

struct Banner: Identifiable, Codable, Equatable {
let headline: String
let title: String
let footnote: String
let externalLink: URL
let image: URL
let isActive: Bool
let paragraphs: [String]

let requirements: [Requirement]

enum Requirement: String, Codable {
case name, phoneNumber, email, school, grade
}

let email: String

let id = UUID()

static func fetch() async throws -> [Banner] {
let db = Database.database().reference()

let snapshot = try await db.getData()

let data = try JSONSerialization.data(withJSONObject: snapshot.value as Any)

let banners = try JSONDecoder().decode([Banner].self, from: data)

return banners
}

func submit(name: String, phoneNumber: String, email: String, school: String, grade: String) async throws {
let endpoint = Endpoint.submit(name: name, phoneNumber: phoneNumber, email: email, school: school, grade: grade, sendEmail: self.email)

AF.request(endpoint.request)
.response(completionHandler: { result in
let res = result.response

let ok = (200...300).contains(res?.statusCode ?? 0)

if ok {
print("Successfully sent email.")

Task {
let db = Database.database().reference()
guard let data = try? await db.getData() else { return }

let index = Array(data.children).firstIndex { child in
let snapshot = child as! DataSnapshot

let dict = snapshot.value as! [String: Any]

return dict["title"] as? String == title
}

guard let index = index else { return }

let ref = db.child("\(index)/submissions").childByAutoId()

try await ref.setValue([
"name": name,
"phone_number": phoneNumber,
"email": email,
"school": school,
"grade": grade
])
}
}
})
.resume()
}
}
Loading

0 comments on commit 18bc2f0

Please sign in to comment.