Skip to content

Commit

Permalink
Added MVVM
Browse files Browse the repository at this point in the history
  • Loading branch information
perlinleo committed Mar 14, 2024
1 parent 2396209 commit 577bee6
Show file tree
Hide file tree
Showing 46 changed files with 973 additions and 609 deletions.
9 changes: 2 additions & 7 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ opt_in_rules:
disabled_rules:
- anonymous_argument_in_multiline_closure
- private_swiftui_state
- file_name
- attributes
- anyobject_protocol
- closure_body_length
Expand Down Expand Up @@ -58,20 +59,14 @@ disabled_rules:
- line_length
- identifier_name
- let_var_whitespace
- nslocalizedstring_key

identifier_name:
excluded:
- id
large_tuple: 3
number_separator:
minimum_length: 5
file_name:
excluded:
- Exports.swift
- GeneratedTests.swift
- RuleConfigurationMacros.swift
- SwiftSyntax+SwiftLint.swift
- TestHelpers.swift

balanced_xctest_lifecycle: &unit_test_configuration
test_parent_classes:
Expand Down
233 changes: 168 additions & 65 deletions LiveRecipes.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "swinject",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Swinject/Swinject",
"state" : {
"revision" : "463cb2d659c8ae34899d18057ea5b1bb86fc3178",
"version" : "2.8.4"
}
}
],
"version" : 2
}
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@
<dict>
<key>LiveRecipes.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>Sample-iOS (Playground) 1.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>Sample-iOS (Playground) 2.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>Sample-iOS (Playground).xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>0</integer>
</dict>
Expand Down
28 changes: 12 additions & 16 deletions LiveRecipes/ApplicationViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,27 @@

import Foundation
import SwiftUI
import Swinject

@MainActor
final class ApplicationViewBuilder: Assembly, ObservableObject {
required init(container: Container) {
super.init(container: container)
}

final class ApplicationViewBuilder: ObservableObject {
@ViewBuilder
func build(view: Views) -> some View {
func build(view: Tabs) -> some View {
switch view {
case .main:
buildMain()
case .recipes:
Assembler.sharedAssembly.resolver.resolve(RecipesView.self)
case .favorites:
Assembler.sharedAssembly.resolver.resolve(FavoritesView.self)
case .list:
Assembler.sharedAssembly.resolver.resolve(ListView.self)
case .cooking:
Assembler.sharedAssembly.resolver.resolve(CookingView.self)
}
}

@ViewBuilder
fileprivate func buildMain() -> some View {
container.resolve(RecipesAssembly.self).build()
}
}

extension ApplicationViewBuilder {
static var stub: ApplicationViewBuilder {
return ApplicationViewBuilder(
container: RootApp().container
)
return ApplicationViewBuilder()
}
}
33 changes: 0 additions & 33 deletions LiveRecipes/Library/Assembly.swift

This file was deleted.

35 changes: 0 additions & 35 deletions LiveRecipes/Library/AssemblyFactory.swift

This file was deleted.

60 changes: 0 additions & 60 deletions LiveRecipes/Library/DependencyContainer.swift

This file was deleted.

35 changes: 0 additions & 35 deletions LiveRecipes/Library/ObjectKey.swift

This file was deleted.

26 changes: 0 additions & 26 deletions LiveRecipes/Library/StrongBox.swift

This file was deleted.

24 changes: 0 additions & 24 deletions LiveRecipes/Library/WeakBox.swift

This file was deleted.

20 changes: 0 additions & 20 deletions LiveRecipes/Library/WeakContainer.swift

This file was deleted.

Loading

0 comments on commit 577bee6

Please sign in to comment.