-
Notifications
You must be signed in to change notification settings - Fork 4
fix: 0.7.1 reel 업데이트 경로 보강 #12
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,6 +93,18 @@ extension Array where Element == TextColumn { | |
| filter(\.value.isNumber).count | ||
| } | ||
|
|
||
| func digitOrdinalsByIndex() -> [Int: Int] { | ||
| var ordinalsByIndex: [Int: Int] = [:] | ||
| var digitOrdinal = 0 | ||
|
|
||
| for index in indices where self[index].value.isNumber { | ||
| ordinalsByIndex[index] = digitOrdinal | ||
| digitOrdinal += 1 | ||
| } | ||
|
|
||
| return ordinalsByIndex | ||
| } | ||
|
|
||
| func preservingReelPositions(_ positions: [UUID: Double]) -> [UUID: Double] { | ||
| var nextPositions: [UUID: Double] = [:] | ||
|
|
||
|
|
@@ -115,22 +127,50 @@ extension Array where Element == TextColumn { | |
| return nextPositions | ||
| } | ||
|
|
||
| @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | ||
| func reelPositions(updatingTo characters: [Character], | ||
| animation: AnimateNumberTextAnimation, | ||
| currentPositions: [UUID: Double]) -> [UUID: Double] { | ||
| let digitOrdinals = digitOrdinalsByIndex() | ||
| var nextPositions = preservingReelPositions(currentPositions) | ||
|
|
||
| for (index, character) in characters.enumerated() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Minor] Problem: Confidence score: 0.88 |
||
| let targetValue = TextType(character) | ||
| guard canAnimateDigitChange(to: targetValue, index: index), | ||
| let digit = targetValue.digitValue, | ||
| let digitOrdinal = digitOrdinals[index] else { | ||
| continue | ||
| } | ||
|
|
||
| let column = self[index] | ||
| let currentPosition = nextPositions[column.id] | ||
| ?? Double(column.value.digitValue ?? digit) | ||
| nextPositions[column.id] = animation.reelTargetPosition(from: currentPosition, | ||
| to: digit, | ||
| ordinal: digitOrdinal) | ||
| } | ||
|
|
||
| return nextPositions | ||
| } | ||
|
|
||
| func canAnimateDigitChange(to value: Character, index: Int) -> Bool { | ||
| canAnimateDigitChange(to: TextType(value), index: index) | ||
| } | ||
|
|
||
| func canAnimateDigitChange(to value: TextType, index: Int) -> Bool { | ||
| guard indices.contains(index) else { return false } | ||
|
|
||
| return self[index].value.isNumber && TextType(value).isNumber | ||
| return self[index].value.isNumber && value.isNumber | ||
| } | ||
|
|
||
| func needsUpdate(to value: Character, index: Int) -> Bool { | ||
| guard indices.contains(index) else { return false } | ||
|
|
||
| return self[index].value != TextType(value) | ||
| needsUpdate(to: TextType(value), index: index) | ||
| } | ||
|
|
||
| func digitOrdinal(at index: Int) -> Int? { | ||
| guard indices.contains(index), self[index].value.isNumber else { return nil } | ||
| func needsUpdate(to value: TextType, index: Int) -> Bool { | ||
| guard indices.contains(index) else { return false } | ||
|
|
||
| return self[..<index].filter(\.value.isNumber).count | ||
| return self[index].value != value | ||
| } | ||
|
|
||
| mutating func set(_ value: Character, index: Int) { | ||
|
|
||
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.
[Major] Problem:
digitOrdinal(at:)메서드는 프로덕션 코드에서 더 이상 사용되지 않으며, 테스트 코드 외에는 전혀 사용되지 않습니다. 이는 죽은 코드(Dead Code)로, 유지보수 부담과 불필요한 복잡성을 증가시킵니다. Why it matters: 죽은 코드는 코드베이스의 품질을 저하시키고, 다른 개발자가 이를 오해하거나 의도적으로 사용할 위험이 있습니다. Suggested fix:digitOrdinal(at:)메서드를 완전히 제거하고, 테스트 코드에서digitOrdinalsByIndex()를 사용하도록 수정하세요. Confidence: HighConfidence score: 0.95