Skip to content

Commit

Permalink
remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mltbnz committed Oct 6, 2024
1 parent 167d53b commit bf548b2
Show file tree
Hide file tree
Showing 20 changed files with 170 additions and 156 deletions.
3 changes: 0 additions & 3 deletions CriticalMapsKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ package.targets.append(contentsOf: [
.testHelper,
.tca,
.product(name: "MastodonKit", package: "MastodonKit")
],
exclude: [
"__Snapshots__"
]
)
])
Expand Down
4 changes: 2 additions & 2 deletions CriticalMapsKit/Sources/AppFeature/RideEventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct RideEventView: View {
),
slug: nil,
title: "CriticalMaps Berlin",
description: "Enim magna ea nostrud irure elit pariatur ea dolore in. Enim magna ea nostrud irure elit pariatur ea dolore in.Enim magna ea nostrud irure elit pariatur ea dolore in.Enim magna ea nostrud irure elit pariatur ea dolore in.",
description: "Enim magna ea nostrud irure elit pariatur ea dolore in. Enim magna ea nostrud irure elit pariatur ea dolore in.",
dateTime: Date(timeIntervalSince1970: 1727905659),
location: "Berlin",
latitude: 53.1235,
Expand All @@ -83,7 +83,7 @@ struct RideEventView: View {
),
slug: nil,
title: "CriticalMaps Berlin",
description: "Enim magna ea nostrud irure elit pariatur ea dolore in. Enim magna ea nostrud irure elit pariatur ea dolore in.Enim magna ea nostrud irure elit pariatur ea dolore in.Enim magna ea nostrud irure elit pariatur ea dolore in.",
description: "Enim magna ea nostrud irure elit pariatur ea dolore in. Enim magna ea nostrud irure elit pariatur ea dolore in.",
dateTime: Date(timeIntervalSince1970: 1727905659),
location: "Berlin",
latitude: 53.1235,
Expand Down
4 changes: 2 additions & 2 deletions CriticalMapsKit/Sources/ChatFeature/ChatFeatureCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public struct ChatFeature {
state.chatInputState.isSending = false

state.alert = AlertState(
title: TextState(L10n.error),
message: TextState("Failed to send chat message")
title: { TextState(L10n.error) },
message: { TextState("Failed to send chat message") }
)

logger.debug("ChatInput Action failed with error: \(error.localizedDescription)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ extension FeedbackGeneratorClient: DependencyKey {
public static let liveValue = {
let generator = UISelectionFeedbackGenerator()
return Self(
prepare: { await generator.prepare() },
selectionChanged: { await generator.selectionChanged() }
prepare: { generator.prepare() },
selectionChanged: { generator.selectionChanged() }
)
}()
}
Expand Down
21 changes: 12 additions & 9 deletions CriticalMapsKit/Sources/MapFeature/MapFeatureCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ public struct MapFeature {

case .didChangeAuthorization(.denied):
if state.isRequestingCurrentLocation {
state.alert = AlertState(
title: TextState("Location makes this app better. Please consider giving us access.")
)
state.alert = AlertState {
TextState("Location makes this app better. Please consider giving us access.")
}

state.isRequestingCurrentLocation = false
}
return .none
Expand Down Expand Up @@ -294,15 +295,17 @@ extension LocationManager {

public extension AlertState where Action == MapFeature.Action {
static let goToSettingsAlert = Self(
title: TextState(L10n.Location.Alert.provideAccessToLocationService),
primaryButton: .default(TextState(L10n.Settings.title)),
secondaryButton: .default(TextState(L10n.ok))
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 provideAuth = Self(title: {TextState(L10n.Location.Alert.provideAuth)})
static let servicesOff = Self(title: {TextState(L10n.Location.Alert.serviceIsOff)})
static let provideAccessToLocationService = Self(
title: TextState(L10n.Location.Alert.provideAccessToLocationService)
title: {TextState(L10n.Location.Alert.provideAccessToLocationService)}
)
}

Expand Down
24 changes: 15 additions & 9 deletions CriticalMapsKit/Sources/MapFeature/MapOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,20 @@ public struct MapOverlayView<Content>: View where Content: View {
}
}
)
.transition(.scale.animation(reduceMotion ? nil : .easeOut(duration: 0.2)))
.onChange(of: viewStore.isExpanded, perform: { newValue in
let updateAction: () -> Void = { self.isExpanded = newValue }
reduceMotion ? updateAction() : withAnimation { updateAction() }
})
.onChange(of: viewStore.isVisible, perform: { newValue in
let updateAction: () -> Void = { self.isVisible = newValue }
reduceMotion ? updateAction() : withAnimation { updateAction() }
})
.transition(.scale.combined(with: .opacity).animation(reduceMotion ? nil : .spring(duration: 0.2)))
.onChange(
of: viewStore.isExpanded,
perform: { newValue in
let updateAction: () -> Void = { self.isExpanded = newValue }
reduceMotion ? updateAction() : withAnimation { updateAction() }
}
)
.onChange(
of: viewStore.isVisible,
perform: { newValue in
let updateAction: () -> Void = { self.isVisible = newValue }
reduceMotion ? updateAction() : withAnimation { updateAction() }
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public struct MastodonFeedView: View {
public init(store: StoreOf<TootFeedFeature>) {
self.store = store
viewStore = ViewStore(
store.scope(state: MastodonFeedViewState.init, action: { $0 }),
store.scope(
state: MastodonFeedViewState.init,
action: { $0 }
),
observe: { $0 }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct TootFeedFeature {
case refresh
case fetchData
case fetchDataResponse(TaskResult<[Status]>)
case toot(id: TootFeature.State.ID, action: TootFeature.Action)
case toot(IdentifiedActionOf<TootFeature>)
}


Expand Down Expand Up @@ -90,13 +90,13 @@ public struct TootFeedFeature {
return .none
}
}
.forEach(\.toots, action: /TootFeedFeature.Action.toot) {
.forEach(\.toots, action: \.toot) {
TootFeature()
}
}
}

extension MastodonKit.Status: Identifiable {
extension MastodonKit.Status: @retroactive Identifiable {
public static func == (lhs: MastodonKit.Status, rhs: MastodonKit.Status) -> Bool {
lhs.id == rhs.id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public struct TootsListView: View {
ForEachStore(
self.store.scope(
state: \.toots,
action: TootFeedFeature.Action.toot
action: \.toot
)
) {
TootView(store: $0)
Expand Down
42 changes: 23 additions & 19 deletions CriticalMapsKit/Sources/SettingsFeature/RideEventRadius.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,31 @@ public struct RideEventRadiusView: View {
let store: StoreOf<RideEventRadius>

public var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
SettingsRow {
Button(
action: { viewStore.send(.set(\.$isSelected, true)) },
label: {
HStack(spacing: .grid(3)) {
Text(String(viewStore.eventDistance.displayValue))
.accessibility(label: Text(viewStore.eventDistance.displayValue))
.padding(.vertical, .grid(2))
Spacer()
if viewStore.isSelected {
Image(systemName: "checkmark.circle.fill")
.accessibilityRepresentation {
Text(L10n.A11y.General.selected)
}
WithViewStore(
self.store,
observe: { $0 },
content: { viewStore in
SettingsRow {
Button(
action: { viewStore.send(.set(\.$isSelected, true)) },
label: {
HStack(spacing: .grid(3)) {
Text(String(viewStore.eventDistance.displayValue))
.accessibility(label: Text(viewStore.eventDistance.displayValue))
.padding(.vertical, .grid(2))
Spacer()
if viewStore.isSelected {
Image(systemName: "checkmark.circle.fill")
.accessibilityRepresentation {
Text(L10n.A11y.General.selected)
}
}
}
.accessibilityElement(children: .combine)
}
.accessibilityElement(children: .combine)
}
)
)
}
}
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ import SwiftUIHelpers

/// A view to render next ride event settings
public struct RideEventSettingsView: View {
public typealias State = RideEventsSettingsFeature.State
public typealias Action = RideEventsSettingsFeature.Action
private let store: StoreOf<RideEventsSettingsFeature>
@ObservedObject var viewStore: ViewStoreOf<RideEventsSettingsFeature>

let store: Store<State, Action>
@ObservedObject var viewStore: ViewStore<State, Action>

public init(store: Store<State, Action>) {
public init(store: StoreOf<RideEventsSettingsFeature>) {
self.store = store
viewStore = ViewStore(
store,
Expand Down
46 changes: 25 additions & 21 deletions CriticalMapsKit/Sources/SettingsFeature/RideEventType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,33 @@ public struct RideEventTypeView: View {
let store: StoreOf<RideEventType>

public var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
SettingsRow {
Button(
action: {
viewStore.send(
.set(\.$isEnabled, !viewStore.state.isEnabled)
)
},
label: {
HStack(spacing: .grid(3)) {
Text(viewStore.rideType.title)
.padding(.vertical, .grid(2))
Spacer()
if viewStore.isEnabled {
Image(systemName: "checkmark.circle.fill")
} else {
Image(systemName: "circle")
WithViewStore(
self.store,
observe: { $0 },
content: { viewStore in
SettingsRow {
Button(
action: {
viewStore.send(
.set(\.$isEnabled, !viewStore.state.isEnabled)
)
},
label: {
HStack(spacing: .grid(3)) {
Text(viewStore.rideType.title)
.padding(.vertical, .grid(2))
Spacer()
if viewStore.isEnabled {
Image(systemName: "checkmark.circle.fill")
} else {
Image(systemName: "circle")
}
}
}
}
)
)
}
.accessibilityValue(viewStore.isEnabled ? Text(L10n.A11y.General.selected) : Text(""))
}
.accessibilityValue(viewStore.isEnabled ? Text(L10n.A11y.General.selected) : Text(""))
}
)
}
}
6 changes: 3 additions & 3 deletions CriticalMapsKit/Sources/UIApplicationClient/Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import UIKit.UIApplication
extension UIApplicationClient: DependencyKey {
public static let liveValue = Self(
alternateIconName: { UIApplication.shared.alternateIconName },
alternateIconNameAsync: { await UIApplication.shared.alternateIconName },
alternateIconNameAsync: { UIApplication.shared.alternateIconName },
open: { @MainActor in await UIApplication.shared.open($0, options: $1) },
openSettingsURLString: { await UIApplication.openSettingsURLString },
openSettingsURLString: { UIApplication.openSettingsURLString },
setAlternateIconName: { @MainActor in try await UIApplication.shared.setAlternateIconName($0) },
supportsAlternateIcons: { UIApplication.shared.supportsAlternateIcons },
supportsAlternateIconsAsync: { await UIApplication.shared.supportsAlternateIcons }
supportsAlternateIconsAsync: { UIApplication.shared.supportsAlternateIcons }
)
}
Loading

0 comments on commit bf548b2

Please sign in to comment.