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
19 changes: 7 additions & 12 deletions Examples/SyncUps/SyncUps/AppFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,13 @@ struct AppView: View {
}

#Preview {
AppView(
store: Store(
initialState: AppFeature.State(
syncUpsList: SyncUpsList.State(
syncUps: [
.mock,
.productMock,
.engineeringMock,
]
)
)
) {
@Shared(.syncUps) var syncUps: IdentifiedArrayOf<SyncUp> = [
Copy link
Member Author

Choose a reason for hiding this comment

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

I had some sync-ups cleanup on the shared branch that snuck into this. The PR review can stay focused on the Sources directory, I can also cherry-pick the sync-ups changes back into the beta branch if that makes it easier to review.

.mock,
.productMock,
.engineeringMock
]
return AppView(
store: Store(initialState: AppFeature.State()) {
AppFeature()
}
)
Expand Down
6 changes: 3 additions & 3 deletions Examples/SyncUps/SyncUps/Meeting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ struct MeetingView: View {
var body: some View {
Form {
Section {
ForEach(self.syncUp.attendees) { attendee in
ForEach(syncUp.attendees) { attendee in
Text(attendee.name)
}
} header: {
Text("Attendees")
}
Section {
Text(self.meeting.transcript)
Text(meeting.transcript)
} header: {
Text("Transcript")
}
}
.navigationTitle(Text(self.meeting.date, style: .date))
.navigationTitle(Text(meeting.date, style: .date))
}
}

Expand Down
6 changes: 3 additions & 3 deletions Examples/SyncUps/SyncUps/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct SyncUp: Equatable, Identifiable, Codable {
var title = ""

var durationPerAttendee: Duration {
self.duration / self.attendees.count
duration / attendees.count
}
}

Expand Down Expand Up @@ -56,9 +56,9 @@ enum Theme: String, CaseIterable, Equatable, Identifiable, Codable {
}
}

var mainColor: Color { Color(self.rawValue) }
var mainColor: Color { Color(rawValue) }

var name: String { self.rawValue.capitalized }
var name: String { rawValue.capitalized }
}

extension SyncUp {
Expand Down
72 changes: 36 additions & 36 deletions Examples/SyncUps/SyncUps/RecordMeeting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct RecordMeeting {
var transcript = ""

var durationRemaining: Duration {
self.syncUp.duration - .seconds(self.secondsElapsed)
syncUp.duration - .seconds(secondsElapsed)
}
}

Expand Down Expand Up @@ -41,11 +41,11 @@ struct RecordMeeting {
Reduce { state, action in
switch action {
case .alert(.presented(.confirmDiscard)):
return .run { _ in await self.dismiss() }
return .run { _ in await dismiss() }

case .alert(.presented(.confirmSave)):
state.syncUp.insert(transcript: state.transcript)
return .run { _ in await self.dismiss() }
return .run { _ in await dismiss() }

case .alert:
return .none
Expand All @@ -68,18 +68,18 @@ struct RecordMeeting {
case .onTask:
return .run { send in
let authorization =
await self.speechClient.authorizationStatus() == .notDetermined
? self.speechClient.requestAuthorization()
: self.speechClient.authorizationStatus()
await speechClient.authorizationStatus() == .notDetermined
? speechClient.requestAuthorization()
: speechClient.authorizationStatus()

await withTaskGroup(of: Void.self) { group in
if authorization == .authorized {
group.addTask {
await self.startSpeechRecognition(send: send)
await startSpeechRecognition(send: send)
}
}
group.addTask {
await self.startTimer(send: send)
await startTimer(send: send)
}
}
}
Expand All @@ -94,7 +94,7 @@ struct RecordMeeting {
if state.secondsElapsed.isMultiple(of: secondsPerAttendee) {
if state.secondsElapsed == state.syncUp.duration.components.seconds {
state.syncUp.insert(transcript: state.transcript)
return .run { _ in await self.dismiss() }
return .run { _ in await dismiss() }
}
state.speakerIndex += 1
}
Expand All @@ -118,7 +118,7 @@ struct RecordMeeting {

private func startSpeechRecognition(send: Send<Action>) async {
do {
let speechTask = await self.speechClient.startTask(SFSpeechAudioBufferRecognitionRequest())
let speechTask = await speechClient.startTask(SFSpeechAudioBufferRecognitionRequest())
for try await result in speechTask {
await send(.speechResult(result))
}
Expand All @@ -128,7 +128,7 @@ struct RecordMeeting {
}

private func startTimer(send: Send<Action>) async {
for await _ in self.clock.timer(interval: .seconds(1)) {
for await _ in clock.timer(interval: .seconds(1)) {
await send(.timerTick)
}
}
Expand All @@ -138,7 +138,7 @@ extension SyncUp {
fileprivate mutating func insert(transcript: String) {
@Dependency(\.date.now) var now
@Dependency(\.uuid) var uuid
self.meetings.insert(
meetings.insert(
Meeting(
id: Meeting.ID(uuid()),
date: now,
Expand Down Expand Up @@ -239,22 +239,22 @@ struct MeetingHeaderView: View {

var body: some View {
VStack {
ProgressView(value: self.progress)
.progressViewStyle(MeetingProgressViewStyle(theme: self.theme))
ProgressView(value: progress)
.progressViewStyle(MeetingProgressViewStyle(theme: theme))
HStack {
VStack(alignment: .leading) {
Text("Time Elapsed")
.font(.caption)
Label(
Duration.seconds(self.secondsElapsed).formatted(.units()),
Duration.seconds(secondsElapsed).formatted(.units()),
systemImage: "hourglass.bottomhalf.fill"
)
}
Spacer()
VStack(alignment: .trailing) {
Text("Time Remaining")
.font(.caption)
Label(self.durationRemaining.formatted(.units()), systemImage: "hourglass.tophalf.fill")
Label(durationRemaining.formatted(.units()), systemImage: "hourglass.tophalf.fill")
.font(.body.monospacedDigit())
.labelStyle(.trailingIcon)
}
Expand All @@ -264,12 +264,12 @@ struct MeetingHeaderView: View {
}

private var totalDuration: Duration {
.seconds(self.secondsElapsed) + self.durationRemaining
.seconds(secondsElapsed) + durationRemaining
}

private var progress: Double {
guard self.totalDuration > .seconds(0) else { return 0 }
return Double(self.secondsElapsed) / Double(self.totalDuration.components.seconds)
guard totalDuration > .seconds(0) else { return 0 }
return Double(secondsElapsed) / Double(totalDuration.components.seconds)
}
}

Expand All @@ -279,11 +279,11 @@ struct MeetingProgressViewStyle: ProgressViewStyle {
func makeBody(configuration: Configuration) -> some View {
ZStack {
RoundedRectangle(cornerRadius: 10)
.fill(self.theme.accentColor)
.fill(theme.accentColor)
.frame(height: 20)

ProgressView(configuration)
.tint(self.theme.mainColor)
.tint(theme.mainColor)
.frame(height: 12)
.padding(.horizontal)
}
Expand All @@ -300,8 +300,8 @@ struct MeetingTimerView: View {
.overlay {
VStack {
Group {
if self.speakerIndex < self.syncUp.attendees.count {
Text(self.syncUp.attendees[self.speakerIndex].name)
if speakerIndex < syncUp.attendees.count {
Text(syncUp.attendees[speakerIndex].name)
} else {
Text("Someone")
}
Expand All @@ -312,14 +312,14 @@ struct MeetingTimerView: View {
.font(.largeTitle)
.padding(.top)
}
.foregroundStyle(self.syncUp.theme.accentColor)
.foregroundStyle(syncUp.theme.accentColor)
}
.overlay {
ForEach(Array(self.syncUp.attendees.enumerated()), id: \.element.id) { index, attendee in
if index < self.speakerIndex + 1 {
SpeakerArc(totalSpeakers: self.syncUp.attendees.count, speakerIndex: index)
ForEach(Array(syncUp.attendees.enumerated()), id: \.element.id) { index, attendee in
if index < speakerIndex + 1 {
SpeakerArc(totalSpeakers: syncUp.attendees.count, speakerIndex: index)
.rotation(Angle(degrees: -90))
.stroke(self.syncUp.theme.mainColor, lineWidth: 12)
.stroke(syncUp.theme.mainColor, lineWidth: 12)
}
}
}
Expand All @@ -339,21 +339,21 @@ struct SpeakerArc: Shape {
path.addArc(
center: center,
radius: radius,
startAngle: self.startAngle,
endAngle: self.endAngle,
startAngle: startAngle,
endAngle: endAngle,
clockwise: false
)
}
}

private var degreesPerSpeaker: Double {
360 / Double(self.totalSpeakers)
360 / Double(totalSpeakers)
}
private var startAngle: Angle {
Angle(degrees: self.degreesPerSpeaker * Double(self.speakerIndex) + 1)
Angle(degrees: degreesPerSpeaker * Double(speakerIndex) + 1)
}
private var endAngle: Angle {
Angle(degrees: self.startAngle.degrees + self.degreesPerSpeaker - 1)
Angle(degrees: startAngle.degrees + degreesPerSpeaker - 1)
}
}

Expand All @@ -365,13 +365,13 @@ struct MeetingFooterView: View {
var body: some View {
VStack {
HStack {
if self.speakerIndex < self.syncUp.attendees.count - 1 {
Text("Speaker \(self.speakerIndex + 1) of \(self.syncUp.attendees.count)")
if speakerIndex < syncUp.attendees.count - 1 {
Text("Speaker \(speakerIndex + 1) of \(syncUp.attendees.count)")
} else {
Text("No more speakers.")
}
Spacer()
Button(action: self.nextButtonTapped) {
Button(action: nextButtonTapped) {
Image(systemName: "forward.fill")
}
}
Expand Down
6 changes: 3 additions & 3 deletions Examples/SyncUps/SyncUps/SyncUpDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ struct SyncUpDetail {
case .confirmDeletion:
@Shared(.syncUps) var syncUps: IdentifiedArrayOf<SyncUp> = []
syncUps.remove(id: state.syncUp.id)
return .run { _ in await self.dismiss() }
return .run { _ in await dismiss() }

case .continueWithoutRecording:
return .send(.delegate(.startMeeting))

case .openSettings:
return .run { _ in await self.openSettings() }
return .run { _ in await openSettings() }
}

case .destination:
Expand All @@ -89,7 +89,7 @@ struct SyncUpDetail {
return .none

case .startMeetingButtonTapped:
switch self.authorizationStatus() {
switch authorizationStatus() {
case .notDetermined, .authorized:
return .send(.delegate(.startMeeting))

Expand Down
8 changes: 4 additions & 4 deletions Examples/SyncUps/SyncUps/SyncUpForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct SyncUpForm {
Reduce { state, action in
switch action {
case .addAttendeeButtonTapped:
let attendee = Attendee(id: Attendee.ID(self.uuid()))
let attendee = Attendee(id: Attendee.ID(uuid()))
state.syncUp.attendees.append(attendee)
state.focus = .attendee(attendee.id)
return .none
Expand All @@ -48,7 +48,7 @@ struct SyncUpForm {
case let .deleteAttendees(atOffsets: indices):
state.syncUp.attendees.remove(atOffsets: indices)
if state.syncUp.attendees.isEmpty {
state.syncUp.attendees.append(Attendee(id: Attendee.ID(self.uuid())))
state.syncUp.attendees.append(Attendee(id: Attendee.ID(uuid())))
}
guard let firstIndex = indices.first
else { return .none }
Expand Down Expand Up @@ -104,7 +104,7 @@ struct ThemePicker: View {
@Binding var selection: Theme

var body: some View {
Picker("Theme", selection: self.$selection) {
Picker("Theme", selection: $selection) {
ForEach(Theme.allCases) { theme in
ZStack {
RoundedRectangle(cornerRadius: 4)
Expand All @@ -122,7 +122,7 @@ struct ThemePicker: View {

extension Duration {
fileprivate var minutes: Double {
get { Double(self.components.seconds / 60) }
get { Double(components.seconds / 60) }
set { self = .seconds(newValue * 60) }
}
}
Expand Down
Loading