Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
root = true

[*.swift]
indent_style = space
charset = utf-8
indent_style = tab
indent_size = 2
tab_width = 2
end_of_line = crlf
Expand Down
8 changes: 4 additions & 4 deletions CriticalMapsKit/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.2

import PackageDescription

Expand Down Expand Up @@ -209,7 +209,8 @@ let package = Package(
.swiftUIHelpers
],
exclude: ["README.md"],
resources: [.process("Resources")]
resources: [.process("Resources")],
swiftSettings: [.swiftLanguageMode(.v5)]
),
.target(
name: "SwiftUIHelpers",
Expand Down Expand Up @@ -334,8 +335,7 @@ package.targets.append(contentsOf: [
.testHelper,
.tca,
.product(name: "MastodonKit", package: "MastodonKit")
],
resources: [.process("_Resources/")]
]
)
])

Expand Down
4 changes: 2 additions & 2 deletions CriticalMapsKit/Sources/ApiClient/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation

/// A Client to dispatch network calls
@DependencyClient
public struct APIClient {
public struct APIClient: Sendable {
/// Dispatches a Request and returns its data
/// - Parameter request: Request to Dispatch
/// - Returns: The response data of the request
Expand All @@ -25,7 +25,7 @@ extension APIClient: DependencyKey {
}

extension APIClient: TestDependencyKey {
public static var testValue: APIClient = Self()
public static let testValue: APIClient = Self()
public static let previewValue: APIClient = Self(
send: { _ in (Data(), HTTPURLResponse()) }
)
Expand Down
2 changes: 1 addition & 1 deletion CriticalMapsKit/Sources/ApiClient/APIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SharedModels

/// A Service to send and fetch locations and chat messages from the Critical Maps API
@DependencyClient
public struct APIService {
public struct APIService: Sendable {
public var getRiders: @Sendable () async throws -> [Rider]
public var postRiderLocation: @Sendable (SendLocationPostBody) async throws -> ApiResponse
public var getChatMessages: @Sendable () async throws -> [ChatMessage]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation

/// A client to dispatch network request to URLSession
@DependencyClient
public struct NetworkDispatcher {
public struct NetworkDispatcher: Sendable {
var dispatch: @Sendable (URLRequest) async throws -> (Data, URLResponse)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import SharedModels

public struct SendLocationPostBody: Encodable {
public struct SendLocationPostBody: Encodable, Sendable {
public init(
device: String,
location: Location? = nil
Expand Down
8 changes: 4 additions & 4 deletions CriticalMapsKit/Sources/AppFeature/AppFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import UIApplicationClient
import UserDefaultsClient

@Reducer
public struct AppFeature { // swiftlint:disable:this type_body_length
public struct AppFeature: Sendable { // swiftlint:disable:this type_body_length
public init() {}

@Reducer
public enum Destination {
public enum Destination: Sendable {
case social(SocialFeature)
case settings(SettingsFeature)
case alert(AlertState<Alert>)
Expand Down Expand Up @@ -481,7 +481,7 @@ public struct AppFeature { // swiftlint:disable:this type_body_length

// MARK: - Helper

extension AppFeature.Destination.State: Equatable {}
extension AppFeature.Destination.State: Equatable, Sendable {}

extension SharedModels.Location {
/// Creates a Location object from an optional ComposableCoreLocation.Location
Expand Down Expand Up @@ -514,7 +514,7 @@ extension SharedModels.Coordinate {

private extension Logger {
/// Using your bundle identifier is a great way to ensure a unique identifier.
private static var subsystem = "AppFeature"
private static let subsystem = "AppFeature"

/// Logs the view cycles like a view that appeared.
static let reducer = Logger(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import ComposableArchitecture
import Foundation

@Reducer
public struct RequestTimer {
public init(timerInterval: Int = 60) {
self.timerInterval = .seconds(timerInterval)
}

let timerInterval: RunLoop.SchedulerTimeType.Stride
public struct RequestTimer: Sendable {
public init() {}

// MARK: State

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import SharedModels
import Sharing

public struct ObservationModeIntent: AppIntent {
public static var title = LocalizedStringResource(
public static let title = LocalizedStringResource(
"appIntent.observationMode.title",
defaultValue: "Toggle Observation Mode",
bundle: .module
)
public static var description = IntentDescription(
public static let description = IntentDescription(
LocalizedStringResource(
"appIntent.observationMode.description",
defaultValue: "Enable or disable observation mode in CriticalMaps",
Expand Down
8 changes: 4 additions & 4 deletions CriticalMapsKit/Sources/ChatFeature/ChatFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SharedModels
import UserDefaultsClient

@Reducer
public struct ChatFeature {
public struct ChatFeature: Sendable {
public init() {}

var md5Uuid: String {
Expand All @@ -22,7 +22,7 @@ public struct ChatFeature {
// MARK: State

@ObservableState
public struct State: Equatable {
public struct State: Equatable, Sendable {
public var chatMessages: ContentState<[ChatMessage]>
public var chatInputState: ChatInput.State
@Presents public var alert: AlertState<Action.Alert>?
Expand Down Expand Up @@ -53,7 +53,7 @@ public struct ChatFeature {
case chatInput(ChatInput.Action)
case alert(PresentationAction<Alert>)

public enum Alert {
public enum Alert: Sendable {
case chat
}
}
Expand Down Expand Up @@ -159,7 +159,7 @@ public struct ChatFeature {

private extension Logger {
/// Using your bundle identifier is a great way to ensure a unique identifier.
private static var subsystem = "ChatFeature"
private static let subsystem = "ChatFeature"

/// Logs the view cycles like a view that appeared.
static let reducer = Logger(
Expand Down
4 changes: 1 addition & 3 deletions CriticalMapsKit/Sources/ChatFeature/ChatFeatureView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ private struct ChatEmptyStateView: View {
emptyState: .init(
icon: Asset.chatEmpty.image,
text: L10n.Chat.emptyMessageTitle,
message: .init(
string: L10n.Chat.noChatActivity
)
message: AttributedString(L10n.Chat.noChatActivity)
)
)
}
Expand Down
4 changes: 2 additions & 2 deletions CriticalMapsKit/Sources/ChatFeature/ChatInputFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import Foundation
import UIKit

@Reducer
public struct ChatInput {
public struct ChatInput: Sendable {
public init() {}

// MARK: State

@ObservableState
public struct State: Equatable {
public struct State: Equatable, Sendable {
public var isEditing = false
public var message = ""
public var isSending = false
Expand Down
12 changes: 3 additions & 9 deletions CriticalMapsKit/Sources/ChatFeature/ChatInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,17 @@ private struct OverlayView: View {

// MARK: - Implementation Details

public struct ContentSizeThatFitsKey: PreferenceKey {
@MainActor
public struct ContentSizeThatFitsKey: @MainActor PreferenceKey {
public static var defaultValue: CGSize = .zero

public static func reduce(value: inout CGSize, nextValue: () -> CGSize) {
value = nextValue()
}
}

struct TextAttributesKey: EnvironmentKey {
static var defaultValue: TextAttributes = .init()
}

extension EnvironmentValues {
var textAttributes: TextAttributes {
get { self[TextAttributesKey.self] }
set { self[TextAttributesKey.self] = newValue }
}
@Entry var textAttributes = TextAttributes()
}

struct TextAttributesModifier: ViewModifier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation
import UIKit

@DependencyClient
public struct FeedbackGeneratorClient {
public struct FeedbackGeneratorClient: Sendable {
public var prepare: @Sendable () async -> Void
public var selectionChanged: @Sendable () async -> Void
}
Expand Down
4 changes: 2 additions & 2 deletions CriticalMapsKit/Sources/GuideFeature/Guide.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import L10n
import Styleguide
import UIKit.UIImage

public struct Guide: Hashable, Identifiable {
public struct Guide: Hashable, Identifiable, Sendable {
public let rule: Rule
public var id: String { rule.rawValue }

Expand All @@ -13,7 +13,7 @@ public struct Guide: Hashable, Identifiable {
}

public extension Guide {
enum Rule: String, CaseIterable {
enum Rule: String, CaseIterable, Sendable {
case brake
case contraflow
case gently
Expand Down
2 changes: 1 addition & 1 deletion CriticalMapsKit/Sources/Helpers/ContentState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import Styleguide

/// Wrapper type to represent the state of a loadable object. Typically from a network request
public enum ContentState<T: Hashable>: Equatable {
public enum ContentState<T: Hashable & Sendable>: Equatable, Sendable {
case loading(T)
case results(T)
case empty(EmptyState)
Expand Down
12 changes: 0 additions & 12 deletions CriticalMapsKit/Sources/Helpers/DateFormatter+Additions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ public extension DateFormatter {
}()
}

public extension DateComponentsFormatter {
/// Formatter to handle Twitter
static func tweetDateFormatter(_ calendar: Calendar = .current) -> DateComponentsFormatter {
let formatter = DateComponentsFormatter()
formatter.calendar = calendar
formatter.allowedUnits = [.month, .day, .hour, .minute]
formatter.unitsStyle = .short
formatter.maximumUnitCount = 1
return formatter
}
}

public extension Date.FormatStyle {
/// Format to display only the day and a medium format month -> 28 Okt.
static let dateWithoutYear: Self = .dateTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import Foundation
import UIKit.UIDevice

extension IDProvider: TestDependencyKey {
public static var testValue: IDProvider = Self()
public static let testValue: IDProvider = Self()
}
6 changes: 3 additions & 3 deletions CriticalMapsKit/Sources/IDProvider/IDProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import Helpers

/// Provides a hashed ID to create api update requests
@DependencyClient
public struct IDProvider {
public var id: () -> String = { "" }
public var token: () -> String = { "" }
public struct IDProvider: Sendable {
public var id: @Sendable () -> String = { "" }
public var token: @Sendable () -> String = { "" }

public static func hash(id: String, currentDate: () -> Date) -> String {
let dateString = DateFormatter.IDStoreHashDateFormatter.string(from: currentDate())
Expand Down
14 changes: 8 additions & 6 deletions CriticalMapsKit/Sources/MapFeature/MapFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public typealias MapFeatureState = MapFeature.State
public typealias MapFeatureAction = MapFeature.Action

@Reducer
public struct MapFeature {
public struct MapFeature: Sendable {
public init() {}

// MARK: State
Expand Down Expand Up @@ -55,7 +55,7 @@ public struct MapFeature {
}

@CasePathable
public enum Action: BindableAction, Equatable {
public enum Action: BindableAction, Equatable, Sendable {
case binding(BindingAction<State>)
case onAppear
case locationRequested
Expand Down Expand Up @@ -255,17 +255,17 @@ extension LocationManager {
}

public extension AlertState where Action == MapFeature.Action {
static let goToSettingsAlert = Self(
@MainActor static let goToSettingsAlert = Self(
title: { TextState(L10n.Location.Alert.provideAccessToLocationService) },
actions: {
ButtonState<MapFeature.Action> { TextState(L10n.Settings.title) }
ButtonState<MapFeature.Action> { TextState(L10n.Settings.title) }
}
)

static let provideAuth = Self(title: { TextState(L10n.Location.Alert.provideAuth) })
static let servicesOff = Self(title: { TextState(L10n.Location.Alert.serviceIsOff) })
static let provideAccessToLocationService = Self(
@MainActor static let provideAuth = Self(title: { TextState(L10n.Location.Alert.provideAuth) })
@MainActor static let servicesOff = Self(title: { TextState(L10n.Location.Alert.serviceIsOff) })
@MainActor static let provideAccessToLocationService = Self(
title: { TextState(L10n.Location.Alert.provideAccessToLocationService) }
)
}
Expand All @@ -283,3 +283,5 @@ public extension DependencyValues {
set { self[LocationManagerKey.self] = newValue }
}
}

extension LocationManager.Action: @retroactive @unchecked Sendable {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import MapKit
import SharedModels

/// A client to update rider annotations on a map.
@MainActor
public enum RiderAnnotationUpdateClient {
/// Calculates the difference between displayed annotations and a collection of new rider elements.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import L10n
import MapKit

@Reducer
public struct UserTrackingFeature {
public struct UserTrackingFeature: Sendable {
public init() {}

@ObservableState
Expand All @@ -15,7 +15,7 @@ public struct UserTrackingFeature {
}
}

public enum Action: Equatable {
public enum Action: Equatable, Sendable {
case nextTrackingMode
}

Expand Down
Loading