Skip to content

Commit

Permalink
Merge pull request #568 from pennlabs/concurrency/shared-widget
Browse files Browse the repository at this point in the history
Convert PennMobileShared to Swift 6
  • Loading branch information
anli5005 authored Nov 12, 2024
2 parents 6344b3b + 4b31767 commit d4d1a41
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 64 deletions.
4 changes: 2 additions & 2 deletions PennMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2979,7 +2979,7 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -3024,7 +3024,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
2 changes: 1 addition & 1 deletion PennMobileShared/Courses/ScheduleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public struct ScheduleView: View {
self.showColors = showColors
}

public struct HourLabel: OptionSet {
public struct HourLabel: OptionSet, Sendable {
public var rawValue: UInt8
public init(rawValue: UInt8) {
self.rawValue = rawValue
Expand Down
2 changes: 1 addition & 1 deletion PennMobileShared/Dining/DiningAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import SwiftyJSON
import Foundation

public class DiningAPI {
public final class DiningAPI: Sendable {
public static let defaultVenueIds: [Int] = [593, 636, 1442, 639]

public static let instance = DiningAPI()
Expand Down
2 changes: 1 addition & 1 deletion PennMobileShared/Dining/Models/DiningBalance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public struct DiningBalance: Codable {
public struct DiningBalance: Codable, Sendable {
public static let directory = "diningBalance.json"

public let date: String
Expand Down
2 changes: 1 addition & 1 deletion PennMobileShared/Fitness/FitnessAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import SwiftyJSON

public class FitnessAPI {
public final class FitnessAPI: Sendable {

public static let instance = FitnessAPI()

Expand Down
4 changes: 2 additions & 2 deletions PennMobileShared/Fitness/FitnessModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public struct FitnessRoom: Codable, Equatable, Identifiable {
public struct FitnessRoom: Codable, Equatable, Identifiable, Sendable {
public let id: Int
public let name: String
public let image_url: URL?
Expand All @@ -20,7 +20,7 @@ public struct FitnessRoom: Codable, Equatable, Identifiable {
public var data: FitnessRoomData?
}

public struct FitnessRoomData: Codable, Equatable {
public struct FitnessRoomData: Codable, Equatable, Sendable {
public let name: String
public let start: String
public let end: String
Expand Down
86 changes: 43 additions & 43 deletions PennMobileShared/General/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,54 +115,54 @@ public extension Color {
static let labelQuaternary = Color("labelQuaternary")

// MARK: - Primary Palette
static var baseDarkBlue = Color("baseDarkBlue")
static let baseDarkBlue = Color("baseDarkBlue")
static let baseLabsBlue = Color("baseLabsBlue")

// MARK: - Neutral Palette
static var grey1 = Color("grey1")
static var grey2 = Color("grey2")
static var grey3 = Color("grey3")
static var grey4 = Color("grey4")
static var grey5 = Color("grey5")
static var grey6 = Color("grey6")
static var grey7 = Color("grey7")
static let grey1 = Color("grey1")
static let grey2 = Color("grey2")
static let grey3 = Color("grey3")
static let grey4 = Color("grey4")
static let grey5 = Color("grey5")
static let grey6 = Color("grey6")
static let grey7 = Color("grey7")

// MARK: - Secondary Palette
static var baseBlue = Color("baseBlue")
static var baseGreen = Color("baseGreen")
static var baseOrange = Color("baseOrange")
static var basePurple = Color("basePurple")
static var baseRed = Color("baseRed")
static var baseYellow = Color("baseYellow")
static let baseBlue = Color("baseBlue")
static let baseGreen = Color("baseGreen")
static let baseOrange = Color("baseOrange")
static let basePurple = Color("basePurple")
static let baseRed = Color("baseRed")
static let baseYellow = Color("baseYellow")

// MARK: - Extended Palette
static var blueLight = Color("blueLight")
static var blueLighter = Color("blueLighter")
static var blueDark = Color("blueDark")
static var blueDarker = Color("blueDarker")

static var greenLight = Color("greenLight")
static var greenLighter = Color("greenLighter")
static var greenDark = Color("greenDark")
static var greenDarker = Color("greenDarker")

static var orangeLight = Color("orangeLight")
static var orangeLighter = Color("orangeLighter")
static var orangeDark = Color("orangeDark")
static var orangeDarker = Color("orangeDarker")

static var purpleLight = Color("purpleLight")
static var purpleLighter = Color("purpleLighter")
static var purpleDark = Color("purpleDark")
static var purpleDarker = Color("purpleDarker")

static var redLight = Color("redLight")
static var redLighter = Color("redLighter")
static var redDark = Color("redDark")
static var redDarker = Color("redDarker")

static var yellowLight = Color("yellowLight")
static var yellowLighter = Color("yellowLighter")
static var yellowDark = Color("yellowDark")
static var yellowDarker = Color("yellowDarker")
static let blueLight = Color("blueLight")
static let blueLighter = Color("blueLighter")
static let blueDark = Color("blueDark")
static let blueDarker = Color("blueDarker")

static let greenLight = Color("greenLight")
static let greenLighter = Color("greenLighter")
static let greenDark = Color("greenDark")
static let greenDarker = Color("greenDarker")

static let orangeLight = Color("orangeLight")
static let orangeLighter = Color("orangeLighter")
static let orangeDark = Color("orangeDark")
static let orangeDarker = Color("orangeDarker")

static let purpleLight = Color("purpleLight")
static let purpleLighter = Color("purpleLighter")
static let purpleDark = Color("purpleDark")
static let purpleDarker = Color("purpleDarker")

static let redLight = Color("redLight")
static let redLighter = Color("redLighter")
static let redDark = Color("redDark")
static let redDarker = Color("redDarker")

static let yellowLight = Color("yellowLight")
static let yellowLighter = Color("yellowLighter")
static let yellowDark = Color("yellowDark")
static let yellowDarker = Color("yellowDarker")
}
2 changes: 1 addition & 1 deletion PennMobileShared/General/Day.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public struct Day: Hashable, Codable, Comparable {
public struct Day: Hashable, Codable, Comparable, Sendable {
public var year: Int
public var month: Int
public var day: Int
Expand Down
8 changes: 2 additions & 6 deletions PennMobileShared/General/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,6 @@ public extension MutableCollection where Index == Int {
}

public extension Optional {
func nullUnwrap() -> Any {
return self == nil ? "null" : self!
}

/// Unwraps an optional and throws an error if it is nil.
///
/// https://www.avanderlee.com/swift/unwrap-or-throw/
Expand All @@ -466,9 +462,9 @@ public extension UILabel {
}
}

public extension Sequence {
public extension Sequence where Element: Sendable {
/// Maps an array to an array of transformed values, fetched asynchronously in parallel.
func asyncMap<T>(_ transform: @escaping (Element) async throws -> T) async rethrows -> [T] {
func asyncMap<T: Sendable>(_ transform: @escaping @Sendable (Element) async throws -> T) async rethrows -> [T] {
try await withThrowingTaskGroup(of: T.self) { group in
forEach { element in
group.addTask {
Expand Down
2 changes: 1 addition & 1 deletion PennMobileShared/General/KeychainAccessible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public class KeychainAccessible {
public final class KeychainAccessible: Sendable {

public static let instance = KeychainAccessible()

Expand Down
10 changes: 5 additions & 5 deletions PennMobileShared/Subletting/SublettingModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import SwiftUI
/// `SubletData` contains the properties that are set by the user when creating a listing,
/// and `Sublet` contains the remainder.
@dynamicMemberLookup
public struct Sublet: Identifiable, Codable, Hashable {
public struct Sublet: Identifiable, Codable, Hashable, Sendable {
public let subletID: Int
public var data: SubletData
public var subletter: Int
Expand Down Expand Up @@ -139,7 +139,7 @@ public struct SubletDraft: Identifiable, Codable, Hashable {
}
}

public struct SubletData: Codable {
public struct SubletData: Codable, Sendable {
public var amenities: [String]
public var title: String
public var address: String?
Expand Down Expand Up @@ -227,13 +227,13 @@ public extension SubletData {
}
}

public struct SubletImage: Identifiable, Codable, Hashable {
public struct SubletImage: Identifiable, Codable, Hashable, Sendable {
public let id: Int
public let imageUrl: String
}

@dynamicMemberLookup
public struct SubletOffer: Identifiable, Codable, Hashable {
public struct SubletOffer: Identifiable, Codable, Hashable, Sendable {
public let id: Int
public let createdDate: Date
public let user: Int
Expand Down Expand Up @@ -289,7 +289,7 @@ public struct SubletOffer: Identifiable, Codable, Hashable {
}
}

public struct SubletOfferData: Codable {
public struct SubletOfferData: Codable, Sendable {
public var email: String
public var phoneNumber: String
public var message: String?
Expand Down

0 comments on commit d4d1a41

Please sign in to comment.