A simple version of IG story, this demo app is my SwiftUI study record.
Although the refactoring is still ongoing, I would like to write down some of my reflections at the moment.
There were only a few parts of view models covered by unit tests 2 years ago. As an advocate of automated tests, it's a shame! I've already added back/update unit tests for view models and their collaborators, to improve the reliability of this app.
However, there is no unit tests coverage for all the SwiftUI views, because no testing mechanism officially provided by Apple. And I don't want to rely on 3rd party dependencies, for example, I've replaced the dependency of 3rd party SwiftyCam
to my own AVFoundation components before. My goal is to keep this app simple and pure.
Also, although the ideal way is using the real stuff for unit tests, because of the real AVfoundation framework is not testable in iOS simulator (simulator has no camera and mic.), all the tests written for AVFoundation components are by subclassing/method swizzling, mocking AVFoundation functions. This is the trade-off, it has the risk that the behaviours of those "mocking functions" may not be correct in the future iOS version, but this does enable testability.
Before, all the animation code was mixed with others in view models. I've done the separation, view models focus on other actions such as: image/video file management, and animation handlers are responsible for animation logic. Separation of concerns, keeping each component simple.
There are views composed in SimplifiedIgStoriesApp
, aka composition root. Before, the view had to "carry" every dependency which their child view needed only, or create the dependency the view did not need by itself.
This is an important move, it does enable the possibility to inject their collaborators directly depending on the view's need without caring of the view hierarchy.
- SwiftUI
- Combine
- AVFoundation
- XCTest
- Async/await
- Add
StoryPreviewViewModel
- Add unit tests for
StoryPreviewViewModel
- Refactor
StoryCameraViewModel
- Update unit tests for
StoryCameraViewModel
- Extract animation logic from
StoriesViewModel
toStoriesAnimationHandler
- Remove unnecessary
StoryViewModel
- Perform portion actions in a portion level
StoryPortionViewModel
- Add unit tests for
StoryPortionViewModel
,StoriesAnimationHandler
andStoryAnimationHandler
- Compose views and their collaborators in
SimplifiedIgStoriesApp
, aka composition root. Unlock the possibility to do dependency injection directly, without care of the view hierarchy.
- Cover most of the code in
StoriesViewModel
by unite tests - Inject
StoriesViewModel
intoHomeView
- Extract animation logic from
StoryViewModel
toStoryAnimationHandler
- Add unit tests
- Refactored some animation logic.
- More tests.
- Use my own AVFoundation manager class instead of SwiftyCam package.
- Add unit test for
StoriesModelView
.
- Merge combine branch to main.
- Add SwiftyCam by package from my forked combine-framework branch.
- Start a new branch for studying Combine Framework.
- Handle camera and microphone permission.
- Support removing current user story.
- Support playing video type story.
- Support taking photo and recording video for your story by SwiftyCam.
- Save your photo/video to album.