-
Notifications
You must be signed in to change notification settings - Fork 299
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
1 parent
c0ded85
commit a9611a8
Showing
20 changed files
with
1,373 additions
and
0 deletions.
There are no files selected for viewing
537 changes: 537 additions & 0 deletions
537
0223-composable-navigation-pt2/Inventory/Inventory.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...navigation-pt2/Inventory/Inventory.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
...2/Inventory/Inventory.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
88 changes: 88 additions & 0 deletions
88
...le-navigation-pt2/Inventory/Inventory.xcodeproj/xcshareddata/xcschemes/Inventory.xcscheme
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,88 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1420" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "2A3BE9F22994469500351060" | ||
BuildableName = "Inventory.app" | ||
BlueprintName = "Inventory" | ||
ReferencedContainer = "container:Inventory.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "2A3BEA022994469600351060" | ||
BuildableName = "InventoryTests.xctest" | ||
BlueprintName = "InventoryTests" | ||
ReferencedContainer = "container:Inventory.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "2A3BE9F22994469500351060" | ||
BuildableName = "Inventory.app" | ||
BlueprintName = "Inventory" | ||
ReferencedContainer = "container:Inventory.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "2A3BE9F22994469500351060" | ||
BuildableName = "Inventory.app" | ||
BlueprintName = "Inventory" | ||
ReferencedContainer = "container:Inventory.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
11 changes: 11 additions & 0 deletions
11
...ble-navigation-pt2/Inventory/Inventory/Assets.xcassets/AccentColor.colorset/Contents.json
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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...sable-navigation-pt2/Inventory/Inventory/Assets.xcassets/AppIcon.appiconset/Contents.json
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,13 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
0223-composable-navigation-pt2/Inventory/Inventory/Assets.xcassets/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
0223-composable-navigation-pt2/Inventory/Inventory/ContentView.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,99 @@ | ||
import ComposableArchitecture | ||
import SwiftUI | ||
|
||
struct AppFeature: Reducer { | ||
struct State: Equatable { | ||
var firstTab = FirstTabFeature.State() | ||
var inventory = InventoryFeature.State() | ||
var selectedTab: Tab = .one | ||
var thirdTab = ThirdTabFeature.State() | ||
} | ||
enum Action: Equatable { | ||
case firstTab(FirstTabFeature.Action) | ||
case inventory(InventoryFeature.Action) | ||
case selectedTabChanged(Tab) | ||
case thirdTab(ThirdTabFeature.Action) | ||
} | ||
var body: some ReducerOf<Self> { | ||
Reduce<State, Action> { state, action in | ||
switch action { | ||
case let .firstTab(.delegate(action)): | ||
switch action { | ||
case .switchToInventoryTab: | ||
state.selectedTab = .inventory | ||
return .none | ||
} | ||
|
||
case let .selectedTabChanged(tab): | ||
state.selectedTab = tab | ||
return .none | ||
|
||
case .firstTab, .inventory, .thirdTab: | ||
return .none | ||
} | ||
} | ||
Scope(state: \.firstTab, action: /Action.firstTab) { | ||
FirstTabFeature() | ||
} | ||
Scope(state: \.inventory, action: /Action.inventory) { | ||
InventoryFeature() | ||
} | ||
Scope(state: \.thirdTab, action: /Action.thirdTab) { | ||
ThirdTabFeature() | ||
} | ||
} | ||
} | ||
|
||
enum Tab { | ||
case one, inventory, three | ||
} | ||
|
||
struct ContentView: View { | ||
//@State var selectedTab: Tab = .one | ||
let store: StoreOf<AppFeature> | ||
// Store<AppFeature.State, AppFeature.Action> | ||
|
||
var body: some View { | ||
WithViewStore(self.store, observe: \.selectedTab) { viewStore in | ||
TabView(selection: viewStore.binding(send: AppFeature.Action.selectedTabChanged)) { | ||
FirstTabView( | ||
store: self.store.scope( | ||
state: \.firstTab, | ||
action: AppFeature.Action.firstTab | ||
) | ||
) | ||
.tabItem { Text("One") } | ||
.tag(Tab.one) | ||
|
||
InventoryView( | ||
store: self.store.scope( | ||
state: \.inventory, | ||
action: AppFeature.Action.inventory | ||
) | ||
) | ||
.tabItem { Text("Inventory") } | ||
.tag(Tab.inventory) | ||
|
||
ThirdTabView( | ||
store: self.store.scope( | ||
state: \.thirdTab, | ||
action: AppFeature.Action.thirdTab | ||
) | ||
) | ||
.tabItem { Text("Three") } | ||
.tag(Tab.three) | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct ContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ContentView( | ||
store: Store( | ||
initialState: AppFeature.State(), | ||
reducer: AppFeature() | ||
) | ||
) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
0223-composable-navigation-pt2/Inventory/Inventory/FirstTab.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,38 @@ | ||
import ComposableArchitecture | ||
import SwiftUI | ||
|
||
struct FirstTabFeature: Reducer { | ||
struct State: Equatable {} | ||
enum Action: Equatable { | ||
case goToInventoryButtonTapped | ||
case delegate(Delegate) | ||
|
||
enum Delegate: Equatable { | ||
case switchToInventoryTab | ||
} | ||
} | ||
|
||
func reduce(into state: inout State, action: Action) -> Effect<Action> { | ||
switch action { | ||
case .delegate: | ||
return .none | ||
|
||
case .goToInventoryButtonTapped: | ||
return .send(.delegate(.switchToInventoryTab)) | ||
} | ||
} | ||
} | ||
|
||
struct FirstTabView: View { | ||
let store: StoreOf<FirstTabFeature> | ||
|
||
var body: some View { | ||
WithViewStore(self.store, observe: { $0 }) { viewStore in | ||
Button { | ||
viewStore.send(.goToInventoryButtonTapped) | ||
} label: { | ||
Text("Go to inventory") | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.