mirror of
https://github.com/NinjaCheetah/RIT-Dining.git
synced 2025-10-19 06:36:18 -04:00
It seems reasonable to ask for some money here or there, since my Apple Developer Program membership was quite expensive just for this app
40 lines
1.2 KiB
Swift
40 lines
1.2 KiB
Swift
//
|
|
// SharedComponents.swift
|
|
// RIT Dining
|
|
//
|
|
// Created by Campbell on 9/8/25.
|
|
//
|
|
|
|
import Foundation
|
|
import SafariServices
|
|
import SwiftUI
|
|
|
|
// Gross disgusting UIKit code :(
|
|
// There isn't a direct way to use integrated Safari from SwiftUI, except maybe in iOS 26? I'm not targeting that though so I must fall
|
|
// back on UIKit stuff.
|
|
struct SafariView: UIViewControllerRepresentable {
|
|
let url: URL
|
|
|
|
func makeUIViewController(context: Context) -> SFSafariViewController {
|
|
SFSafariViewController(url: url)
|
|
}
|
|
|
|
func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {}
|
|
}
|
|
|
|
func getAPIFriendlyDateString(date: Date) -> String {
|
|
let formatter = DateFormatter()
|
|
formatter.calendar = Calendar(identifier: .iso8601)
|
|
formatter.locale = Locale(identifier: "en_US_POSIX")
|
|
formatter.timeZone = TimeZone.current
|
|
formatter.dateFormat = "yyyy-MM-dd"
|
|
return formatter.string(from: date)
|
|
}
|
|
|
|
|
|
// Custom view extension that just applies modifiers in a block to the object it's applied to. Mostly useful for splitting up conditional
|
|
// modifiers that should only be applied for certain OS versions.
|
|
extension View {
|
|
func apply<V: View>(@ViewBuilder _ block: (Self) -> V) -> V { block(self) }
|
|
}
|