Refactor project to MVVM architecture, modularize code, and clean ContentView #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📦 What was done
Refactored the entire project to follow MVVM architecture.
Extracted all business logic from
ContentViewinto:FreewriteViewModel(manages app state and main logic)FreewriterFileManager(handles file persistence:.mdmanagement and PDF exports)AppSettings(handles color scheme settings reactively).Split
ContentViewinto composable Components:SidebarViewBottomNavBarEntryCardOptionButtonChatPopOverViewIntroduced
Helpersfolder for reusable utilities.Improved code readability and maintainability across the project.
No new features were added — this is purely a code structure and organization improvement.
🔥 Motivation
Make the project easier to maintain, scale, and contribute to.
Improve separation of concerns, following best practices.
Enable future features to be added cleanly without bloating
ContentView.Ensure all file operations (
read,write,update,export) are managed independently from UI.🧹 Other Notes
The existing app functionality remains unchanged.
No behavior regression has been introduced.
Only structural improvements were made.
✅ Checklist for reviewers
Project structure migrated to MVVM cleanly.
No breaking changes to app functionality.
ContentViewno longer contains business logic.New
FreewriteViewModelintroduced and correctly handles app state.File operations (
create,read,update,export) are managed viaFreewriterFileManager.Color scheme settings are managed through
AppSettingsviaEnvironmentObject.UI components (
SidebarView,BottomNavBar,EntryCard,OptionButton,ChatPopOverView) are properly separated and reusable.Code readability and maintainability significantly improved.
No new features were added (pure refactor).
📝 Notes for reviewers
If needed, you can check the diff of
ContentView.swiftto easily confirm the extraction of UI-only code.No regressions were detected in manual testing.