Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/#108] ๐Ÿšจ ์›Œํฌ ์•„์›ƒ ์„ธ์…˜ #111

Merged
merged 7 commits into from
Jul 3, 2023

Conversation

mooyoung2309
Copy link
Member

@mooyoung2309 mooyoung2309 commented Jun 28, 2023

PR ์š”์•ฝ

RPReplay_Final1688278005.MP4

store์—์„œ delegate ์ œ๊ฑฐ ์™„๋ฃŒ
watchOS์™€ iOS ํ†ต์‹  ์™„๋ฃŒ

๐Ÿ“Œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ

โœ… PR check list

Linked Issue

close #108

Comment on lines 145 to 157
let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute())
let heartRate = statistics.mostRecentQuantity()?.doubleValue(for: heartRateUnit) ?? 0
// viewStore?.send(.setHeartRate(10))
self.heartRate = heartRate
debugPrint("heart \(heartRate)")
//TODO: averageHeartRate ํ•„์š”์„ฑ ๊ณ ๋ฏผ ํ›„ ์ฃผ์„ ์ œ๊ฑฐ
// statistics.averageQuantity()?.doubleValue(for: heartRateUnit) ?? 0

case HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned):
let calorieUnit = HKUnit.kilocalorie()
let calorie = statistics.sumQuantity()?.doubleValue(for: calorieUnit) ?? 0
self.viewStore?.send(.setCalorie(Int(calorie)))
debugPrint("calorie \(calorie)")
Copy link
Member Author

Choose a reason for hiding this comment

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

@parkhj0423 @derrickkim0109
์ด๋ถ€๋ถ„์—์„œ ์™œ viewStore๋กœ send๊ฐ€ ์•ˆ๋ ๊นŒ์š” ? ์ด๋ถ€๋ถ„๋งŒ ํ•ด๊ฒฐํ•˜๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค. ์ดํ•ด๊ฐ€ ์ž˜ ์•ˆ๋ผ์š” ์ €๋Š”..

Copy link
Member

Choose a reason for hiding this comment

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

delegate๊ฐ€ Store์˜ State๋กœ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉด ์•ˆ๋ ๊ฑฐ๊ฐ™์€ ๋Š๋‚Œ์ด ๋“ค์–ด ์Šคํ† ์–ด์—์„œ ๋นผ๊ณ  ๋ณ„๋„์˜ ํด๋ž˜์Šค์—์„œ delegate ๊ตฌํ˜„ํ•˜๊ณ  ๋ทฐ์—์„œ onChange, onReceive๋กœ Store์— action send ํ•ด์„œ connectivity๋กœ ์˜๋Š” ๋ฐฉ๋ฒ•์€ ์–ด๋–„?

Copy link
Member Author

Choose a reason for hiding this comment

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

@parkhj0423
(onChange, onReceive ์ฒ˜์Œ ๋“ค์–ด๋ณธ ์ด์Šˆ..) delegate๋ฅผ ObservableObject ๊ฐ์‹ธ๊ณ  (์˜ˆ์ œ ์ฝ”๋“œ์ฒ˜๋Ÿผ) onChange์— publish ๋ณ€์ˆ˜๋ฅผ ๋„ฃ๊ณ  ํŠธ๋ž˜ํ‚น ํ•˜๋‹ค sendํ•˜๋Š” ๋ฐฉ์‹ ๋ง์”€ํ•˜์‹œ๋Š”๊ฑฐ์ฃ  ?

Copy link
Member

@parkhj0423 parkhj0423 Jun 29, 2023

Choose a reason for hiding this comment

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

