-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* iOS 16 Update Updated the app to use iOS 16 patterns and features. * Accessibility updates * Refactor Color view out of ColorService Someone on the internet didn't understand abstraction and they were mad that I used Color (the View) inside a service. I refactored it out with this update which really doesn't change much. * Update README with project architecture description * Add older OS reference to the README
- Loading branch information
Showing
26 changed files
with
374 additions
and
289 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -7,13 +7,13 @@ | |
objects = { | ||
|
||
/* Begin PBXBuildFile section */ | ||
6FD86CD9293DE9060052C759 /* ObjectNavigationStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FD86CD8293DE9060052C759 /* ObjectNavigationStack.swift */; }; | ||
6FD86CDC2940033C0052C759 /* BusyIndicator in Frameworks */ = {isa = PBXBuildFile; productRef = 6FD86CDB2940033C0052C759 /* BusyIndicator */; }; | ||
9647788B2774F0EE002203DE /* AnyPublisher+AwaitResults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9647788A2774F0EE002203DE /* AnyPublisher+AwaitResults.swift */; }; | ||
964778902774F240002203DE /* AuthenticationService+Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9647788F2774F240002203DE /* AuthenticationService+Tests.swift */; }; | ||
964778922774F64A002203DE /* Result+TestExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964778912774F64A002203DE /* Result+TestExtensions.swift */; }; | ||
9665D9552745C1D60055F1F6 /* ColorWizardCoordinatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9665D9542745C1D60055F1F6 /* ColorWizardCoordinatorView.swift */; }; | ||
9665D9572745C1F10055F1F6 /* ColorWizardCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9665D9562745C1F10055F1F6 /* ColorWizardCoordinator.swift */; }; | ||
9665D95A2745C2540055F1F6 /* ColorWizardPageCoordinatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9665D9592745C2540055F1F6 /* ColorWizardPageCoordinatorView.swift */; }; | ||
9665D95C2745C26F0055F1F6 /* ColorWizardPageCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9665D95B2745C26F0055F1F6 /* ColorWizardPageCoordinator.swift */; }; | ||
9665D95F2745C2E00055F1F6 /* ColorWizardContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9665D95E2745C2E00055F1F6 /* ColorWizardContentView.swift */; }; | ||
9665D9612745C2FA0055F1F6 /* ColorWizardContentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9665D9602745C2FA0055F1F6 /* ColorWizardContentViewModel.swift */; }; | ||
9665D9632745C3410055F1F6 /* ColorWizardConfigurationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9665D9622745C3410055F1F6 /* ColorWizardConfigurationViewModel.swift */; }; | ||
|
@@ -40,7 +40,6 @@ | |
96B4E0AE27432FAB00EC88B3 /* UIApplication+EndEditing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B4E0AD27432FAB00EC88B3 /* UIApplication+EndEditing.swift */; }; | ||
96B4E0B027432FD000EC88B3 /* Button+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B4E0AF27432FD000EC88B3 /* Button+Extensions.swift */; }; | ||
96B4E0B327432FEB00EC88B3 /* EdgeInsets+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B4E0B227432FEB00EC88B3 /* EdgeInsets+Extensions.swift */; }; | ||
96B4E0B72743302100EC88B3 /* View+Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B4E0B62743302100EC88B3 /* View+Navigation.swift */; }; | ||
96B4E0B92743303F00EC88B3 /* View+OnReceive.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B4E0B82743303F00EC88B3 /* View+OnReceive.swift */; }; | ||
96B4E0BE2743309B00EC88B3 /* AppAssembler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B4E0BD2743309B00EC88B3 /* AppAssembler.swift */; }; | ||
96B4E0C0274330B400EC88B3 /* CoordinatorAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B4E0BF274330B400EC88B3 /* CoordinatorAssembly.swift */; }; | ||
|
@@ -86,13 +85,13 @@ | |
/* End PBXContainerItemProxy section */ | ||
|
||
/* Begin PBXFileReference section */ | ||
6FBF3B6729F10AA2008BB5B7 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; }; | ||
6FD86CD8293DE9060052C759 /* ObjectNavigationStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectNavigationStack.swift; sourceTree = "<group>"; }; | ||
9647788A2774F0EE002203DE /* AnyPublisher+AwaitResults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AnyPublisher+AwaitResults.swift"; sourceTree = "<group>"; }; | ||
9647788F2774F240002203DE /* AuthenticationService+Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AuthenticationService+Tests.swift"; sourceTree = "<group>"; }; | ||
964778912774F64A002203DE /* Result+TestExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Result+TestExtensions.swift"; sourceTree = "<group>"; }; | ||
9665D9542745C1D60055F1F6 /* ColorWizardCoordinatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorWizardCoordinatorView.swift; sourceTree = "<group>"; }; | ||
9665D9562745C1F10055F1F6 /* ColorWizardCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorWizardCoordinator.swift; sourceTree = "<group>"; }; | ||
9665D9592745C2540055F1F6 /* ColorWizardPageCoordinatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorWizardPageCoordinatorView.swift; sourceTree = "<group>"; }; | ||
9665D95B2745C26F0055F1F6 /* ColorWizardPageCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorWizardPageCoordinator.swift; sourceTree = "<group>"; }; | ||
9665D95E2745C2E00055F1F6 /* ColorWizardContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorWizardContentView.swift; sourceTree = "<group>"; }; | ||
9665D9602745C2FA0055F1F6 /* ColorWizardContentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorWizardContentViewModel.swift; sourceTree = "<group>"; }; | ||
9665D9622745C3410055F1F6 /* ColorWizardConfigurationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorWizardConfigurationViewModel.swift; sourceTree = "<group>"; }; | ||
|
@@ -120,7 +119,6 @@ | |
96B4E0AD27432FAB00EC88B3 /* UIApplication+EndEditing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+EndEditing.swift"; sourceTree = "<group>"; }; | ||
96B4E0AF27432FD000EC88B3 /* Button+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Button+Extensions.swift"; sourceTree = "<group>"; }; | ||
96B4E0B227432FEB00EC88B3 /* EdgeInsets+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EdgeInsets+Extensions.swift"; sourceTree = "<group>"; }; | ||
96B4E0B62743302100EC88B3 /* View+Navigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Navigation.swift"; sourceTree = "<group>"; }; | ||
96B4E0B82743303F00EC88B3 /* View+OnReceive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+OnReceive.swift"; sourceTree = "<group>"; }; | ||
96B4E0BD2743309B00EC88B3 /* AppAssembler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAssembler.swift; sourceTree = "<group>"; }; | ||
96B4E0BF274330B400EC88B3 /* CoordinatorAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoordinatorAssembly.swift; sourceTree = "<group>"; }; | ||
|
@@ -155,6 +153,7 @@ | |
files = ( | ||
96B4E0A227432EEE00EC88B3 /* CombineExt in Frameworks */, | ||
96B4E0A527432EFC00EC88B3 /* Swinject in Frameworks */, | ||
6FD86CDC2940033C0052C759 /* BusyIndicator in Frameworks */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
|
@@ -199,22 +198,12 @@ | |
children = ( | ||
9665D9692745CCB70055F1F6 /* Configuration */, | ||
9665D95D2745C2C80055F1F6 /* Content */, | ||
9665D9582745C2210055F1F6 /* PageCoordinator */, | ||
9665D9542745C1D60055F1F6 /* ColorWizardCoordinatorView.swift */, | ||
9665D9562745C1F10055F1F6 /* ColorWizardCoordinator.swift */, | ||
); | ||
path = ColorWizard; | ||
sourceTree = "<group>"; | ||
}; | ||
9665D9582745C2210055F1F6 /* PageCoordinator */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
9665D9592745C2540055F1F6 /* ColorWizardPageCoordinatorView.swift */, | ||
9665D95B2745C26F0055F1F6 /* ColorWizardPageCoordinator.swift */, | ||
); | ||
path = PageCoordinator; | ||
sourceTree = "<group>"; | ||
}; | ||
9665D95D2745C2C80055F1F6 /* Content */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
|
@@ -268,6 +257,7 @@ | |
96B4E06327432D6100EC88B3 /* MVVM.Demo.SwiftUI */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
6FBF3B6729F10AA2008BB5B7 /* README.md */, | ||
96B4E0BC2743306A00EC88B3 /* Architecture */, | ||
96B4E08F27432DEB00EC88B3 /* Core */, | ||
96B4E0CB274331DB00EC88B3 /* Services */, | ||
|
@@ -344,7 +334,7 @@ | |
96B4E0AF27432FD000EC88B3 /* Button+Extensions.swift */, | ||
96B4E0EA274386FA00EC88B3 /* Color+SystemColors.swift */, | ||
96B4E0B227432FEB00EC88B3 /* EdgeInsets+Extensions.swift */, | ||
96B4E0B62743302100EC88B3 /* View+Navigation.swift */, | ||
6FD86CD8293DE9060052C759 /* ObjectNavigationStack.swift */, | ||
96B4E0B82743303F00EC88B3 /* View+OnReceive.swift */, | ||
); | ||
path = SwiftUI; | ||
|
@@ -494,6 +484,7 @@ | |
packageProductDependencies = ( | ||
96B4E0A127432EEE00EC88B3 /* CombineExt */, | ||
96B4E0A427432EFC00EC88B3 /* Swinject */, | ||
6FD86CDB2940033C0052C759 /* BusyIndicator */, | ||
); | ||
productName = MVVM.Demo.SwiftUI; | ||
productReference = 96B4E06127432D6100EC88B3 /* MVVM.Demo.SwiftUI.app */; | ||
|
@@ -570,6 +561,7 @@ | |
packageReferences = ( | ||
96B4E0A027432EEE00EC88B3 /* XCRemoteSwiftPackageReference "CombineExt" */, | ||
96B4E0A327432EFC00EC88B3 /* XCRemoteSwiftPackageReference "Swinject" */, | ||
6FD86CDA2940033C0052C759 /* XCRemoteSwiftPackageReference "BusyIndicator" */, | ||
); | ||
productRefGroup = 96B4E06227432D6100EC88B3 /* Products */; | ||
projectDirPath = ""; | ||
|
@@ -627,7 +619,6 @@ | |
96B4E09627432E6800EC88B3 /* CancelBag.swift in Sources */, | ||
96B4E0D42743382B00EC88B3 /* LandingView.swift in Sources */, | ||
96B4E0CF274335A900EC88B3 /* ColorService.swift in Sources */, | ||
9665D95A2745C2540055F1F6 /* ColorWizardPageCoordinatorView.swift in Sources */, | ||
96B4E0CA2743314700EC88B3 /* AppRootCoordinator.swift in Sources */, | ||
96B4E0B92743303F00EC88B3 /* View+OnReceive.swift in Sources */, | ||
96B4E0D62743384F00EC88B3 /* LandingViewModel.swift in Sources */, | ||
|
@@ -640,7 +631,6 @@ | |
96B4E0A727432F1C00EC88B3 /* PassthroughSubject+Extensions.swift in Sources */, | ||
96B4E09827432E7D00EC88B3 /* Just+Void.swift in Sources */, | ||
9665D9552745C1D60055F1F6 /* ColorWizardCoordinatorView.swift in Sources */, | ||
96B4E0B72743302100EC88B3 /* View+Navigation.swift in Sources */, | ||
968D344D27CD941700340C18 /* AlertService.AlertPackage+View.swift in Sources */, | ||
9665D9612745C2FA0055F1F6 /* ColorWizardContentViewModel.swift in Sources */, | ||
96B4E0D1274336EE00EC88B3 /* AlertService.swift in Sources */, | ||
|
@@ -649,13 +639,13 @@ | |
96B4E0F0274424FE00EC88B3 /* PulseViewModel.swift in Sources */, | ||
96B4E0E227437CA200EC88B3 /* SignInView.swift in Sources */, | ||
96B4E0DF2743396600EC88B3 /* ButtonTextStyle.swift in Sources */, | ||
9665D95C2745C26F0055F1F6 /* ColorWizardPageCoordinator.swift in Sources */, | ||
96B4E0DD2743393E00EC88B3 /* TextStyle.swift in Sources */, | ||
E9959A7328666409006FDF5A /* AlertManager+Environment.swift in Sources */, | ||
96B4E0B327432FEB00EC88B3 /* EdgeInsets+Extensions.swift in Sources */, | ||
96B4E09A27432E9300EC88B3 /* Publisher+DefinedScheduler.swift in Sources */, | ||
96B4E0EE274424F600EC88B3 /* PulseView.swift in Sources */, | ||
96B4E0E927437D5300EC88B3 /* CardView.swift in Sources */, | ||
6FD86CD9293DE9060052C759 /* ObjectNavigationStack.swift in Sources */, | ||
9665D9652745C3700055F1F6 /* ColorWizardConfiguration.swift in Sources */, | ||
96B4E0CD274331EE00EC88B3 /* AuthenticationService.swift in Sources */, | ||
9665D9572745C1F10055F1F6 /* ColorWizardCoordinator.swift in Sources */, | ||
|
@@ -833,11 +823,12 @@ | |
INFOPLIST_KEY_UILaunchScreen_Generation = YES; | ||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; | ||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; | ||
IPHONEOS_DEPLOYMENT_TARGET = 16.1; | ||
LD_RUNPATH_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
"@executable_path/Frameworks", | ||
); | ||
MARKETING_VERSION = 1.0; | ||
MARKETING_VERSION = 3.0.0; | ||
PRODUCT_BUNDLE_IDENTIFIER = "com.jasonrapai.MVVM-Demo-SwiftUI"; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
SWIFT_EMIT_LOC_STRINGS = YES; | ||
|
@@ -862,11 +853,12 @@ | |
INFOPLIST_KEY_UILaunchScreen_Generation = YES; | ||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; | ||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; | ||
IPHONEOS_DEPLOYMENT_TARGET = 16.1; | ||
LD_RUNPATH_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
"@executable_path/Frameworks", | ||
); | ||
MARKETING_VERSION = 1.0; | ||
MARKETING_VERSION = 3.0.0; | ||
PRODUCT_BUNDLE_IDENTIFIER = "com.jasonrapai.MVVM-Demo-SwiftUI"; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
SWIFT_EMIT_LOC_STRINGS = YES; | ||
|
@@ -884,7 +876,7 @@ | |
CURRENT_PROJECT_VERSION = 1; | ||
DEVELOPMENT_TEAM = QGV9TK3SFM; | ||
GENERATE_INFOPLIST_FILE = YES; | ||
IPHONEOS_DEPLOYMENT_TARGET = 15.0; | ||
IPHONEOS_DEPLOYMENT_TARGET = 16.1; | ||
LD_RUNPATH_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
"@executable_path/Frameworks", | ||
|
@@ -909,7 +901,7 @@ | |
CURRENT_PROJECT_VERSION = 1; | ||
DEVELOPMENT_TEAM = QGV9TK3SFM; | ||
GENERATE_INFOPLIST_FILE = YES; | ||
IPHONEOS_DEPLOYMENT_TARGET = 15.0; | ||
IPHONEOS_DEPLOYMENT_TARGET = 16.1; | ||
LD_RUNPATH_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
"@executable_path/Frameworks", | ||
|
@@ -933,6 +925,7 @@ | |
CURRENT_PROJECT_VERSION = 1; | ||
DEVELOPMENT_TEAM = QGV9TK3SFM; | ||
GENERATE_INFOPLIST_FILE = YES; | ||
IPHONEOS_DEPLOYMENT_TARGET = 16.1; | ||
LD_RUNPATH_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
"@executable_path/Frameworks", | ||
|
@@ -956,6 +949,7 @@ | |
CURRENT_PROJECT_VERSION = 1; | ||
DEVELOPMENT_TEAM = QGV9TK3SFM; | ||
GENERATE_INFOPLIST_FILE = YES; | ||
IPHONEOS_DEPLOYMENT_TARGET = 16.1; | ||
LD_RUNPATH_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
"@executable_path/Frameworks", | ||
|
@@ -1013,6 +1007,14 @@ | |
/* End XCConfigurationList section */ | ||
|
||
/* Begin XCRemoteSwiftPackageReference section */ | ||
6FD86CDA2940033C0052C759 /* XCRemoteSwiftPackageReference "BusyIndicator" */ = { | ||
isa = XCRemoteSwiftPackageReference; | ||
repositoryURL = "[email protected]:jasonjrr/BusyIndicator.git"; | ||
requirement = { | ||
kind = exactVersion; | ||
version = 1.0.0; | ||
}; | ||
}; | ||
96B4E0A027432EEE00EC88B3 /* XCRemoteSwiftPackageReference "CombineExt" */ = { | ||
isa = XCRemoteSwiftPackageReference; | ||
repositoryURL = "https://github.com/CombineCommunity/CombineExt"; | ||
|
@@ -1032,6 +1034,11 @@ | |
/* End XCRemoteSwiftPackageReference section */ | ||
|
||
/* Begin XCSwiftPackageProductDependency section */ | ||
6FD86CDB2940033C0052C759 /* BusyIndicator */ = { | ||
isa = XCSwiftPackageProductDependency; | ||
package = 6FD86CDA2940033C0052C759 /* XCRemoteSwiftPackageReference "BusyIndicator" */; | ||
productName = BusyIndicator; | ||
}; | ||
96B4E0A127432EEE00EC88B3 /* CombineExt */ = { | ||
isa = XCSwiftPackageProductDependency; | ||
package = 96B4E0A027432EEE00EC88B3 /* XCRemoteSwiftPackageReference "CombineExt" */; | ||
|
9 changes: 9 additions & 0 deletions
9
MVVM.Demo.SwiftUI.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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,5 +1,14 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "busyindicator", | ||
"kind" : "remoteSourceControl", | ||
"location" : "[email protected]:jasonjrr/BusyIndicator.git", | ||
"state" : { | ||
"revision" : "dd4d5e4160372accad6ff54beb69c3354c85f63b", | ||
"version" : "1.0.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "combineext", | ||
"kind" : "remoteSourceControl", | ||
|
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
80 changes: 80 additions & 0 deletions
80
MVVM.Demo.SwiftUI/Core/SwiftUI/ObjectNavigationStack.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,80 @@ | ||
// | ||
// ObjectNavigationStack.swift | ||
// MVVM.Demo.SwiftUI | ||
// | ||
// Created by Jason Lew-Rapai on 12/5/22. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ObjectNavigationStack<Content>: View where Content : View { | ||
@ObservedObject var path: ObjectNavigationPath | ||
let content: () -> Content | ||
|
||
var body: some View { | ||
NavigationStack(path: self.$path.path, root: self.content) | ||
} | ||
} | ||
|
||
class ObjectNavigationPath: ObservableObject { | ||
typealias NavigationObject = AnyObject & Hashable & Equatable | ||
@Published fileprivate var path: NavigationPath = NavigationPath() | ||
private var objects: [any NavigationObject] = [] | ||
|
||
private let semaphore: DispatchSemaphore = DispatchSemaphore(value: 1) | ||
|
||
var last: (any NavigationObject)? { | ||
self.objects.last | ||
} | ||
|
||
func append(_ object: some NavigationObject) { | ||
self.semaphore.wait() | ||
self.objects.append(object) | ||
self.path.append(object) | ||
self.semaphore.signal() | ||
} | ||
|
||
func removeLast() { | ||
self.semaphore.wait() | ||
self.objects.removeLast() | ||
self.path.removeLast() | ||
self.semaphore.signal() | ||
} | ||
|
||
@discardableResult | ||
func removeLast<Element : NavigationObject>(through graphObject: Element) -> Element? { | ||
self.semaphore.wait() | ||
var removeCount: Int = 0 | ||
defer { | ||
self.path.removeLast(removeCount) | ||
self.semaphore.signal() | ||
} | ||
|
||
while let object = self.objects.popLast() { | ||
removeCount = removeCount + 1 | ||
if graphObject === object { | ||
return graphObject | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
@discardableResult | ||
func removeLast(through clause: (any NavigationObject) -> Bool) -> (any NavigationObject)? { | ||
self.semaphore.wait() | ||
var removeCount: Int = 0 | ||
defer { | ||
self.path.removeLast(removeCount) | ||
self.semaphore.signal() | ||
} | ||
|
||
while let object = self.objects.popLast() { | ||
removeCount = removeCount + 1 | ||
if clause(object) { | ||
return object | ||
} | ||
} | ||
return nil | ||
} | ||
} | ||
|
Oops, something went wrong.