-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
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)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parkhj0423 @derrickkim0109
์ด๋ถ๋ถ์์ ์ viewStore๋ก send๊ฐ ์๋ ๊น์ ? ์ด๋ถ๋ถ๋ง ํด๊ฒฐํ๊ณ ์ถ์ต๋๋ค. ์ดํด๊ฐ ์ ์๋ผ์ ์ ๋..
There was a problem hiding this comment.
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๋ก ์๋ ๋ฐฉ๋ฒ์ ์ด๋?
There was a problem hiding this comment.
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ํ๋ ๋ฐฉ์ ๋ง์ํ์๋๊ฑฐ์ฃ ?
There was a problem hiding this comment.
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 ์ฑ์ ์ ์ก ํ๋ ๋ฐฉ๋ฒ์ด์ผ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋ชจ๋ ์ด์์์ผ๋ฉด ์๋ ค์ฃผ์ธ์~
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. |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํ์ด๋จธ์ ์ฌ๋ฐ์์ ์นผ๋ก๋ฆฌ๋ฅผ ๋ฃ๋ ๋ก์ง์
๋๋ค.
์กฐ๊ธ์ ๊ณ ๋ฏผ ๋ง์ด ํ ๋ถ๋ถ์ธ๋ฐ, ์์ธ ์ผ์ด์ค๊ฐ ์ข ๋ ์์ ๋ฏ ์ถ์ด์ ๊ณ ๋ํ ํด๋๊ฐ์ผํจ
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import ํ๋ ๋ถ๋ถ๋ ์ฐ๋ฆฌ๊ฐ ์ปจ๋ฒค์ ์ ๋ง์ถฐ์ผํ๋๋ฐ ๋ณดํต ์์์๋ถํฐ ํผ์คํธํํฐ ํ๋ ์์ํฌ, ์จ๋ํํฐ, ๊ฐ์ ๋ ์ด์ด๋ด์ ๋ชจ๋, ํ์๋ชจ๋ ์์ผ๋ก ์ ๋ฆฌํ๋๊ฒ ์ข์๊ฑฐ๊ฐ์ ์ด๋ถ๋ถ์ ๋ง์ด ๋์ณ์ง๊ณ ์์ผ๋ ํ๋ฒ ์น ๋ง์ถ๋ ์์ ์ด ํ์ํ ๋ฏ
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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์ด ๋ฐ์ํ๊ฒ๋ ์ํ์ง ์๋ ์ด์ ๋นผ๊ณ ์์ด
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๊ฑฐ๋ ๋น์ฅ ๋ค ๋ฐ๊พธ๋๊ฑฐ ์ข ๋ง์์, ํ๊บผ ๋จผ์ ์ฝ๋ ํ์ธ ํ์ ๋ค์ ๊ฐ๋ฐ๋ถํฐ ๋ฐ์ํด๋๊ฐ๊ฒ์ !
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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))
}
์ผ๋ก ํ๋๊ฒ ๋ ๊น๋!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๊ฐ์ฌํฉ๋๋ค ๋ฐ์์๋ฃ
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. |
PR ์์ฝ
RPReplay_Final1688278005.MP4
store์์ delegate ์ ๊ฑฐ ์๋ฃ
watchOS์ iOS ํต์ ์๋ฃ
๐ ๋ณ๊ฒฝ ์ฌํญ
โ PR check list
Linked Issue
close #108