Skip to content

Commit

Permalink
style: 💄 format
Browse files Browse the repository at this point in the history
  • Loading branch information
tomokisun committed Dec 26, 2023
1 parent 1d8c0d4 commit 0ac8900
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions Packages/FlyCam/Sources/CameraRecordFeature/Accelerometer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ private let GRAVITY_THRESHOLD = 0.2
@Reducer
public struct AccelerometerLogic {
public init() {}

public struct State: Equatable {
let motionManager = CMMotionManager()
var zeroGravityStartTime: Date?
var zeroGravityEndTime: Date?

public init() {}
}

public enum Action {
case startAccelerometerUpdates
case stopAccelerometerUpdates
case accelerometerUpdates(Result<CMAccelerometerData, Error>)
}

@Dependency(\.date.now) var now

enum Cancel {
case accelerometerUpdates
}

public var body: some Reducer<State, Action> {
Reduce<State, Action> { state, action in
switch action {
Expand All @@ -40,7 +40,7 @@ public struct AccelerometerLogic {
}
}
.cancellable(id: Cancel.accelerometerUpdates, cancelInFlight: true)

case .stopAccelerometerUpdates:
state.motionManager.stopAccelerometerUpdates()
return .none
Expand All @@ -65,7 +65,7 @@ public struct AccelerometerLogic {
}
}
}

func startAccelerometerUpdates(_ motionManager: CMMotionManager) -> AsyncStream<Result<CMAccelerometerData, Error>> {
AsyncStream { continuation in
motionManager.startAccelerometerUpdates(to: .main) { accelerometerData, error in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public struct CameraRecordLogic {
case .tool(.delegate(.startRecording)):
let delegate = Delegate()
state.videoCamera?.fileOutput.startRecording(to: state.videoFileURL, recordingDelegate: delegate)

return .merge(
.run(operation: { _ in
await feedbackGenerator.impactOccurred()
Expand All @@ -75,7 +75,7 @@ public struct CameraRecordLogic {
.reduce(into: &state.accelerometer, action: .startAccelerometerUpdates)
.map(Action.accelerometer)
)

case .tool(.delegate(.stopRecording)):
state.isActivityIndicatorVisible = true
state.videoCamera?.fileOutput.stopRecording()
Expand Down Expand Up @@ -146,7 +146,7 @@ public struct CameraRecordView: View {
ProgressView()
}
}

CaptureToolView(store: store.scope(state: \.tool, action: \.tool))
}
.padding(.vertical, 24)
Expand Down
18 changes: 9 additions & 9 deletions Packages/FlyCam/Sources/CameraRecordFeature/CaptureTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct CaptureToolLogic {
case onTask
case captureButtonTapped
case delegate(Delegate)

public enum Delegate: Equatable {
case startRecording
case stopRecording
Expand All @@ -26,13 +26,13 @@ public struct CaptureToolLogic {
switch action {
case .onTask:
return .none

case .captureButtonTapped:
defer {
state.isRecording.toggle()
}
return .send(.delegate(state.isRecording ? .stopRecording : .startRecording), animation: .default)

case .delegate:
return .none
}
Expand All @@ -46,16 +46,16 @@ public struct CaptureToolView: View {
public init(store: StoreOf<CaptureToolLogic>) {
self.store = store
}

struct ViewState: Equatable {
let isRecording: Bool
let redSize: CGFloat
let cornerRadius: CGFloat

init(state: CaptureToolLogic.State) {
self.isRecording = state.isRecording
self.redSize = state.isRecording ? 25 : 72
self.cornerRadius = state.isRecording ? 6 : 72 / 2
isRecording = state.isRecording
redSize = state.isRecording ? 25 : 72
cornerRadius = state.isRecording ? 6 : 72 / 2
}
}

Expand All @@ -74,7 +74,7 @@ public struct CaptureToolView: View {
.stroke(Color.white, lineWidth: 6.0)
.frame(width: 80, height: 80)
.contentShape(Rectangle())

Color.red
.frame(width: viewStore.redSize, height: viewStore.redSize)
.clipShape(RoundedRectangle(cornerRadius: viewStore.cornerRadius))
Expand Down

0 comments on commit 0ac8900

Please sign in to comment.