์‘ ๋งž์•„ manager๋ฅผ StateObject๋กœ ๊ฐ€์ง€๊ณ  ์žˆ๊ณ , ๋ฉ”์ธ ๋ทฐ ์—์„œ onReceive๋ฅผ ํ†ตํ•ด @published ๋ณ€์ˆ˜์˜ ๋ณ€๊ฒฝ์„ ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ์–ด์„œ ๊ทธ ๋ถ€๋ถ„์—์„œ store์— ๊ฐ’์„ ํฌํ•จํ•œ ์•ก์…˜์„ ๋ณด๋‚ด๊ณ  ๋ฆฌ๋“€์„œ์—์„œ connectivity๋กœ iOS ์•ฑ์— ์ „์†ก ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด์•ผ

Copy link
Member

@parkhj0423 parkhj0423 left a comment

Choose a reason for hiding this comment

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

์˜๋ชจ๋Š” ์ด์Šˆ์žˆ์œผ๋ฉด ์•Œ๋ ค์ฃผ์„ธ์š”~

@github-actions github-actions bot added size/xl and removed size/l labels Jul 2, 2023
@github-actions
Copy link

github-actions bot commented Jul 2, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Comment on lines +85 to +107
case let .updateHeartRate(heartRate):
state.heartRateToCalc = heartRate

if let id = state.currentActiveTimerCellID {
state.heartRateToShow = heartRate
guard let timerIndex = state.timerCells.firstIndex(where: { $0.id == id }) else { return .none }
var targetTimer = state.timers[timerIndex]
targetTimer.heartRates.append(heartRate)

return .send(.updateTimer(index: timerIndex, timer: targetTimer))
}

return .none

case let .updateCalorie(calorie):
let diff = calorie - state.calorieToCalc
state.calorieToCalc = calorie

if let id = state.currentActiveTimerCellID {
state.calorieToShow += diff
guard let timerIndex = state.timerCells.firstIndex(where: { $0.id == id }) else { return .none }
var targetTimer = state.timers[timerIndex]
targetTimer.calorie += diff
Copy link
Member Author

Choose a reason for hiding this comment

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

ํƒ€์ด๋จธ์— ์‹ฌ๋ฐ•์ˆ˜์™€ ์นผ๋กœ๋ฆฌ๋ฅผ ๋„ฃ๋Š” ๋กœ์ง์ž…๋‹ˆ๋‹ค.
์กฐ๊ธˆ์€ ๊ณ ๋ฏผ ๋งŽ์ด ํ•œ ๋ถ€๋ถ„์ธ๋ฐ, ์˜ˆ์™ธ ์ผ€์ด์Šค๊ฐ€ ์ข€ ๋” ์žˆ์„ ๋“ฏ ์‹ถ์–ด์„œ ๊ณ ๋„ํ™” ํ•ด๋‚˜๊ฐ€์•ผํ•จ

@mooyoung2309 mooyoung2309 self-assigned this Jul 2, 2023
Copy link
Member

@parkhj0423 parkhj0423 left a comment

Choose a reason for hiding this comment

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

WatchConnectivity์™€ StateObject, OnReceive๋ถ€๋ถ„์„ ๋ง๋กœ๋งŒ ์„ค๋ช…ํ–ˆ๋Š”๋ฐ ์ž˜ ๊ตฌํ˜„ํ–ˆ๋„ค!! ๊ณ ์ƒํ–ˆ์–ด

}

