├── .gitignore ├── MTSlideToOpen-SwiftUI ├── MTSlideToOpen-SwiftUI.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── MTSlideToOpen-SwiftUI │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── ic_arrow.imageset │ │ ├── Contents.json │ │ └── ic_arrow.png │ ├── Base.lproj │ └── LaunchScreen.storyboard │ ├── ContentView.swift │ ├── Info.plist │ ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json │ ├── SceneDelegate.swift │ └── Source │ └── MTSlideToOpen-SwiftUI.swift ├── README.md └── example.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | # 51 | # Add this line if you want to avoid checking in source code from the Xcode workspace 52 | # *.xcworkspace 53 | 54 | # Carthage 55 | # 56 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 57 | # Carthage/Checkouts 58 | 59 | Carthage/Build 60 | 61 | # Accio dependency management 62 | Dependencies/ 63 | .accio/ 64 | 65 | # fastlane 66 | # 67 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 68 | # screenshots whenever they are needed. 69 | # For more information about the recommended setup visit: 70 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 71 | 72 | fastlane/report.xml 73 | fastlane/Preview.html 74 | fastlane/screenshots/**/*.png 75 | fastlane/test_output 76 | 77 | # Code Injection 78 | # 79 | # After new code Injection tools there's a generated folder /iOSInjectionProject 80 | # https://github.com/johnno1962/injectionforxcode 81 | 82 | iOSInjectionProject/ -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9DB1748E22F91BBE0078058C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DB1748D22F91BBE0078058C /* AppDelegate.swift */; }; 11 | 9DB1749022F91BBE0078058C /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DB1748F22F91BBE0078058C /* SceneDelegate.swift */; }; 12 | 9DB1749222F91BBE0078058C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DB1749122F91BBE0078058C /* ContentView.swift */; }; 13 | 9DB1749422F91BC00078058C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9DB1749322F91BC00078058C /* Assets.xcassets */; }; 14 | 9DB1749722F91BC00078058C /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9DB1749622F91BC00078058C /* Preview Assets.xcassets */; }; 15 | 9DB1749A22F91BC00078058C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9DB1749822F91BC00078058C /* LaunchScreen.storyboard */; }; 16 | 9DB174A322F91BE10078058C /* MTSlideToOpen-SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DB174A222F91BE10078058C /* MTSlideToOpen-SwiftUI.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 9DB1748A22F91BBE0078058C /* MTSlideToOpen-SwiftUI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MTSlideToOpen-SwiftUI.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 9DB1748D22F91BBE0078058C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 9DB1748F22F91BBE0078058C /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 23 | 9DB1749122F91BBE0078058C /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 24 | 9DB1749322F91BC00078058C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 9DB1749622F91BC00078058C /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 26 | 9DB1749922F91BC00078058C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | 9DB1749B22F91BC00078058C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | 9DB174A222F91BE10078058C /* MTSlideToOpen-SwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MTSlideToOpen-SwiftUI.swift"; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 9DB1748722F91BBE0078058C /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 9DB1748122F91BBE0078058C = { 43 | isa = PBXGroup; 44 | children = ( 45 | 9DB1748C22F91BBE0078058C /* MTSlideToOpen-SwiftUI */, 46 | 9DB1748B22F91BBE0078058C /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 9DB1748B22F91BBE0078058C /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 9DB1748A22F91BBE0078058C /* MTSlideToOpen-SwiftUI.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 9DB1748C22F91BBE0078058C /* MTSlideToOpen-SwiftUI */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 9DB174A122F91BC70078058C /* Source */, 62 | 9DB1748D22F91BBE0078058C /* AppDelegate.swift */, 63 | 9DB1748F22F91BBE0078058C /* SceneDelegate.swift */, 64 | 9DB1749122F91BBE0078058C /* ContentView.swift */, 65 | 9DB1749322F91BC00078058C /* Assets.xcassets */, 66 | 9DB1749822F91BC00078058C /* LaunchScreen.storyboard */, 67 | 9DB1749B22F91BC00078058C /* Info.plist */, 68 | 9DB1749522F91BC00078058C /* Preview Content */, 69 | ); 70 | path = "MTSlideToOpen-SwiftUI"; 71 | sourceTree = ""; 72 | }; 73 | 9DB1749522F91BC00078058C /* Preview Content */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 9DB1749622F91BC00078058C /* Preview Assets.xcassets */, 77 | ); 78 | path = "Preview Content"; 79 | sourceTree = ""; 80 | }; 81 | 9DB174A122F91BC70078058C /* Source */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 9DB174A222F91BE10078058C /* MTSlideToOpen-SwiftUI.swift */, 85 | ); 86 | path = Source; 87 | sourceTree = ""; 88 | }; 89 | /* End PBXGroup section */ 90 | 91 | /* Begin PBXNativeTarget section */ 92 | 9DB1748922F91BBE0078058C /* MTSlideToOpen-SwiftUI */ = { 93 | isa = PBXNativeTarget; 94 | buildConfigurationList = 9DB1749E22F91BC00078058C /* Build configuration list for PBXNativeTarget "MTSlideToOpen-SwiftUI" */; 95 | buildPhases = ( 96 | 9DB1748622F91BBE0078058C /* Sources */, 97 | 9DB1748722F91BBE0078058C /* Frameworks */, 98 | 9DB1748822F91BBE0078058C /* Resources */, 99 | ); 100 | buildRules = ( 101 | ); 102 | dependencies = ( 103 | ); 104 | name = "MTSlideToOpen-SwiftUI"; 105 | productName = "MTSlideToOpen-SwiftUI"; 106 | productReference = 9DB1748A22F91BBE0078058C /* MTSlideToOpen-SwiftUI.app */; 107 | productType = "com.apple.product-type.application"; 108 | }; 109 | /* End PBXNativeTarget section */ 110 | 111 | /* Begin PBXProject section */ 112 | 9DB1748222F91BBE0078058C /* Project object */ = { 113 | isa = PBXProject; 114 | attributes = { 115 | LastSwiftUpdateCheck = 1100; 116 | LastUpgradeCheck = 1100; 117 | ORGANIZATIONNAME = io.tienle; 118 | TargetAttributes = { 119 | 9DB1748922F91BBE0078058C = { 120 | CreatedOnToolsVersion = 11.0; 121 | }; 122 | }; 123 | }; 124 | buildConfigurationList = 9DB1748522F91BBE0078058C /* Build configuration list for PBXProject "MTSlideToOpen-SwiftUI" */; 125 | compatibilityVersion = "Xcode 9.3"; 126 | developmentRegion = en; 127 | hasScannedForEncodings = 0; 128 | knownRegions = ( 129 | en, 130 | Base, 131 | ); 132 | mainGroup = 9DB1748122F91BBE0078058C; 133 | productRefGroup = 9DB1748B22F91BBE0078058C /* Products */; 134 | projectDirPath = ""; 135 | projectRoot = ""; 136 | targets = ( 137 | 9DB1748922F91BBE0078058C /* MTSlideToOpen-SwiftUI */, 138 | ); 139 | }; 140 | /* End PBXProject section */ 141 | 142 | /* Begin PBXResourcesBuildPhase section */ 143 | 9DB1748822F91BBE0078058C /* Resources */ = { 144 | isa = PBXResourcesBuildPhase; 145 | buildActionMask = 2147483647; 146 | files = ( 147 | 9DB1749A22F91BC00078058C /* LaunchScreen.storyboard in Resources */, 148 | 9DB1749722F91BC00078058C /* Preview Assets.xcassets in Resources */, 149 | 9DB1749422F91BC00078058C /* Assets.xcassets in Resources */, 150 | ); 151 | runOnlyForDeploymentPostprocessing = 0; 152 | }; 153 | /* End PBXResourcesBuildPhase section */ 154 | 155 | /* Begin PBXSourcesBuildPhase section */ 156 | 9DB1748622F91BBE0078058C /* Sources */ = { 157 | isa = PBXSourcesBuildPhase; 158 | buildActionMask = 2147483647; 159 | files = ( 160 | 9DB1748E22F91BBE0078058C /* AppDelegate.swift in Sources */, 161 | 9DB174A322F91BE10078058C /* MTSlideToOpen-SwiftUI.swift in Sources */, 162 | 9DB1749022F91BBE0078058C /* SceneDelegate.swift in Sources */, 163 | 9DB1749222F91BBE0078058C /* ContentView.swift in Sources */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXSourcesBuildPhase section */ 168 | 169 | /* Begin PBXVariantGroup section */ 170 | 9DB1749822F91BC00078058C /* LaunchScreen.storyboard */ = { 171 | isa = PBXVariantGroup; 172 | children = ( 173 | 9DB1749922F91BC00078058C /* Base */, 174 | ); 175 | name = LaunchScreen.storyboard; 176 | sourceTree = ""; 177 | }; 178 | /* End PBXVariantGroup section */ 179 | 180 | /* Begin XCBuildConfiguration section */ 181 | 9DB1749C22F91BC00078058C /* Debug */ = { 182 | isa = XCBuildConfiguration; 183 | buildSettings = { 184 | ALWAYS_SEARCH_USER_PATHS = NO; 185 | CLANG_ANALYZER_NONNULL = YES; 186 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 187 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 188 | CLANG_CXX_LIBRARY = "libc++"; 189 | CLANG_ENABLE_MODULES = YES; 190 | CLANG_ENABLE_OBJC_ARC = YES; 191 | CLANG_ENABLE_OBJC_WEAK = YES; 192 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 193 | CLANG_WARN_BOOL_CONVERSION = YES; 194 | CLANG_WARN_COMMA = YES; 195 | CLANG_WARN_CONSTANT_CONVERSION = YES; 196 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 197 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 198 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 199 | CLANG_WARN_EMPTY_BODY = YES; 200 | CLANG_WARN_ENUM_CONVERSION = YES; 201 | CLANG_WARN_INFINITE_RECURSION = YES; 202 | CLANG_WARN_INT_CONVERSION = YES; 203 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 204 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 205 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 206 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 207 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 208 | CLANG_WARN_STRICT_PROTOTYPES = YES; 209 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 210 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 211 | CLANG_WARN_UNREACHABLE_CODE = YES; 212 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 213 | COPY_PHASE_STRIP = NO; 214 | DEBUG_INFORMATION_FORMAT = dwarf; 215 | ENABLE_STRICT_OBJC_MSGSEND = YES; 216 | ENABLE_TESTABILITY = YES; 217 | GCC_C_LANGUAGE_STANDARD = gnu11; 218 | GCC_DYNAMIC_NO_PIC = NO; 219 | GCC_NO_COMMON_BLOCKS = YES; 220 | GCC_OPTIMIZATION_LEVEL = 0; 221 | GCC_PREPROCESSOR_DEFINITIONS = ( 222 | "DEBUG=1", 223 | "$(inherited)", 224 | ); 225 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 226 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 227 | GCC_WARN_UNDECLARED_SELECTOR = YES; 228 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 229 | GCC_WARN_UNUSED_FUNCTION = YES; 230 | GCC_WARN_UNUSED_VARIABLE = YES; 231 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 232 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 233 | MTL_FAST_MATH = YES; 234 | ONLY_ACTIVE_ARCH = YES; 235 | SDKROOT = iphoneos; 236 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 237 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 238 | }; 239 | name = Debug; 240 | }; 241 | 9DB1749D22F91BC00078058C /* Release */ = { 242 | isa = XCBuildConfiguration; 243 | buildSettings = { 244 | ALWAYS_SEARCH_USER_PATHS = NO; 245 | CLANG_ANALYZER_NONNULL = YES; 246 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 247 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 248 | CLANG_CXX_LIBRARY = "libc++"; 249 | CLANG_ENABLE_MODULES = YES; 250 | CLANG_ENABLE_OBJC_ARC = YES; 251 | CLANG_ENABLE_OBJC_WEAK = YES; 252 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 253 | CLANG_WARN_BOOL_CONVERSION = YES; 254 | CLANG_WARN_COMMA = YES; 255 | CLANG_WARN_CONSTANT_CONVERSION = YES; 256 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 257 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 258 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 259 | CLANG_WARN_EMPTY_BODY = YES; 260 | CLANG_WARN_ENUM_CONVERSION = YES; 261 | CLANG_WARN_INFINITE_RECURSION = YES; 262 | CLANG_WARN_INT_CONVERSION = YES; 263 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 264 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 265 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 266 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 267 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 268 | CLANG_WARN_STRICT_PROTOTYPES = YES; 269 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 270 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 271 | CLANG_WARN_UNREACHABLE_CODE = YES; 272 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 273 | COPY_PHASE_STRIP = NO; 274 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 275 | ENABLE_NS_ASSERTIONS = NO; 276 | ENABLE_STRICT_OBJC_MSGSEND = YES; 277 | GCC_C_LANGUAGE_STANDARD = gnu11; 278 | GCC_NO_COMMON_BLOCKS = YES; 279 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 280 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 281 | GCC_WARN_UNDECLARED_SELECTOR = YES; 282 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 283 | GCC_WARN_UNUSED_FUNCTION = YES; 284 | GCC_WARN_UNUSED_VARIABLE = YES; 285 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 286 | MTL_ENABLE_DEBUG_INFO = NO; 287 | MTL_FAST_MATH = YES; 288 | SDKROOT = iphoneos; 289 | SWIFT_COMPILATION_MODE = wholemodule; 290 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 291 | VALIDATE_PRODUCT = YES; 292 | }; 293 | name = Release; 294 | }; 295 | 9DB1749F22F91BC00078058C /* Debug */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 299 | CODE_SIGN_STYLE = Automatic; 300 | DEVELOPMENT_ASSET_PATHS = "MTSlideToOpen-SwiftUI/Preview\\ Content"; 301 | ENABLE_PREVIEWS = YES; 302 | INFOPLIST_FILE = "MTSlideToOpen-SwiftUI/Info.plist"; 303 | LD_RUNPATH_SEARCH_PATHS = ( 304 | "$(inherited)", 305 | "@executable_path/Frameworks", 306 | ); 307 | PRODUCT_BUNDLE_IDENTIFIER = "io.tienle.MTSlideToOpen-SwiftUI"; 308 | PRODUCT_NAME = "$(TARGET_NAME)"; 309 | SWIFT_VERSION = 5.0; 310 | TARGETED_DEVICE_FAMILY = "1,2"; 311 | }; 312 | name = Debug; 313 | }; 314 | 9DB174A022F91BC00078058C /* Release */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 318 | CODE_SIGN_STYLE = Automatic; 319 | DEVELOPMENT_ASSET_PATHS = "MTSlideToOpen-SwiftUI/Preview\\ Content"; 320 | ENABLE_PREVIEWS = YES; 321 | INFOPLIST_FILE = "MTSlideToOpen-SwiftUI/Info.plist"; 322 | LD_RUNPATH_SEARCH_PATHS = ( 323 | "$(inherited)", 324 | "@executable_path/Frameworks", 325 | ); 326 | PRODUCT_BUNDLE_IDENTIFIER = "io.tienle.MTSlideToOpen-SwiftUI"; 327 | PRODUCT_NAME = "$(TARGET_NAME)"; 328 | SWIFT_VERSION = 5.0; 329 | TARGETED_DEVICE_FAMILY = "1,2"; 330 | }; 331 | name = Release; 332 | }; 333 | /* End XCBuildConfiguration section */ 334 | 335 | /* Begin XCConfigurationList section */ 336 | 9DB1748522F91BBE0078058C /* Build configuration list for PBXProject "MTSlideToOpen-SwiftUI" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | 9DB1749C22F91BC00078058C /* Debug */, 340 | 9DB1749D22F91BC00078058C /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | 9DB1749E22F91BC00078058C /* Build configuration list for PBXNativeTarget "MTSlideToOpen-SwiftUI" */ = { 346 | isa = XCConfigurationList; 347 | buildConfigurations = ( 348 | 9DB1749F22F91BC00078058C /* Debug */, 349 | 9DB174A022F91BC00078058C /* Release */, 350 | ); 351 | defaultConfigurationIsVisible = 0; 352 | defaultConfigurationName = Release; 353 | }; 354 | /* End XCConfigurationList section */ 355 | }; 356 | rootObject = 9DB1748222F91BBE0078058C /* Project object */; 357 | } 358 | -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MTSlideToOpen-SwiftUI 4 | // 5 | // Created by Le Manh Tien on 6/8/19. 6 | // Copyright © 2019 io.tienle. 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 | -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/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 | } -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/Assets.xcassets/ic_arrow.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "ic_arrow.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/Assets.xcassets/ic_arrow.imageset/ic_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lemanhtien/MTSlideToOpen-SwiftUI/6643bb0e6004756f344601c68670685e75c0c530/MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/Assets.xcassets/ic_arrow.imageset/ic_arrow.png -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/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 | -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // MTSlideToOpen-SwiftUI 4 | // 5 | // Created by Le Manh Tien on 6/8/19. 6 | // Copyright © 2019 io.tienle. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ContentView: View { 12 | var body: some View { 13 | VStack { 14 | MTSlideToOpen(thumbnailColor: Color.red, 15 | didReachEndAction: { view in 16 | print("reach end!!") 17 | DispatchQueue.main.asyncAfter(deadline: .now() + 3) { 18 | view.resetState() 19 | } 20 | }) 21 | .frame(width: 320, height: 56) 22 | .background(Color.yellow) 23 | .cornerRadius(28) 24 | 25 | MTSlideToOpen(thumbnailTopBottomPadding: 4, 26 | thumbnailLeadingTrailingPadding: 4, 27 | text: "Slide to unlock", 28 | textColor: .white, 29 | thumbnailColor: Color.white, 30 | sliderBackgroundColor: Color.black, 31 | didReachEndAction: { view in 32 | print("reach end!!") 33 | DispatchQueue.main.asyncAfter(deadline: .now() + 3) { 34 | view.resetState() 35 | } 36 | }) 37 | .frame(width: 320, height: 56) 38 | .background(Color.yellow) 39 | .cornerRadius(28) 40 | 41 | MTSlideToOpen(thumbnailLeadingTrailingPadding: 10, 42 | thumbnailColor:Color.blue, 43 | thumbnailBackgroundColor: Color.blue, 44 | didReachEndAction: { view in 45 | print("reach end!!") 46 | DispatchQueue.main.asyncAfter(deadline: .now() + 3) { 47 | view.resetState() 48 | } 49 | }) 50 | .frame(width: 320, height: 56) 51 | .background(Color.yellow) 52 | .cornerRadius(28) 53 | 54 | MTSlideToOpen(sliderTopBottomPadding: 4, didReachEndAction: { view in 55 | print("reach end!!") 56 | DispatchQueue.main.asyncAfter(deadline: .now() + 3) { 57 | view.resetState() 58 | } 59 | }) 60 | .frame(width: 320, height: 56) 61 | .background(Color.yellow) 62 | .cornerRadius(28) 63 | 64 | } 65 | } 66 | } 67 | 68 | #if DEBUG 69 | struct ContentView_Previews: PreviewProvider { 70 | static var previews: some View { 71 | ContentView() 72 | } 73 | } 74 | #endif 75 | -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/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 | -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // MTSlideToOpen-SwiftUI 4 | // 5 | // Created by Le Manh Tien on 6/8/19. 6 | // Copyright © 2019 io.tienle. 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 | // Use a UIHostingController as window root view controller 23 | if let windowScene = scene as? UIWindowScene { 24 | let window = UIWindow(windowScene: windowScene) 25 | window.rootViewController = UIHostingController(rootView: ContentView()) 26 | self.window = window 27 | window.makeKeyAndVisible() 28 | } 29 | } 30 | 31 | func sceneDidDisconnect(_ scene: UIScene) { 32 | // Called as the scene is being released by the system. 33 | // This occurs shortly after the scene enters the background, or when its session is discarded. 34 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 35 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 36 | } 37 | 38 | func sceneDidBecomeActive(_ scene: UIScene) { 39 | // Called when the scene has moved from an inactive state to an active state. 40 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 41 | } 42 | 43 | func sceneWillResignActive(_ scene: UIScene) { 44 | // Called when the scene will move from an active state to an inactive state. 45 | // This may occur due to temporary interruptions (ex. an incoming phone call). 46 | } 47 | 48 | func sceneWillEnterForeground(_ scene: UIScene) { 49 | // Called as the scene transitions from the background to the foreground. 50 | // Use this method to undo the changes made on entering the background. 51 | } 52 | 53 | func sceneDidEnterBackground(_ scene: UIScene) { 54 | // Called as the scene transitions from the foreground to the background. 55 | // Use this method to save data, release shared resources, and store enough scene-specific state information 56 | // to restore the scene back to its current state. 57 | } 58 | 59 | 60 | } 61 | 62 | -------------------------------------------------------------------------------- /MTSlideToOpen-SwiftUI/MTSlideToOpen-SwiftUI/Source/MTSlideToOpen-SwiftUI.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTSlideToOpen-SwiftUI.swift 3 | // MTSlideToOpen-SwiftUI 4 | // 5 | // Created by Le Manh Tien on 6/8/19. 6 | // Copyright © 2019 io.tienle. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct MTSlideToOpen: View { 12 | 13 | // Public Property 14 | var sliderTopBottomPadding: CGFloat = 0 15 | var thumbnailTopBottomPadding: CGFloat = 0 16 | var thumbnailLeadingTrailingPadding: CGFloat = 0 17 | var textLabelLeadingPadding: CGFloat = 0 18 | var text: String = "MTSlideToOpen" 19 | var textFont: Font = .system(size: 15) 20 | var textColor = Color(.sRGB, red: 25.0/255, green: 155.0/255, blue: 215.0/255, opacity: 0.7) 21 | var thumbnailColor = Color(.sRGB, red: 25.0/255, green: 155.0/255, blue: 215.0/255, opacity: 1) 22 | var thumbnailBackgroundColor: Color = .clear 23 | var sliderBackgroundColor = Color(.sRGB, red: 0.1, green: 0.64, blue: 0.84, opacity: 0.1) 24 | var resetAnimation: Animation = .easeIn(duration: 0.3) 25 | var iconName = "ic_arrow" 26 | var didReachEndAction: ((MTSlideToOpen) -> Void)? 27 | 28 | // Private Property 29 | @State private var draggableState: DraggableState = .ready 30 | 31 | private enum DraggableState { 32 | case ready 33 | case dragging(offsetX: CGFloat, maxX: CGFloat) 34 | case end(offsetX: CGFloat) 35 | 36 | var reachEnd: Bool { 37 | switch self { 38 | case .ready, .dragging(_): 39 | return false 40 | case .end(_): 41 | return true 42 | } 43 | } 44 | 45 | var isReady: Bool { 46 | switch self { 47 | case .dragging(_), .end(_): 48 | return false 49 | case .ready: 50 | return true 51 | } 52 | } 53 | 54 | var offsetX: CGFloat { 55 | switch self { 56 | case .ready: 57 | return 0.0 58 | case .dragging(let (offsetX,_)): 59 | return offsetX 60 | case .end(let offsetX): 61 | return offsetX 62 | } 63 | } 64 | 65 | var textColorOpacity: Double { 66 | switch self { 67 | case .ready: 68 | return 1.0 69 | case.dragging(let (offsetX,maxX)): 70 | return 1.0 - Double(offsetX / maxX) 71 | case .end(_): 72 | return 0.0 73 | } 74 | } 75 | 76 | } 77 | 78 | var body: some View { 79 | return GeometryReader { geometry in 80 | self.setupView(geometry: geometry) 81 | } 82 | } 83 | 84 | private func setupView(geometry: GeometryProxy) -> some View { 85 | let frame = geometry.frame(in: .global) 86 | let width = frame.size.width 87 | let height = frame.size.height 88 | let drag = DragGesture() 89 | .onChanged({ (drag) in 90 | let maxX = width - height - self.thumbnailLeadingTrailingPadding * 2 + self.thumbnailTopBottomPadding * 2 91 | let currentX = drag.translation.width 92 | if currentX >= maxX { 93 | self.draggableState = .end(offsetX: maxX) 94 | self.didReachEndAction?(self) 95 | } else if currentX <= 0 { 96 | self.draggableState = .dragging(offsetX: 0, maxX: maxX) 97 | } else { 98 | self.draggableState = .dragging(offsetX: currentX, maxX: maxX) 99 | } 100 | }) 101 | .onEnded(onDragEnded) 102 | let sliderCornerRadius = (height - sliderTopBottomPadding * 2) / 2 103 | return HStack { 104 | ZStack(alignment: .leading, content: { 105 | HStack { 106 | Text(self.text) 107 | .frame(maxWidth: .infinity) 108 | .padding([.leading], textLabelLeadingPadding) 109 | .foregroundColor(self.textColor) 110 | .opacity(self.draggableState.textColorOpacity) 111 | .animation(self.draggableState.isReady ? self.resetAnimation : nil) 112 | 113 | } 114 | .frame(maxWidth: .infinity, maxHeight: .infinity) 115 | .background(self.sliderBackgroundColor) 116 | .cornerRadius(sliderCornerRadius) 117 | .padding([.top, .bottom], self.sliderTopBottomPadding) 118 | 119 | Image(iconName) 120 | .frame(maxWidth: .infinity, maxHeight: .infinity) 121 | .aspectRatio(1.0, contentMode: .fit) 122 | .background(self.thumbnailColor) 123 | .clipShape(Circle()) 124 | .padding([.top, .bottom], self.thumbnailTopBottomPadding) 125 | .padding([.leading, .trailing], self.thumbnailLeadingTrailingPadding) 126 | .background(self.thumbnailBackgroundColor) 127 | .cornerRadius(sliderCornerRadius) 128 | .offset(x: self.self.draggableState.offsetX) 129 | .animation(self.draggableState.isReady ? self.resetAnimation : nil) 130 | .gesture(self.draggableState.reachEnd ? nil : drag) 131 | }) 132 | } 133 | .background(Color.white) 134 | } 135 | 136 | private func onDragEnded(drag: DragGesture.Value) { 137 | switch draggableState { 138 | case .end(_), .dragging(_): 139 | draggableState = .ready 140 | break 141 | case .ready: 142 | break 143 | } 144 | } 145 | 146 | // MARK: Public Function 147 | 148 | func resetState(_ animated: Bool = true) { 149 | self.draggableState = .ready 150 | } 151 | } 152 | 153 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MTSlideToOpen-SwiftUI 2 | A simple SlideToUnlock iOS UI component written in SwiftUI. 3 | 4 | 5 | 6 | ## Requirements 7 | * Swift 5.0. 8 | * iOS 13.0 or later. 9 | 10 | ## Others 11 | If you are looking for UIKit Library, can check [MTSlideToOpen](https://github.com/lemanhtien/MTSlideToOpen). 12 | 13 | ## License 14 | 15 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details. 16 | -------------------------------------------------------------------------------- /example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lemanhtien/MTSlideToOpen-SwiftUI/6643bb0e6004756f344601c68670685e75c0c530/example.gif --------------------------------------------------------------------------------