Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Improved Grade Scheduling #531

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
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
283 changes: 281 additions & 2 deletions Campus-iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions Campus-iOS/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ struct CampusApp: App {
let persistenceController = PersistenceController.shared
@State var selectedTab = 0
@State var isLoginSheetPresented = false


@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

init() {
#if !DEBUG
FirebaseApp.configure()
#endif
UITabBar.appearance().isOpaque = true

if #available(iOS 15.0, *) {
let appearance = UITabBarAppearance()
UITabBar.appearance().scrollEdgeAppearance = appearance
Expand Down Expand Up @@ -69,12 +72,12 @@ struct CampusApp: App {
model: model,
service: LecturesService()
), refresh: $model.isUserAuthenticated)
.navigationTitle("Lectures")
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
ProfileToolbar(model: model)
}
.navigationTitle("Lectures")
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
ProfileToolbar(model: model)
}
}
}
.tag(1)
.tabItem {
Expand Down Expand Up @@ -118,7 +121,7 @@ struct CampusApp: App {
view.navigationViewStyle(.stack)
})

NavigationView {
NavigationView {
MapScreenView(vm: MapViewModel(cafeteriaService: CafeteriasService(), studyRoomsService: StudyRoomsService()))
}
.tag(3)
Expand Down
58 changes: 58 additions & 0 deletions Campus-iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// AppDelegate.swift
// Campus-iOS
//
// Created by Anton Wyrowski on 29.11.22.
//

import Foundation
import UIKit
import UserNotifications


class AppDelegate: NSObject, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

UIApplication.shared.registerForRemoteNotifications()
registerForPushNotifications()

return true
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
let token = tokenParts.joined()

Task {
await PushNotifications.shared.registerDeviceToken(token)
}
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
CrashlyticsService.log("Failed to register for remote notifications with error message: \(error.localizedDescription)")
}

func registerForPushNotifications() {
UNUserNotificationCenter.current()
.requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in
print("Notification Permission granted: \(granted)")
}
}

func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
) {
Task {
do {
try await PushNotifications.shared.handleBackgroundNotification(data: userInfo)
completionHandler(.noData)
} catch {
completionHandler(.failed)
}
}
}

}
41 changes: 41 additions & 0 deletions Campus-iOS/Base/Networking/CampusBackend.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// CampusBackend.swift
// Campus-iOS
//
// Created by Anton Wyrowski on 29.11.22.
//

import Foundation
import GRPC
import Logging

struct CampusBackend {

private static let s = CampusBackend()

static let shared = s.client

let client: Api_CampusAsyncClient

private init() {
let group = PlatformSupport.makeEventLoopGroup(loopCount: 1)

var logger = Logger(label: "gRPC", factory: StreamLogHandler.standardOutput(label:))
logger.logLevel = .debug


let channel = ClientConnection
.usingPlatformAppropriateTLS(for: group)
.withBackgroundActivityLogger(logger)
.connect(host: "api-grpc.tum.app", port: 443)

// For local development will be removed after
// backend changes are merged
/* let channel = ClientConnection
.insecure(group: group)
.withBackgroundActivityLogger(logger)
.connect(host: "192.168.178.41", port: 50051) */

client = Api_CampusAsyncClient(channel: channel)
}
}
Loading