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
15 changes: 4 additions & 11 deletions Examples/Standups/Standups/AppFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,20 @@ struct AppFeature: Reducer {
struct Path: Reducer {
enum State: Equatable {
case detail(StandupDetail.State)
case meeting(MeetingReducer.State)
case meeting(Meeting, standup: Standup)
case record(RecordMeeting.State)
}

enum Action: Equatable {
case detail(StandupDetail.Action)
case meeting(MeetingReducer.Action)
case meeting(Never)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this just be case meeting? Is this case even necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wouldn't want to use case meeting because that represents that the meeting view has an action when it does not. And case meeting(Never) can never actually be created, due to the Never, and so it definitely can be omitted entirely. I've just left it to have symmetry with the State, but it's not strictly necessary.

case record(RecordMeeting.Action)
}

var body: some Reducer<State, Action> {
Scope(state: /State.detail, action: /Action.detail) {
StandupDetail()
}
Scope(state: /State.meeting, action: /Action.meeting) {
MeetingReducer()
}
Scope(state: /State.record, action: /Action.record) {
RecordMeeting()
}
Expand All @@ -137,12 +134,8 @@ struct AppView: View {
action: AppFeature.Path.Action.detail,
then: StandupDetailView.init(store:)
)
case .meeting:
CaseLet(
/AppFeature.Path.State.meeting,
action: AppFeature.Path.Action.meeting,
then: MeetingView.init(store:)
)
case let .meeting(meeting, standup: standup):
MeetingView(meeting: meeting, standup: standup)
case .record:
CaseLet(
/AppFeature.Path.State.record,
Expand Down
43 changes: 16 additions & 27 deletions Examples/Standups/Standups/Meeting.swift
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
import ComposableArchitecture
import SwiftUI

struct MeetingReducer: Reducer {
struct State: Equatable {
let meeting: Meeting
let standup: Standup
}
enum Action: Equatable {}
func reduce(into state: inout State, action: Action) -> Effect<Action> {
}
}

struct MeetingView: View {
let store: StoreOf<MeetingReducer>
let meeting: Meeting
let standup: Standup

var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
ScrollView {
VStack(alignment: .leading) {
Divider()
.padding(.bottom)
Text("Attendees")
.font(.headline)
ForEach(viewStore.standup.attendees) { attendee in
Text(attendee.name)
}
Text("Transcript")
.font(.headline)
.padding(.top)
Text(viewStore.meeting.transcript)
ScrollView {
VStack(alignment: .leading) {
Divider()
.padding(.bottom)
Text("Attendees")
.font(.headline)
ForEach(self.standup.attendees) { attendee in
Text(attendee.name)
}
Text("Transcript")
.font(.headline)
.padding(.top)
Text(self.meeting.transcript)
}
.navigationTitle(Text(viewStore.meeting.date, style: .date))
.padding()
}
.navigationTitle(Text(self.meeting.date, style: .date))
.padding()
}
}
4 changes: 1 addition & 3 deletions Examples/Standups/Standups/StandupDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ struct StandupDetailView: View {
Section {
ForEach(viewStore.standup.meetings) { meeting in
NavigationLink(
state: AppFeature.Path.State.meeting(
MeetingReducer.State(meeting: meeting, standup: viewStore.standup)
)
state: AppFeature.Path.State.meeting(meeting, standup: viewStore.standup)
) {
HStack {
Image(systemName: "calendar")
Expand Down