├── .gitignore ├── LICENSE ├── README.md ├── RouterWithTriggerViews.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── RouterWithTriggerViews.xcscheme └── RouterWithTriggerViews ├── Assets.xcassets ├── AccentColor.colorset │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Info.plist ├── PresentedView.swift ├── PresentingRouter.swift ├── PresentingView.swift ├── Preview Content └── Preview Assets.xcassets │ └── Contents.json ├── Router ├── BasePresentedRouter.swift ├── NavigatingRouter.swift ├── NavigationButton.swift ├── PresentedRouter.swift └── SheetButton.swift └── RouterWithViewTriggersApp.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 ihorvovk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Routing-in-SwiftUI-with-trigger-views -------------------------------------------------------------------------------- /RouterWithTriggerViews.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A296C3E22517BAFF005B03F2 /* RouterWithViewTriggersApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A296C3E12517BAFF005B03F2 /* RouterWithViewTriggersApp.swift */; }; 11 | A296C3E42517BAFF005B03F2 /* PresentingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A296C3E32517BAFF005B03F2 /* PresentingView.swift */; }; 12 | A296C3E62517BB01005B03F2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A296C3E52517BB01005B03F2 /* Assets.xcassets */; }; 13 | A296C3E92517BB01005B03F2 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A296C3E82517BB01005B03F2 /* Preview Assets.xcassets */; }; 14 | A2E5E039251F67BB00878ACB /* PresentedRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E5E038251F67BB00878ACB /* PresentedRouter.swift */; }; 15 | A2E5E03B251F67C400878ACB /* NavigatingRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E5E03A251F67C400878ACB /* NavigatingRouter.swift */; }; 16 | A2E5E03D251F67CF00878ACB /* NavigationButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E5E03C251F67CF00878ACB /* NavigationButton.swift */; }; 17 | A2E5E03F251F67D800878ACB /* SheetButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E5E03E251F67D800878ACB /* SheetButton.swift */; }; 18 | A2E5E041251F684000878ACB /* PresentingRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E5E040251F684000878ACB /* PresentingRouter.swift */; }; 19 | A2E5E043251F686000878ACB /* PresentedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E5E042251F686000878ACB /* PresentedView.swift */; }; 20 | A2E5E0452520A67C00878ACB /* BasePresentedRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E5E0442520A67C00878ACB /* BasePresentedRouter.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | A296C3DE2517BAFF005B03F2 /* RouterWithTriggerViews.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RouterWithTriggerViews.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | A296C3E12517BAFF005B03F2 /* RouterWithViewTriggersApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterWithViewTriggersApp.swift; sourceTree = ""; }; 26 | A296C3E32517BAFF005B03F2 /* PresentingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentingView.swift; sourceTree = ""; }; 27 | A296C3E52517BB01005B03F2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | A296C3E82517BB01005B03F2 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 29 | A296C3EA2517BB01005B03F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | A2E5E038251F67BB00878ACB /* PresentedRouter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresentedRouter.swift; sourceTree = ""; }; 31 | A2E5E03A251F67C400878ACB /* NavigatingRouter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigatingRouter.swift; sourceTree = ""; }; 32 | A2E5E03C251F67CF00878ACB /* NavigationButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationButton.swift; sourceTree = ""; }; 33 | A2E5E03E251F67D800878ACB /* SheetButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SheetButton.swift; sourceTree = ""; }; 34 | A2E5E040251F684000878ACB /* PresentingRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentingRouter.swift; sourceTree = ""; }; 35 | A2E5E042251F686000878ACB /* PresentedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentedView.swift; sourceTree = ""; }; 36 | A2E5E0442520A67C00878ACB /* BasePresentedRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasePresentedRouter.swift; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | A296C3DB2517BAFF005B03F2 /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | A296C3D52517BAFF005B03F2 = { 51 | isa = PBXGroup; 52 | children = ( 53 | A296C3E02517BAFF005B03F2 /* RouterWithTriggerViews */, 54 | A296C3DF2517BAFF005B03F2 /* Products */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | A296C3DF2517BAFF005B03F2 /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | A296C3DE2517BAFF005B03F2 /* RouterWithTriggerViews.app */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | A296C3E02517BAFF005B03F2 /* RouterWithTriggerViews */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | A2E5E037251F67A700878ACB /* Router */, 70 | A296C3E12517BAFF005B03F2 /* RouterWithViewTriggersApp.swift */, 71 | A296C3E32517BAFF005B03F2 /* PresentingView.swift */, 72 | A2E5E040251F684000878ACB /* PresentingRouter.swift */, 73 | A2E5E042251F686000878ACB /* PresentedView.swift */, 74 | A296C3E52517BB01005B03F2 /* Assets.xcassets */, 75 | A296C3EA2517BB01005B03F2 /* Info.plist */, 76 | A296C3E72517BB01005B03F2 /* Preview Content */, 77 | ); 78 | path = RouterWithTriggerViews; 79 | sourceTree = ""; 80 | }; 81 | A296C3E72517BB01005B03F2 /* Preview Content */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | A296C3E82517BB01005B03F2 /* Preview Assets.xcassets */, 85 | ); 86 | path = "Preview Content"; 87 | sourceTree = ""; 88 | }; 89 | A2E5E037251F67A700878ACB /* Router */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | A2E5E03A251F67C400878ACB /* NavigatingRouter.swift */, 93 | A2E5E038251F67BB00878ACB /* PresentedRouter.swift */, 94 | A2E5E0442520A67C00878ACB /* BasePresentedRouter.swift */, 95 | A2E5E03C251F67CF00878ACB /* NavigationButton.swift */, 96 | A2E5E03E251F67D800878ACB /* SheetButton.swift */, 97 | ); 98 | path = Router; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | A296C3DD2517BAFF005B03F2 /* RouterWithTriggerViews */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = A296C3ED2517BB01005B03F2 /* Build configuration list for PBXNativeTarget "RouterWithTriggerViews" */; 107 | buildPhases = ( 108 | A296C3DA2517BAFF005B03F2 /* Sources */, 109 | A296C3DB2517BAFF005B03F2 /* Frameworks */, 110 | A296C3DC2517BAFF005B03F2 /* Resources */, 111 | ); 112 | buildRules = ( 113 | ); 114 | dependencies = ( 115 | ); 116 | name = RouterWithTriggerViews; 117 | productName = RouterWithViewTriggers; 118 | productReference = A296C3DE2517BAFF005B03F2 /* RouterWithTriggerViews.app */; 119 | productType = "com.apple.product-type.application"; 120 | }; 121 | /* End PBXNativeTarget section */ 122 | 123 | /* Begin PBXProject section */ 124 | A296C3D62517BAFF005B03F2 /* Project object */ = { 125 | isa = PBXProject; 126 | attributes = { 127 | LastSwiftUpdateCheck = 1200; 128 | LastUpgradeCheck = 1200; 129 | TargetAttributes = { 130 | A296C3DD2517BAFF005B03F2 = { 131 | CreatedOnToolsVersion = 12.0; 132 | }; 133 | }; 134 | }; 135 | buildConfigurationList = A296C3D92517BAFF005B03F2 /* Build configuration list for PBXProject "RouterWithTriggerViews" */; 136 | compatibilityVersion = "Xcode 9.3"; 137 | developmentRegion = en; 138 | hasScannedForEncodings = 0; 139 | knownRegions = ( 140 | en, 141 | Base, 142 | ); 143 | mainGroup = A296C3D52517BAFF005B03F2; 144 | productRefGroup = A296C3DF2517BAFF005B03F2 /* Products */; 145 | projectDirPath = ""; 146 | projectRoot = ""; 147 | targets = ( 148 | A296C3DD2517BAFF005B03F2 /* RouterWithTriggerViews */, 149 | ); 150 | }; 151 | /* End PBXProject section */ 152 | 153 | /* Begin PBXResourcesBuildPhase section */ 154 | A296C3DC2517BAFF005B03F2 /* Resources */ = { 155 | isa = PBXResourcesBuildPhase; 156 | buildActionMask = 2147483647; 157 | files = ( 158 | A296C3E92517BB01005B03F2 /* Preview Assets.xcassets in Resources */, 159 | A296C3E62517BB01005B03F2 /* Assets.xcassets in Resources */, 160 | ); 161 | runOnlyForDeploymentPostprocessing = 0; 162 | }; 163 | /* End PBXResourcesBuildPhase section */ 164 | 165 | /* Begin PBXSourcesBuildPhase section */ 166 | A296C3DA2517BAFF005B03F2 /* Sources */ = { 167 | isa = PBXSourcesBuildPhase; 168 | buildActionMask = 2147483647; 169 | files = ( 170 | A296C3E42517BAFF005B03F2 /* PresentingView.swift in Sources */, 171 | A2E5E03F251F67D800878ACB /* SheetButton.swift in Sources */, 172 | A296C3E22517BAFF005B03F2 /* RouterWithViewTriggersApp.swift in Sources */, 173 | A2E5E043251F686000878ACB /* PresentedView.swift in Sources */, 174 | A2E5E039251F67BB00878ACB /* PresentedRouter.swift in Sources */, 175 | A2E5E03D251F67CF00878ACB /* NavigationButton.swift in Sources */, 176 | A2E5E041251F684000878ACB /* PresentingRouter.swift in Sources */, 177 | A2E5E0452520A67C00878ACB /* BasePresentedRouter.swift in Sources */, 178 | A2E5E03B251F67C400878ACB /* NavigatingRouter.swift in Sources */, 179 | ); 180 | runOnlyForDeploymentPostprocessing = 0; 181 | }; 182 | /* End PBXSourcesBuildPhase section */ 183 | 184 | /* Begin XCBuildConfiguration section */ 185 | A296C3EB2517BB01005B03F2 /* Debug */ = { 186 | isa = XCBuildConfiguration; 187 | buildSettings = { 188 | ALWAYS_SEARCH_USER_PATHS = NO; 189 | CLANG_ANALYZER_NONNULL = YES; 190 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_MODULES = YES; 194 | CLANG_ENABLE_OBJC_ARC = YES; 195 | CLANG_ENABLE_OBJC_WEAK = YES; 196 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 197 | CLANG_WARN_BOOL_CONVERSION = YES; 198 | CLANG_WARN_COMMA = YES; 199 | CLANG_WARN_CONSTANT_CONVERSION = YES; 200 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 201 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 202 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 203 | CLANG_WARN_EMPTY_BODY = YES; 204 | CLANG_WARN_ENUM_CONVERSION = YES; 205 | CLANG_WARN_INFINITE_RECURSION = YES; 206 | CLANG_WARN_INT_CONVERSION = YES; 207 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 208 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 209 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 210 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 211 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 212 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 213 | CLANG_WARN_STRICT_PROTOTYPES = YES; 214 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 215 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 216 | CLANG_WARN_UNREACHABLE_CODE = YES; 217 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 218 | COPY_PHASE_STRIP = NO; 219 | DEBUG_INFORMATION_FORMAT = dwarf; 220 | ENABLE_STRICT_OBJC_MSGSEND = YES; 221 | ENABLE_TESTABILITY = YES; 222 | GCC_C_LANGUAGE_STANDARD = gnu11; 223 | GCC_DYNAMIC_NO_PIC = NO; 224 | GCC_NO_COMMON_BLOCKS = YES; 225 | GCC_OPTIMIZATION_LEVEL = 0; 226 | GCC_PREPROCESSOR_DEFINITIONS = ( 227 | "DEBUG=1", 228 | "$(inherited)", 229 | ); 230 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 231 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 232 | GCC_WARN_UNDECLARED_SELECTOR = YES; 233 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 234 | GCC_WARN_UNUSED_FUNCTION = YES; 235 | GCC_WARN_UNUSED_VARIABLE = YES; 236 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 237 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 238 | MTL_FAST_MATH = YES; 239 | ONLY_ACTIVE_ARCH = YES; 240 | SDKROOT = iphoneos; 241 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 242 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 243 | }; 244 | name = Debug; 245 | }; 246 | A296C3EC2517BB01005B03F2 /* Release */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | ALWAYS_SEARCH_USER_PATHS = NO; 250 | CLANG_ANALYZER_NONNULL = YES; 251 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 252 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 253 | CLANG_CXX_LIBRARY = "libc++"; 254 | CLANG_ENABLE_MODULES = YES; 255 | CLANG_ENABLE_OBJC_ARC = YES; 256 | CLANG_ENABLE_OBJC_WEAK = YES; 257 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 258 | CLANG_WARN_BOOL_CONVERSION = YES; 259 | CLANG_WARN_COMMA = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 262 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 263 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 264 | CLANG_WARN_EMPTY_BODY = YES; 265 | CLANG_WARN_ENUM_CONVERSION = YES; 266 | CLANG_WARN_INFINITE_RECURSION = YES; 267 | CLANG_WARN_INT_CONVERSION = YES; 268 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 269 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 270 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 271 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 272 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 273 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 274 | CLANG_WARN_STRICT_PROTOTYPES = YES; 275 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 276 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 277 | CLANG_WARN_UNREACHABLE_CODE = YES; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | COPY_PHASE_STRIP = NO; 280 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 281 | ENABLE_NS_ASSERTIONS = NO; 282 | ENABLE_STRICT_OBJC_MSGSEND = YES; 283 | GCC_C_LANGUAGE_STANDARD = gnu11; 284 | GCC_NO_COMMON_BLOCKS = YES; 285 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 286 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 287 | GCC_WARN_UNDECLARED_SELECTOR = YES; 288 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 289 | GCC_WARN_UNUSED_FUNCTION = YES; 290 | GCC_WARN_UNUSED_VARIABLE = YES; 291 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 292 | MTL_ENABLE_DEBUG_INFO = NO; 293 | MTL_FAST_MATH = YES; 294 | SDKROOT = iphoneos; 295 | SWIFT_COMPILATION_MODE = wholemodule; 296 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 297 | VALIDATE_PRODUCT = YES; 298 | }; 299 | name = Release; 300 | }; 301 | A296C3EE2517BB01005B03F2 /* Debug */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 305 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 306 | CODE_SIGN_STYLE = Automatic; 307 | DEVELOPMENT_ASSET_PATHS = "\"RouterWithTriggerViews/Preview Content\""; 308 | DEVELOPMENT_TEAM = 8684QJA92T; 309 | ENABLE_PREVIEWS = YES; 310 | INFOPLIST_FILE = RouterWithTriggerViews/Info.plist; 311 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 312 | LD_RUNPATH_SEARCH_PATHS = ( 313 | "$(inherited)", 314 | "@executable_path/Frameworks", 315 | ); 316 | PRODUCT_BUNDLE_IDENTIFIER = ihor.vovk.RouterWithTriggerViews; 317 | PRODUCT_NAME = "$(TARGET_NAME)"; 318 | SWIFT_VERSION = 5.0; 319 | TARGETED_DEVICE_FAMILY = "1,2"; 320 | }; 321 | name = Debug; 322 | }; 323 | A296C3EF2517BB01005B03F2 /* Release */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 327 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 328 | CODE_SIGN_STYLE = Automatic; 329 | DEVELOPMENT_ASSET_PATHS = "\"RouterWithTriggerViews/Preview Content\""; 330 | DEVELOPMENT_TEAM = 8684QJA92T; 331 | ENABLE_PREVIEWS = YES; 332 | INFOPLIST_FILE = RouterWithTriggerViews/Info.plist; 333 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 334 | LD_RUNPATH_SEARCH_PATHS = ( 335 | "$(inherited)", 336 | "@executable_path/Frameworks", 337 | ); 338 | PRODUCT_BUNDLE_IDENTIFIER = ihor.vovk.RouterWithTriggerViews; 339 | PRODUCT_NAME = "$(TARGET_NAME)"; 340 | SWIFT_VERSION = 5.0; 341 | TARGETED_DEVICE_FAMILY = "1,2"; 342 | }; 343 | name = Release; 344 | }; 345 | /* End XCBuildConfiguration section */ 346 | 347 | /* Begin XCConfigurationList section */ 348 | A296C3D92517BAFF005B03F2 /* Build configuration list for PBXProject "RouterWithTriggerViews" */ = { 349 | isa = XCConfigurationList; 350 | buildConfigurations = ( 351 | A296C3EB2517BB01005B03F2 /* Debug */, 352 | A296C3EC2517BB01005B03F2 /* Release */, 353 | ); 354 | defaultConfigurationIsVisible = 0; 355 | defaultConfigurationName = Release; 356 | }; 357 | A296C3ED2517BB01005B03F2 /* Build configuration list for PBXNativeTarget "RouterWithTriggerViews" */ = { 358 | isa = XCConfigurationList; 359 | buildConfigurations = ( 360 | A296C3EE2517BB01005B03F2 /* Debug */, 361 | A296C3EF2517BB01005B03F2 /* Release */, 362 | ); 363 | defaultConfigurationIsVisible = 0; 364 | defaultConfigurationName = Release; 365 | }; 366 | /* End XCConfigurationList section */ 367 | }; 368 | rootObject = A296C3D62517BAFF005B03F2 /* Project object */; 369 | } 370 | -------------------------------------------------------------------------------- /RouterWithTriggerViews.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RouterWithTriggerViews.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /RouterWithTriggerViews.xcodeproj/xcshareddata/xcschemes/RouterWithTriggerViews.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | 28 | UIApplicationSupportsIndirectInputEvents 29 | 30 | UILaunchScreen 31 | 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/PresentedView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PresentedView.swift 3 | // RouterWithViewTriggers 4 | // 5 | // Created by Ihor Vovk on 26.09.2020. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct PresentedView: View { 11 | 12 | private let text: String 13 | private let router: PresentedRouter 14 | 15 | init(text: String, router: PresentedRouter) { 16 | self.text = text 17 | self.router = router 18 | } 19 | 20 | var body: some View { 21 | VStack { 22 | Button { 23 | router.dismiss() 24 | } label: { 25 | Text(text) 26 | .padding() 27 | } 28 | } 29 | } 30 | } 31 | 32 | struct PresentedView_Previews: PreviewProvider { 33 | static var previews: some View { 34 | PresentedView(text: "Text", router: BasePresentedRouter(isPresented: .constant(true))) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/PresentingRouter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PresentingRouter.swift 3 | // RouterWithTriggerViews 4 | // 5 | // Created by Ihor Vovk on 26.09.2020. 6 | // 7 | 8 | import SwiftUI 9 | 10 | class PresentingRouter: PresentingRouterProtocol { 11 | 12 | struct NavigationState { 13 | var presentingDetails = false 14 | } 15 | 16 | @Published var navigationState = NavigationState() 17 | 18 | func presentDetails(text: String, triggerView: @escaping () -> TV) -> AnyView { 19 | let destinationView = PresentedView(text: text, router: BasePresentedRouter(isPresented: binding(keyPath: \.presentingDetails))) 20 | return AnyView(SheetButton(isPresenting: binding(keyPath: \.presentingDetails), contentView: triggerView, destinationView: destinationView)) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/PresentingView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // RouterWithViewTriggers 4 | // 5 | // Created by Ihor Vovk on 20.09.2020. 6 | // 7 | 8 | import SwiftUI 9 | 10 | protocol PresentingRouterProtocol: NavigatingRouter { 11 | func presentDetails(text: String, triggerView: @escaping () -> TV) -> AnyView 12 | } 13 | 14 | struct PresentingView: View { 15 | 16 | @StateObject private var router: R 17 | 18 | init(router: R) { 19 | _router = StateObject(wrappedValue: router) 20 | } 21 | 22 | var body: some View { 23 | NavigationView { 24 | router.presentDetails(text: "Details") { 25 | Text("Present Details") 26 | .padding() 27 | } 28 | } 29 | } 30 | } 31 | 32 | struct PresentingView_Previews: PreviewProvider { 33 | static var previews: some View { 34 | PresentingView(router: PresentingRouter()) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Router/BasePresentedRouter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BasePresentedRouter.swift 3 | // RouterWithViewTriggers 4 | // 5 | // Created by Ihor Vovk on 26.09.2020. 6 | // 7 | 8 | import SwiftUI 9 | 10 | class BasePresentedRouter: PresentedRouter { 11 | 12 | let isPresented: Binding 13 | 14 | init(isPresented: Binding) { 15 | self.isPresented = isPresented 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Router/NavigatingRouter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigatingRouter.swift 3 | // RouterWithViewTriggers 4 | // 5 | // Created by Ihor Vovk on 26.09.2020. 6 | // 7 | 8 | import SwiftUI 9 | 10 | protocol NavigatingRouter: ObservableObject { 11 | associatedtype NavigationState 12 | var navigationState: NavigationState { get set } 13 | } 14 | 15 | extension NavigatingRouter { 16 | 17 | func binding(keyPath: WritableKeyPath) -> Binding { 18 | Binding(get: { self.navigationState[keyPath: keyPath] }, set: { self.navigationState[keyPath: keyPath] = $0 }) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Router/NavigationButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationButton.swift 3 | // RouterWithViewTriggers 4 | // 5 | // Created by Ihor Vovk on 26.09.2020. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct NavigationButton: View { 11 | 12 | @Binding var isPresenting: Bool 13 | 14 | var contentView: () -> CV 15 | var destinationView: DV 16 | 17 | var body: some View { 18 | Button(action: { 19 | self.isPresenting = true 20 | }) { 21 | contentView() 22 | }.background( 23 | NavigationLink(destination: destinationView, isActive: $isPresenting) { 24 | EmptyView() 25 | } 26 | ) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Router/PresentedRouter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PresentedRouter.swift 3 | // RouterWithViewTriggers 4 | // 5 | // Created by Ihor Vovk on 26.09.2020. 6 | // 7 | 8 | import SwiftUI 9 | 10 | protocol PresentedRouter { 11 | var isPresented: Binding { get } 12 | } 13 | 14 | extension PresentedRouter { 15 | 16 | func dismiss() { 17 | isPresented.wrappedValue = false 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/Router/SheetButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SheetButton.swift 3 | // RouterWithTriggerViews 4 | // 5 | // Created by Ihor Vovk on 26.09.2020. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct SheetButton: View { 11 | 12 | @Binding var isPresenting: Bool 13 | 14 | var contentView: () -> CV 15 | var destinationView: DV 16 | 17 | var body: some View { 18 | Button(action: { 19 | self.isPresenting = true 20 | }) { 21 | contentView() 22 | .sheet(isPresented: $isPresenting) { 23 | self.destinationView 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /RouterWithTriggerViews/RouterWithViewTriggersApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RouterWithViewTriggersApp.swift 3 | // RouterWithViewTriggers 4 | // 5 | // Created by Ihor Vovk on 20.09.2020. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct RouterWithViewTriggersApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | PresentingView(router: PresentingRouter()) 15 | } 16 | } 17 | } 18 | --------------------------------------------------------------------------------