Skip to content

Commit

Permalink
open sheet on banner tap
Browse files Browse the repository at this point in the history
  • Loading branch information
mltbnz committed Sep 28, 2024
1 parent ec0d164 commit d333857
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 9 additions & 3 deletions CriticalMapsKit/Sources/AppFeature/AppFeatureCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public struct AppFeature {
case requestTimer(RequestTimer.Action)
case settings(SettingsFeature.Action)
case social(SocialFeature.Action)
case didTapNextEventBanner

public enum Alert: Equatable, Sendable {
case observationMode(enabled: Bool)
Expand Down Expand Up @@ -322,10 +323,9 @@ public struct AppFeature {

case let .map(mapFeatureAction):
switch mapFeatureAction {
case .focusRideEvent,
.focusNextRide:
case .focusRideEvent, .focusNextRide:
if state.bottomSheetPosition != .hidden {
return .send(.set(\.$bottomSheetPosition, .relative(0.4)))
return .send(.set(\.$bottomSheetPosition, .relative(0.3)))
} else {
return .none
}
Expand Down Expand Up @@ -491,6 +491,12 @@ public struct AppFeature {
default:
return .none
}

case .didTapNextEventBanner:
return .merge(
.send(.map(.focusNextRide(state.nextRideState.nextRide?.coordinate))),
.send(.set(\.$bottomSheetPosition, .relative(0.3)))
)

case .binding:
return .none
Expand Down
10 changes: 2 additions & 8 deletions CriticalMapsKit/Sources/AppFeature/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ public struct AppView: View {
VStack(alignment: .leading) {
if shouldShowNextRideBanner {
nextRideBanner()
.contextMenu {
Button(
action: { viewStore.send(.set(\.$bottomSheetPosition, .relative(0.4))) },
label: { Label(contextMenuTitle, systemImage: "list.bullet") }
)
}
}

if viewStore.settingsState.infoViewEnabled {
Expand Down Expand Up @@ -98,7 +92,7 @@ public struct AppView: View {
.bottomSheet(
bottomSheetPosition: viewStore.$bottomSheetPosition,
switchablePositions: [
.relative(0.4),
.relative(0.3),
.relativeTop(0.975)
],
title: "Events",
Expand Down Expand Up @@ -262,7 +256,7 @@ public struct AppView: View {
},
action: { $0 }
),
action: { viewStore.send(.map(.focusNextRide(viewStore.nextRideState.nextRide?.coordinate))) },
action: { viewStore.send(.didTapNextEventBanner) },
content: {
VStack(alignment: .leading, spacing: .grid(1)) {
Text(viewStore.state.nextRideState.nextRide?.title ?? "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ final class AppFeatureTests: XCTestCase {
await store.send(.map(.focusRideEvent(coordinate))) {
$0.mapFeatureState.eventCenter = CoordinateRegion(center: coordinate.asCLLocationCoordinate)
}
await store.receive(.binding(.set(\.$bottomSheetPosition, .relative(0.4))))
await store.receive(.binding(.set(\.$bottomSheetPosition, .relative(0.3))))
await testClock.advance(by: .seconds(1))
await store.receive(.map(.resetRideEventCenter)) {
$0.mapFeatureState.eventCenter = nil
Expand Down

0 comments on commit d333857

Please sign in to comment.