-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Javier Galera
committed
Mar 23, 2022
1 parent
cc212ca
commit d7e594e
Showing
16 changed files
with
181 additions
and
56 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+7.73 KB
(110%)
...k/petWalk.xcworkspace/xcuserdata/javier.galera.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
petWalk/petWalkWatchKitExtension/Design/ViewModel/PetDataViewConfigurator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// PetDataViewConfigurator.swift | ||
// petWalkWatchKitExtension | ||
// | ||
// Created by Galera, Javier on 17/3/22. | ||
// | ||
|
||
import Foundation | ||
|
||
class PetDataViewConfigurator { | ||
func configure() -> PetDataViewModel { | ||
let userDefaultDataSource = UserDefaultsDataSourceImplementation() | ||
let userDefaultRepository = UserDefaultsRepositoryImplementation(userDefaultDataSource: userDefaultDataSource) | ||
let getAccumulatedDailyStepsUseCase = GetAccumulatedDailyStepsUseCaseImplementation(repository: userDefaultRepository) | ||
|
||
return PetDataViewModel(getAccumulatedDailyStepsUseCase: getAccumulatedDailyStepsUseCase) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
petWalk/petWalkWatchKitExtension/Design/ViewModel/PetDataViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// PetDataViewModel.swift | ||
// petWalkWatchKitExtension | ||
// | ||
// Created by Galera, Javier on 17/3/22. | ||
// | ||
|
||
import Foundation | ||
|
||
class PetDataViewModel: ObservableObject { | ||
@Published var animationDailySteps: Int = 0 | ||
|
||
private var getAccumulatedDailyStepsUseCase: GetAccumulatedDailyStepsUseCase | ||
|
||
init(getAccumulatedDailyStepsUseCase: GetAccumulatedDailyStepsUseCase) { | ||
self.getAccumulatedDailyStepsUseCase = getAccumulatedDailyStepsUseCase | ||
} | ||
|
||
func calculateAnimationDailySteps(_ steps: Int) { | ||
let accumulatedDailySteps = self.getAccumulatedDailyStepsUseCase.execute() | ||
self.animationDailySteps = steps - accumulatedDailySteps | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...omain/UseCase/SaveDailyStepsUseCase.swift → ...se/SaveAccumulatedDailyStepsUseCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import Foundation | ||
|
||
protocol SaveDailyStepsUseCase: AutoMockable { | ||
protocol SaveAccumulatedDailyStepsUseCase: AutoMockable { | ||
func execute(_ steps: Int) | ||
} | ||
|
||
class SaveDailyStepsUseCaseImplementation: SaveDailyStepsUseCase { | ||
class SaveAccumulatedDailyStepsUseCaseImplementation: SaveAccumulatedDailyStepsUseCase { | ||
private var repository: UserDefaultsRepository | ||
|
||
public init(repository: UserDefaultsRepository) { | ||
self.repository = repository | ||
} | ||
|
||
func execute(_ steps: Int) { | ||
repository.saveDailySteps(steps) | ||
repository.saveAccumulatedDailySteps(steps) | ||
repository.saveDateDailySteps(Date()) | ||
} | ||
} |