public enum Action: Equatable {
case tapped
Copy link
Member

Choose a reason for hiding this comment

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

๊ทธ๋ƒฅ Tapped ๋ง๊ณ  workoutTimerButtonTapped์™€ ๊ฐ™์ด ์ž์„ธํžˆ ๋ช…์‹œํ•˜๋Š”๊ฒƒ์„ ์ถ”์ฒœ.

import SwiftUI
import ComposableArchitecture
import Shared

Copy link
Member

Choose a reason for hiding this comment

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

import ํ•˜๋Š” ๋ถ€๋ถ„๋„ ์šฐ๋ฆฌ๊ฐ€ ์ปจ๋ฒค์…˜์„ ๋งž์ถฐ์•ผํ•˜๋Š”๋ฐ ๋ณดํ†ต ์œ„์—์„œ๋ถ€ํ„ฐ ํผ์ŠคํŠธํŒŒํ‹ฐ ํ”„๋ ˆ์ž„์›Œํฌ, ์จ๋“œํŒŒํ‹ฐ, ๊ฐ™์€ ๋ ˆ์ด์–ด๋‚ด์˜ ๋ชจ๋“ˆ, ํ•˜์œ„๋ชจ๋“ˆ ์ˆœ์œผ๋กœ ์ •๋ฆฌํ•˜๋Š”๊ฒŒ ์ข‹์„๊ฑฐ๊ฐ™์•„ ์ด๋ถ€๋ถ„์€ ๋งŽ์ด ๋†“์ณ์ง€๊ณ  ์žˆ์œผ๋‹ˆ ํ•œ๋ฒˆ ์‹น ๋งž์ถ”๋Š” ์ž‘์—…์ด ํ•„์š”ํ• ๋“ฏ

Copy link
Member Author

Choose a reason for hiding this comment

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

// workout implements ์˜ ๊ฒฝ์šฐ ์˜ˆ์‹œ
import SwiftUI

import ComposableArchitecture

import FeatureWorkoutInterface

import Domain
import Core
import Shared

์ด๋ ‡๊ฒŒ ํ†ต์ผํ•˜๋ฉด ๋ ๊นŒ์š” ?!

cc. @derrickkim0109

}

public var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
Copy link
Member

Choose a reason for hiding this comment

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

๋‚˜๋Š” observe: { $0 } ๋ถ€๋ถ„์„ ํŠน์ • state๊ฐ€ ๋ณ€๊ฒฝ๋ ๋•Œ๋งŒ View Re-Rendering์ด ๋ฐœ์ƒํ•˜๊ฒŒ๋” ์›ํ•˜์ง€ ์•Š๋Š” ์ด์ƒ ๋นผ๊ณ ์žˆ์–ด

Copy link
Member Author

Choose a reason for hiding this comment

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

์š”๊ฑฐ๋Š” ๋‹น์žฅ ๋‹ค ๋ฐ”๊พธ๋Š”๊ฑฐ ์ข€ ๋งŽ์•„์„œ, ํ˜•๊บผ ๋จผ์ € ์ฝ”๋“œ ํ™•์ธ ํ›„์— ๋‹ค์Œ ๊ฐœ๋ฐœ๋ถ€ํ„ฐ ๋ฐ˜์˜ํ•ด๋‚˜๊ฐˆ๊ฒŒ์š” !

Copy link
Member Author

Choose a reason for hiding this comment

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

์–ด, ์ด๊ฑฐ ๊ทธ๋ƒฅ ๋นผ๋„ viewStore.State.๊ฐ’ ์ ‘๊ทผํ•˜๊ณ  ์žˆ์œผ๋ฉด re-rendering ๋˜๋Š”๊ตฌ์กฐ์ธ๊ฒŒ ๋งž๋‚˜์š” ?!

.onReceive(watchConnectivityDelegate.$heartRate, perform: { heartRate in
viewStore.send(.updateHeartRate(heartRate))
})
.onReceive(watchConnectivityDelegate.$calorie, perform: { calorie in
Copy link
Member

Choose a reason for hiding this comment

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

.onReceive(watchConnectivityDelegate.$heartRate) { heartRate in
viewStore.send(.updateHeartRate(heartRate))
}
์œผ๋กœ ํ•˜๋Š”๊ฒŒ ๋” ๊น”๋”!

Copy link
Member Author

Choose a reason for hiding this comment

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

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค ๋ฐ˜์˜์™„๋ฃŒ

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@mooyoung2309 mooyoung2309 merged commit 30ea4c5 into develop Jul 3, 2023
@mooyoung2309 mooyoung2309 deleted the feat/#108-workout-session branch July 3, 2023 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] connectivity workout session์œผ๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜
2 participants