├── .DS_Store ├── .gitattributes ├── .gitignore ├── CustomNavigations.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── CustomNavigations ├── .DS_Store ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── Extensions │ └── Color+Custom.swift ├── Info.plist ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json ├── SceneDelegate.swift └── Views │ ├── ContentView.swift │ ├── DestinationView.swift │ ├── Menu │ ├── MenuItem.swift │ ├── MenuRow.swift │ └── MenuView.swift │ ├── Modal │ ├── ModalTransitions.swift │ ├── ScalableShape.swift │ └── TransitionLink.swift │ └── PageView.swift ├── LICENSE └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fermoya/CustomNavigations/879d54ab2e6c66fb88d75c929f6d7e53ad3b1885/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /CustomNavigations.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 173602F723A8107A0060E16C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173602F623A8107A0060E16C /* AppDelegate.swift */; }; 11 | 173602F923A8107A0060E16C /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173602F823A8107A0060E16C /* SceneDelegate.swift */; }; 12 | 173602FB23A8107A0060E16C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173602FA23A8107A0060E16C /* ContentView.swift */; }; 13 | 173602FD23A8107C0060E16C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 173602FC23A8107C0060E16C /* Assets.xcassets */; }; 14 | 1736030023A8107C0060E16C /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 173602FF23A8107C0060E16C /* Preview Assets.xcassets */; }; 15 | 1736030323A8107C0060E16C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1736030123A8107C0060E16C /* LaunchScreen.storyboard */; }; 16 | 1736030E23A810D80060E16C /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1736030D23A810D80060E16C /* MenuView.swift */; }; 17 | 1736031023A819790060E16C /* MenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1736030F23A819790060E16C /* MenuItem.swift */; }; 18 | 1736031323A8367C0060E16C /* TransitionLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1736031223A8367C0060E16C /* TransitionLink.swift */; }; 19 | 6B29184F23BA297900D135B8 /* ScalableShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B29184E23BA297900D135B8 /* ScalableShape.swift */; }; 20 | 6B83FE7523C8AC8D00DFC270 /* DestinationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B83FE7423C8AC8D00DFC270 /* DestinationView.swift */; }; 21 | 6B83FE7823C8AD0300DFC270 /* PageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B83FE7723C8AD0300DFC270 /* PageView.swift */; }; 22 | 6B83FE7B23C8ADBE00DFC270 /* Color+Custom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B83FE7A23C8ADBE00DFC270 /* Color+Custom.swift */; }; 23 | 6B83FE7D23C8B12D00DFC270 /* ModalTransitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B83FE7C23C8B12D00DFC270 /* ModalTransitions.swift */; }; 24 | 6B83FE7F23C8B17000DFC270 /* MenuRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B83FE7E23C8B17000DFC270 /* MenuRow.swift */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 173602F323A8107A0060E16C /* CustomNavigations.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomNavigations.app; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 173602F623A8107A0060E16C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 30 | 173602F823A8107A0060E16C /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 31 | 173602FA23A8107A0060E16C /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 32 | 173602FC23A8107C0060E16C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 33 | 173602FF23A8107C0060E16C /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 34 | 1736030223A8107C0060E16C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 35 | 1736030423A8107C0060E16C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 1736030D23A810D80060E16C /* MenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuView.swift; sourceTree = ""; }; 37 | 1736030F23A819790060E16C /* MenuItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItem.swift; sourceTree = ""; }; 38 | 1736031223A8367C0060E16C /* TransitionLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransitionLink.swift; sourceTree = ""; }; 39 | 6B29184E23BA297900D135B8 /* ScalableShape.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScalableShape.swift; sourceTree = ""; }; 40 | 6B83FE7423C8AC8D00DFC270 /* DestinationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DestinationView.swift; sourceTree = ""; }; 41 | 6B83FE7723C8AD0300DFC270 /* PageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageView.swift; sourceTree = ""; }; 42 | 6B83FE7A23C8ADBE00DFC270 /* Color+Custom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Custom.swift"; sourceTree = ""; }; 43 | 6B83FE7C23C8B12D00DFC270 /* ModalTransitions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalTransitions.swift; sourceTree = ""; }; 44 | 6B83FE7E23C8B17000DFC270 /* MenuRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuRow.swift; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 173602F023A8107A0060E16C /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 173602EA23A8107A0060E16C = { 59 | isa = PBXGroup; 60 | children = ( 61 | 173602F523A8107A0060E16C /* CustomNavigations */, 62 | 173602F423A8107A0060E16C /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | 173602F423A8107A0060E16C /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 173602F323A8107A0060E16C /* CustomNavigations.app */, 70 | ); 71 | name = Products; 72 | sourceTree = ""; 73 | }; 74 | 173602F523A8107A0060E16C /* CustomNavigations */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 173602F623A8107A0060E16C /* AppDelegate.swift */, 78 | 173602F823A8107A0060E16C /* SceneDelegate.swift */, 79 | 173602FC23A8107C0060E16C /* Assets.xcassets */, 80 | 1736030123A8107C0060E16C /* LaunchScreen.storyboard */, 81 | 1736030423A8107C0060E16C /* Info.plist */, 82 | 173602FE23A8107C0060E16C /* Preview Content */, 83 | 6B83FE7623C8ACE300DFC270 /* Views */, 84 | 6B83FE7923C8ADA500DFC270 /* Extensions */, 85 | ); 86 | path = CustomNavigations; 87 | sourceTree = ""; 88 | }; 89 | 173602FE23A8107C0060E16C /* Preview Content */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 173602FF23A8107C0060E16C /* Preview Assets.xcassets */, 93 | ); 94 | path = "Preview Content"; 95 | sourceTree = ""; 96 | }; 97 | 1736030A23A810980060E16C /* Menu */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 1736030D23A810D80060E16C /* MenuView.swift */, 101 | 1736030F23A819790060E16C /* MenuItem.swift */, 102 | 6B83FE7E23C8B17000DFC270 /* MenuRow.swift */, 103 | ); 104 | path = Menu; 105 | sourceTree = ""; 106 | }; 107 | 1736031123A836100060E16C /* Modal */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 1736031223A8367C0060E16C /* TransitionLink.swift */, 111 | 6B29184E23BA297900D135B8 /* ScalableShape.swift */, 112 | 6B83FE7C23C8B12D00DFC270 /* ModalTransitions.swift */, 113 | ); 114 | path = Modal; 115 | sourceTree = ""; 116 | }; 117 | 6B83FE7623C8ACE300DFC270 /* Views */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 173602FA23A8107A0060E16C /* ContentView.swift */, 121 | 1736031123A836100060E16C /* Modal */, 122 | 1736030A23A810980060E16C /* Menu */, 123 | 6B83FE7423C8AC8D00DFC270 /* DestinationView.swift */, 124 | 6B83FE7723C8AD0300DFC270 /* PageView.swift */, 125 | ); 126 | path = Views; 127 | sourceTree = ""; 128 | }; 129 | 6B83FE7923C8ADA500DFC270 /* Extensions */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 6B83FE7A23C8ADBE00DFC270 /* Color+Custom.swift */, 133 | ); 134 | path = Extensions; 135 | sourceTree = ""; 136 | }; 137 | /* End PBXGroup section */ 138 | 139 | /* Begin PBXNativeTarget section */ 140 | 173602F223A8107A0060E16C /* CustomNavigations */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = 1736030723A8107C0060E16C /* Build configuration list for PBXNativeTarget "CustomNavigations" */; 143 | buildPhases = ( 144 | 173602EF23A8107A0060E16C /* Sources */, 145 | 173602F023A8107A0060E16C /* Frameworks */, 146 | 173602F123A8107A0060E16C /* Resources */, 147 | ); 148 | buildRules = ( 149 | ); 150 | dependencies = ( 151 | ); 152 | name = CustomNavigations; 153 | productName = CustomNavigations; 154 | productReference = 173602F323A8107A0060E16C /* CustomNavigations.app */; 155 | productType = "com.apple.product-type.application"; 156 | }; 157 | /* End PBXNativeTarget section */ 158 | 159 | /* Begin PBXProject section */ 160 | 173602EB23A8107A0060E16C /* Project object */ = { 161 | isa = PBXProject; 162 | attributes = { 163 | LastSwiftUpdateCheck = 1120; 164 | LastUpgradeCheck = 1120; 165 | ORGANIZATIONNAME = "Fernando Moya de Rivas"; 166 | TargetAttributes = { 167 | 173602F223A8107A0060E16C = { 168 | CreatedOnToolsVersion = 11.2.1; 169 | }; 170 | }; 171 | }; 172 | buildConfigurationList = 173602EE23A8107A0060E16C /* Build configuration list for PBXProject "CustomNavigations" */; 173 | compatibilityVersion = "Xcode 9.3"; 174 | developmentRegion = en; 175 | hasScannedForEncodings = 0; 176 | knownRegions = ( 177 | en, 178 | Base, 179 | ); 180 | mainGroup = 173602EA23A8107A0060E16C; 181 | productRefGroup = 173602F423A8107A0060E16C /* Products */; 182 | projectDirPath = ""; 183 | projectRoot = ""; 184 | targets = ( 185 | 173602F223A8107A0060E16C /* CustomNavigations */, 186 | ); 187 | }; 188 | /* End PBXProject section */ 189 | 190 | /* Begin PBXResourcesBuildPhase section */ 191 | 173602F123A8107A0060E16C /* Resources */ = { 192 | isa = PBXResourcesBuildPhase; 193 | buildActionMask = 2147483647; 194 | files = ( 195 | 1736030323A8107C0060E16C /* LaunchScreen.storyboard in Resources */, 196 | 1736030023A8107C0060E16C /* Preview Assets.xcassets in Resources */, 197 | 173602FD23A8107C0060E16C /* Assets.xcassets in Resources */, 198 | ); 199 | runOnlyForDeploymentPostprocessing = 0; 200 | }; 201 | /* End PBXResourcesBuildPhase section */ 202 | 203 | /* Begin PBXSourcesBuildPhase section */ 204 | 173602EF23A8107A0060E16C /* Sources */ = { 205 | isa = PBXSourcesBuildPhase; 206 | buildActionMask = 2147483647; 207 | files = ( 208 | 6B83FE7B23C8ADBE00DFC270 /* Color+Custom.swift in Sources */, 209 | 6B29184F23BA297900D135B8 /* ScalableShape.swift in Sources */, 210 | 173602F723A8107A0060E16C /* AppDelegate.swift in Sources */, 211 | 1736030E23A810D80060E16C /* MenuView.swift in Sources */, 212 | 173602F923A8107A0060E16C /* SceneDelegate.swift in Sources */, 213 | 6B83FE7F23C8B17000DFC270 /* MenuRow.swift in Sources */, 214 | 6B83FE7823C8AD0300DFC270 /* PageView.swift in Sources */, 215 | 173602FB23A8107A0060E16C /* ContentView.swift in Sources */, 216 | 6B83FE7D23C8B12D00DFC270 /* ModalTransitions.swift in Sources */, 217 | 6B83FE7523C8AC8D00DFC270 /* DestinationView.swift in Sources */, 218 | 1736031323A8367C0060E16C /* TransitionLink.swift in Sources */, 219 | 1736031023A819790060E16C /* MenuItem.swift in Sources */, 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | /* End PBXSourcesBuildPhase section */ 224 | 225 | /* Begin PBXVariantGroup section */ 226 | 1736030123A8107C0060E16C /* LaunchScreen.storyboard */ = { 227 | isa = PBXVariantGroup; 228 | children = ( 229 | 1736030223A8107C0060E16C /* Base */, 230 | ); 231 | name = LaunchScreen.storyboard; 232 | sourceTree = ""; 233 | }; 234 | /* End PBXVariantGroup section */ 235 | 236 | /* Begin XCBuildConfiguration section */ 237 | 1736030523A8107C0060E16C /* Debug */ = { 238 | isa = XCBuildConfiguration; 239 | buildSettings = { 240 | ALWAYS_SEARCH_USER_PATHS = NO; 241 | CLANG_ANALYZER_NONNULL = YES; 242 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 243 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 244 | CLANG_CXX_LIBRARY = "libc++"; 245 | CLANG_ENABLE_MODULES = YES; 246 | CLANG_ENABLE_OBJC_ARC = YES; 247 | CLANG_ENABLE_OBJC_WEAK = YES; 248 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 249 | CLANG_WARN_BOOL_CONVERSION = YES; 250 | CLANG_WARN_COMMA = YES; 251 | CLANG_WARN_CONSTANT_CONVERSION = YES; 252 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 253 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 254 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 255 | CLANG_WARN_EMPTY_BODY = YES; 256 | CLANG_WARN_ENUM_CONVERSION = YES; 257 | CLANG_WARN_INFINITE_RECURSION = YES; 258 | CLANG_WARN_INT_CONVERSION = YES; 259 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 260 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 261 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 262 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 263 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 264 | CLANG_WARN_STRICT_PROTOTYPES = YES; 265 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 266 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 267 | CLANG_WARN_UNREACHABLE_CODE = YES; 268 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 269 | COPY_PHASE_STRIP = NO; 270 | DEBUG_INFORMATION_FORMAT = dwarf; 271 | ENABLE_STRICT_OBJC_MSGSEND = YES; 272 | ENABLE_TESTABILITY = YES; 273 | GCC_C_LANGUAGE_STANDARD = gnu11; 274 | GCC_DYNAMIC_NO_PIC = NO; 275 | GCC_NO_COMMON_BLOCKS = YES; 276 | GCC_OPTIMIZATION_LEVEL = 0; 277 | GCC_PREPROCESSOR_DEFINITIONS = ( 278 | "DEBUG=1", 279 | "$(inherited)", 280 | ); 281 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 282 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 283 | GCC_WARN_UNDECLARED_SELECTOR = YES; 284 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 285 | GCC_WARN_UNUSED_FUNCTION = YES; 286 | GCC_WARN_UNUSED_VARIABLE = YES; 287 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 288 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 289 | MTL_FAST_MATH = YES; 290 | ONLY_ACTIVE_ARCH = YES; 291 | SDKROOT = iphoneos; 292 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 293 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 294 | }; 295 | name = Debug; 296 | }; 297 | 1736030623A8107C0060E16C /* Release */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ALWAYS_SEARCH_USER_PATHS = NO; 301 | CLANG_ANALYZER_NONNULL = YES; 302 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 303 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 304 | CLANG_CXX_LIBRARY = "libc++"; 305 | CLANG_ENABLE_MODULES = YES; 306 | CLANG_ENABLE_OBJC_ARC = YES; 307 | CLANG_ENABLE_OBJC_WEAK = YES; 308 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 309 | CLANG_WARN_BOOL_CONVERSION = YES; 310 | CLANG_WARN_COMMA = YES; 311 | CLANG_WARN_CONSTANT_CONVERSION = YES; 312 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 313 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 314 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 315 | CLANG_WARN_EMPTY_BODY = YES; 316 | CLANG_WARN_ENUM_CONVERSION = YES; 317 | CLANG_WARN_INFINITE_RECURSION = YES; 318 | CLANG_WARN_INT_CONVERSION = YES; 319 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 320 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 321 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 322 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 323 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 324 | CLANG_WARN_STRICT_PROTOTYPES = YES; 325 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 326 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 327 | CLANG_WARN_UNREACHABLE_CODE = YES; 328 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 329 | COPY_PHASE_STRIP = NO; 330 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 331 | ENABLE_NS_ASSERTIONS = NO; 332 | ENABLE_STRICT_OBJC_MSGSEND = YES; 333 | GCC_C_LANGUAGE_STANDARD = gnu11; 334 | GCC_NO_COMMON_BLOCKS = YES; 335 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 336 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 337 | GCC_WARN_UNDECLARED_SELECTOR = YES; 338 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 339 | GCC_WARN_UNUSED_FUNCTION = YES; 340 | GCC_WARN_UNUSED_VARIABLE = YES; 341 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 342 | MTL_ENABLE_DEBUG_INFO = NO; 343 | MTL_FAST_MATH = YES; 344 | SDKROOT = iphoneos; 345 | SWIFT_COMPILATION_MODE = wholemodule; 346 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 347 | VALIDATE_PRODUCT = YES; 348 | }; 349 | name = Release; 350 | }; 351 | 1736030823A8107C0060E16C /* Debug */ = { 352 | isa = XCBuildConfiguration; 353 | buildSettings = { 354 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 355 | CODE_SIGN_STYLE = Automatic; 356 | DEVELOPMENT_ASSET_PATHS = "\"CustomNavigations/Preview Content\""; 357 | DEVELOPMENT_TEAM = LPBB5C5CRP; 358 | ENABLE_PREVIEWS = YES; 359 | INFOPLIST_FILE = CustomNavigations/Info.plist; 360 | LD_RUNPATH_SEARCH_PATHS = ( 361 | "$(inherited)", 362 | "@executable_path/Frameworks", 363 | ); 364 | PRODUCT_BUNDLE_IDENTIFIER = com.fermoya.challenge.CustomNavigations; 365 | PRODUCT_NAME = "$(TARGET_NAME)"; 366 | SWIFT_VERSION = 5.0; 367 | TARGETED_DEVICE_FAMILY = "1,2"; 368 | }; 369 | name = Debug; 370 | }; 371 | 1736030923A8107C0060E16C /* Release */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 375 | CODE_SIGN_STYLE = Automatic; 376 | DEVELOPMENT_ASSET_PATHS = "\"CustomNavigations/Preview Content\""; 377 | DEVELOPMENT_TEAM = LPBB5C5CRP; 378 | ENABLE_PREVIEWS = YES; 379 | INFOPLIST_FILE = CustomNavigations/Info.plist; 380 | LD_RUNPATH_SEARCH_PATHS = ( 381 | "$(inherited)", 382 | "@executable_path/Frameworks", 383 | ); 384 | PRODUCT_BUNDLE_IDENTIFIER = com.fermoya.challenge.CustomNavigations; 385 | PRODUCT_NAME = "$(TARGET_NAME)"; 386 | SWIFT_VERSION = 5.0; 387 | TARGETED_DEVICE_FAMILY = "1,2"; 388 | }; 389 | name = Release; 390 | }; 391 | /* End XCBuildConfiguration section */ 392 | 393 | /* Begin XCConfigurationList section */ 394 | 173602EE23A8107A0060E16C /* Build configuration list for PBXProject "CustomNavigations" */ = { 395 | isa = XCConfigurationList; 396 | buildConfigurations = ( 397 | 1736030523A8107C0060E16C /* Debug */, 398 | 1736030623A8107C0060E16C /* Release */, 399 | ); 400 | defaultConfigurationIsVisible = 0; 401 | defaultConfigurationName = Release; 402 | }; 403 | 1736030723A8107C0060E16C /* Build configuration list for PBXNativeTarget "CustomNavigations" */ = { 404 | isa = XCConfigurationList; 405 | buildConfigurations = ( 406 | 1736030823A8107C0060E16C /* Debug */, 407 | 1736030923A8107C0060E16C /* Release */, 408 | ); 409 | defaultConfigurationIsVisible = 0; 410 | defaultConfigurationName = Release; 411 | }; 412 | /* End XCConfigurationList section */ 413 | }; 414 | rootObject = 173602EB23A8107A0060E16C /* Project object */; 415 | } 416 | -------------------------------------------------------------------------------- /CustomNavigations.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CustomNavigations.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CustomNavigations/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fermoya/CustomNavigations/879d54ab2e6c66fb88d75c929f6d7e53ad3b1885/CustomNavigations/.DS_Store -------------------------------------------------------------------------------- /CustomNavigations/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 16/12/2019. 6 | // Copyright © 2019 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /CustomNavigations/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /CustomNavigations/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CustomNavigations/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CustomNavigations/Extensions/Color+Custom.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Color+Custom.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 10/01/2020. 6 | // Copyright © 2020 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | extension Color { 12 | 13 | static var lightGray: Color { 14 | Color(.sRGB, red: 0.88, green: 0.88, blue: 0.88, opacity: 1) 15 | } 16 | 17 | static var lightYellow: Color { 18 | Color(.sRGB, red: 1, green: 0.97, blue: 0.79, opacity: 1) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CustomNavigations/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 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /CustomNavigations/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CustomNavigations/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 16/12/2019. 6 | // Copyright © 2019 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | 12 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 18 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 19 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 20 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 21 | 22 | // Create the SwiftUI view that provides the window contents. 23 | UITableView.appearance().tableFooterView = UIView() 24 | let contentView = ContentView() 25 | 26 | // Use a UIHostingController as window root view controller. 27 | if let windowScene = scene as? UIWindowScene { 28 | let window = UIWindow(windowScene: windowScene) 29 | window.rootViewController = UIHostingController(rootView: contentView) 30 | self.window = window 31 | window.makeKeyAndVisible() 32 | } 33 | } 34 | 35 | func sceneDidDisconnect(_ scene: UIScene) { 36 | // Called as the scene is being released by the system. 37 | // This occurs shortly after the scene enters the background, or when its session is discarded. 38 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 39 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 40 | } 41 | 42 | func sceneDidBecomeActive(_ scene: UIScene) { 43 | // Called when the scene has moved from an inactive state to an active state. 44 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 45 | } 46 | 47 | func sceneWillResignActive(_ scene: UIScene) { 48 | // Called when the scene will move from an active state to an inactive state. 49 | // This may occur due to temporary interruptions (ex. an incoming phone call). 50 | } 51 | 52 | func sceneWillEnterForeground(_ scene: UIScene) { 53 | // Called as the scene transitions from the background to the foreground. 54 | // Use this method to undo the changes made on entering the background. 55 | } 56 | 57 | func sceneDidEnterBackground(_ scene: UIScene) { 58 | // Called as the scene transitions from the foreground to the background. 59 | // Use this method to save data, release shared resources, and store enough scene-specific state information 60 | // to restore the scene back to its current state. 61 | } 62 | 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /CustomNavigations/Views/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 16/12/2019. 6 | // Copyright © 2019 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ContentView: View { 12 | 13 | @State var index = 0 14 | @State var isMenuHidden = true 15 | @State var isPresented = false 16 | 17 | var body: some View { 18 | NavigationView { 19 | MenuView(indexSelected: self.$index, 20 | isMenuHidden: self.$isMenuHidden, 21 | menuItems: menuItems, 22 | menuItemRow: { MenuRow(item: $0) }, 23 | menuItemContent: { section in 24 | PageView(section: section, isPresented: self.$isPresented) 25 | .navigationBarItems(leading: self.menuButton) 26 | .navigationBarTitle(Text("Section \(section + 1)"), displayMode: .inline) 27 | .modalLink(isPresented: self.$isPresented, 28 | linkType: section % 2 == 0 ? ModalTransition.circleReveal : ModalTransition.fullScreenModal, 29 | destination: { 30 | DestinationView() 31 | .navigationBarItems(leading: self.closeButton) 32 | .navigationBarTitle(section % 2 == 1 ? "Full screen" : "Reveal screen", displayMode: .inline) 33 | }) 34 | }) 35 | } 36 | } 37 | } 38 | 39 | extension ContentView { 40 | 41 | private var closeButton: some View { 42 | Button(action: { 43 | withAnimation { 44 | self.isPresented.toggle() 45 | } 46 | }) { 47 | Image(systemName: "xmark") 48 | .padding(8) 49 | } 50 | } 51 | 52 | var menuButton: some View { 53 | Button(action: { 54 | withAnimation { 55 | self.isMenuHidden.toggle() 56 | } 57 | }) { 58 | Image(systemName: self.isMenuHidden ? "list.bullet" : "xmark" ) 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /CustomNavigations/Views/DestinationView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DestinationView.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 10/01/2020. 6 | // Copyright © 2020 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct DestinationView: View { 12 | 13 | var body: some View { 14 | ZStack { 15 | Rectangle() 16 | .fill(Color.lightYellow) 17 | VStack(alignment: .leading) { 18 | HStack { 19 | Text("I've been presented") 20 | Spacer() 21 | } 22 | NavigationLink(destination: Text("Pushed")) { 23 | Text("Tap to push") 24 | } 25 | } 26 | .padding(.horizontal) 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /CustomNavigations/Views/Menu/MenuItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MenuItem.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 16/12/2019. 6 | // Copyright © 2019 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct MenuItem: Identifiable, Equatable { 12 | 13 | enum Kind { 14 | case text 15 | case image 16 | } 17 | 18 | var id: String { return name } 19 | var name: String 20 | var kind: Kind 21 | } 22 | 23 | let menuItems: [MenuItem] = [ 24 | MenuItem(name: "Setion 1", kind: .text), 25 | MenuItem(name: "Setion 2", kind: .text), 26 | MenuItem(name: "Setion 3", kind: .image), 27 | MenuItem(name: "Setion 4", kind: .text), 28 | MenuItem(name: "Setion 5", kind: .image), 29 | MenuItem(name: "Setion 6", kind: .text) 30 | ] 31 | -------------------------------------------------------------------------------- /CustomNavigations/Views/Menu/MenuRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MenuRow.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 10/01/2020. 6 | // Copyright © 2020 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct MenuRow: View { 12 | 13 | var item: MenuItem 14 | 15 | var body: some View { 16 | Group { 17 | if item.kind == .text { 18 | Text("\(item.name)") 19 | } else { 20 | HStack { 21 | Image(systemName: "star.fill") 22 | Text("\(item.name) looks different") 23 | } 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CustomNavigations/Views/Menu/MenuView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MenuView.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 16/12/2019. 6 | // Copyright © 2019 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct MenuView: View where Item: Identifiable & Equatable, Row: View, Content: View { 12 | 13 | @Binding private var isMenuRevealed: Bool 14 | @State private var draggingOffset: CGFloat = 0 15 | 16 | @Binding var indexSelected: Int 17 | var menuItems: [Item] 18 | var menuItemRow: (Item) -> Row 19 | var menuItemContent: (Int) -> Content 20 | var revealRatio: CGFloat 21 | 22 | init(indexSelected: Binding, isMenuHidden: Binding, menuItems: [Item], revealRatio: CGFloat = 0.8, @ViewBuilder menuItemRow: @escaping (Item) -> Row, @ViewBuilder menuItemContent: @escaping (Int) -> Content) { 23 | self._indexSelected = indexSelected 24 | self._isMenuRevealed = isMenuHidden 25 | self.menuItems = menuItems 26 | self.revealRatio = revealRatio 27 | self.menuItemRow = menuItemRow 28 | self.menuItemContent = menuItemContent 29 | } 30 | 31 | var body: some View { 32 | GeometryReader { proxy in 33 | ZStack { 34 | self.contentView 35 | .onTapGesture (perform: { 36 | withAnimation { 37 | self.isMenuRevealed = true 38 | } 39 | }) 40 | self.revealList 41 | .frame(width: self.revealListSize(proxy).width) 42 | .offset(x: self.revealListOffset(proxy).x, 43 | y: 0) 44 | }.gesture(DragGesture() 45 | .onChanged({ value in 46 | withAnimation { 47 | self.draggingOffset = self.isMenuRevealed ? max(0, min(self.revealListSize(proxy).width, value.translation.width)) : min(0, max(-self.revealListSize(proxy).width, value.translation.width)) 48 | } 49 | }).onEnded({ _ in 50 | withAnimation { 51 | if abs(self.draggingOffset) > self.revealListSize(proxy).width / 2 { 52 | self.isMenuRevealed.toggle() 53 | } 54 | self.draggingOffset = 0 55 | } 56 | })) 57 | } 58 | } 59 | } 60 | 61 | extension MenuView { 62 | 63 | private func revealListOffset(_ proxy: GeometryProxy) -> CGPoint { 64 | let hiddenOffset = -proxy.size.width * ((1 - revealRatio) * 0.5 + revealRatio) + draggingOffset 65 | return CGPoint(x: self.isMenuRevealed ? hiddenOffset : hiddenOffset + revealListSize(proxy).width, 66 | y: 0) 67 | } 68 | 69 | private func revealListSize(_ proxy: GeometryProxy) -> CGSize { 70 | CGSize(width: revealRatio * proxy.size.width, 71 | height: proxy.size.height) 72 | } 73 | } 74 | 75 | extension MenuView { 76 | 77 | private var contentView: some View { 78 | menuItemContent(indexSelected) 79 | } 80 | 81 | private var revealList: some View { 82 | List { 83 | ForEach(menuItems) { item in 84 | self.menuItemRow(item) 85 | .onTapGesture (perform: { 86 | withAnimation { 87 | self.isMenuRevealed = true 88 | self.indexSelected = self.menuItems.firstIndex(of: item)! 89 | } 90 | }) 91 | } 92 | } 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /CustomNavigations/Views/Modal/ModalTransitions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ModalTransitions.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 10/01/2020. 6 | // Copyright © 2020 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | enum ModalTransition: TransitionLinkType { 12 | case circleReveal 13 | case fullScreenModal 14 | case scale 15 | 16 | var transition: AnyTransition { 17 | switch self { 18 | case .circleReveal: 19 | return .reveal(shape: ScalableCircle.self) 20 | case .fullScreenModal: 21 | return .move(edge: .bottom) 22 | case .scale: 23 | return .scale(scale: 0) 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CustomNavigations/Views/Modal/ScalableShape.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScalableShape.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 30/12/2019. 6 | // Copyright © 2019 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | protocol ScalableShape: Shape { 12 | init(animatableData: CGFloat) 13 | var animatableData: CGFloat { get } 14 | } 15 | 16 | struct ScalableCircle: ScalableShape { 17 | var animatableData: CGFloat = 1 18 | 19 | func path(in rect: CGRect) -> Path { 20 | let hypotenuse = sqrt(rect.width * rect.width + rect.height * rect.height) 21 | let radius = hypotenuse * animatableData 22 | let center = CGPoint(x: rect.midX, 23 | y: rect.midY) 24 | 25 | var path = Path() 26 | path.addArc(center: center, 27 | radius: radius, 28 | startAngle: .degrees(0), 29 | endAngle: .degrees(360), 30 | clockwise: false) 31 | 32 | return path 33 | } 34 | } 35 | 36 | struct ClipShapeModifier: ViewModifier { 37 | let shape: T 38 | 39 | func body(content: Content) -> some View { 40 | content.clipShape(shape) 41 | } 42 | } 43 | 44 | extension AnyTransition { 45 | static func reveal (shape: T.Type) -> AnyTransition { 46 | .modifier( 47 | active: ClipShapeModifier(shape: T(animatableData: 0)), 48 | identity: ClipShapeModifier(shape: T(animatableData: 1)) 49 | ) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /CustomNavigations/Views/Modal/TransitionLink.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FullScreenLink.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 16/12/2019. 6 | // Copyright © 2019 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | protocol TransitionLinkType { 12 | var transition: AnyTransition { get } 13 | } 14 | 15 | struct TransitionLink: View where Content: View, Destination: View { 16 | 17 | @Binding var isPresented: Bool 18 | var content: () -> Content 19 | var destination: () -> Destination 20 | var linkType: TransitionLinkType 21 | 22 | init(isPresented: Binding, linkType: TransitionLinkType, @ViewBuilder destination: @escaping () -> Destination, @ViewBuilder content: @escaping () -> Content) { 23 | self.content = content 24 | self.destination = destination 25 | self._isPresented = isPresented 26 | self.linkType = linkType 27 | } 28 | 29 | var body: some View { 30 | ZStack { 31 | if self.isPresented { 32 | self.destination() 33 | .transition(self.linkType.transition) 34 | } else { 35 | self.content() 36 | } 37 | } 38 | } 39 | } 40 | 41 | struct ModaLinkViewModifier: ViewModifier where Destination: View { 42 | 43 | @Binding var isPresented: Bool 44 | var linkType: TransitionLinkType 45 | var destination: () -> Destination 46 | 47 | func body(content: Self.Content) -> some View { 48 | TransitionLink(isPresented: self.$isPresented, 49 | linkType: linkType, 50 | destination: { 51 | self.destination() 52 | }, content: { 53 | content 54 | }) 55 | } 56 | 57 | } 58 | 59 | extension View { 60 | 61 | func modalLink(isPresented: Binding, 62 | linkType: TransitionLinkType, 63 | destination: @escaping () -> Destination) -> some View { 64 | self.modifier(ModaLinkViewModifier(isPresented: isPresented, 65 | linkType: linkType, 66 | destination: destination)) 67 | } 68 | 69 | } 70 | 71 | //struct FullScreenLink_Previews: PreviewProvider { 72 | // static var previews: some View { 73 | // FullScreenLink() 74 | // } 75 | //} 76 | -------------------------------------------------------------------------------- /CustomNavigations/Views/PageView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PushedView.swift 3 | // CustomNavigations 4 | // 5 | // Created by Fernando Moya de Rivas on 10/01/2020. 6 | // Copyright © 2020 Fernando Moya de Rivas. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct PageView: View { 12 | 13 | var section: Int 14 | @Binding var isPresented: Bool 15 | 16 | var body: some View { 17 | ZStack { 18 | Rectangle() 19 | .fill(Color.lightGray) 20 | VStack { 21 | Spacer() 22 | Text("You're on section \(section + 1)") 23 | .font(.system(size: 23)) 24 | .bold() 25 | Spacer() 26 | HStack { 27 | Spacer() 28 | Text("Swipe right to open menu. Tap anywhere to close.") 29 | Spacer() 30 | } 31 | Spacer() 32 | NavigationLink(destination: Text("pushed"), label: { 33 | Text("Tap to push") 34 | }) 35 | Spacer() 36 | Button(action: { 37 | withAnimation { 38 | self.isPresented.toggle() 39 | } 40 | }) { 41 | Text("Tap me to present full screen modal") 42 | } 43 | Spacer() 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 fermoya 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 | # CustomNavigations 2 | 3 | --------------------------------------------------------------------------------