├── .github ├── ios.gif └── mac.gif ├── .gitignore ├── Example ├── Example.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── swiftpm │ │ └── Package.resolved └── Example │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── Base.lproj │ └── LaunchScreen.storyboard │ ├── ContentView.swift │ ├── Example.entitlements │ ├── Info.plist │ ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json │ └── SceneDelegate.swift ├── LICENSE ├── Package.resolved ├── Package.swift ├── README.md ├── Sources └── RefreshUI │ └── RefreshUI.swift └── Tests ├── LinuxMain.swift └── RefreshUITests ├── RefreshUITests.swift └── XCTestManifests.swift /.github/ios.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noppefoxwolf/RefreshUI/4c65e09f5d1543e7e99f15daaf25e6be6dbc7e56/.github/ios.gif -------------------------------------------------------------------------------- /.github/mac.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noppefoxwolf/RefreshUI/4c65e09f5d1543e7e99f15daaf25e6be6dbc7e56/.github/mac.gif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | .swiftpm 7 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 52; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 37BC3E01236F16820065CAEF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BC3E00236F16820065CAEF /* AppDelegate.swift */; }; 11 | 37BC3E03236F16820065CAEF /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BC3E02236F16820065CAEF /* SceneDelegate.swift */; }; 12 | 37BC3E05236F16820065CAEF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BC3E04236F16820065CAEF /* ContentView.swift */; }; 13 | 37BC3E07236F16840065CAEF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 37BC3E06236F16840065CAEF /* Assets.xcassets */; }; 14 | 37BC3E0A236F16840065CAEF /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 37BC3E09236F16840065CAEF /* Preview Assets.xcassets */; }; 15 | 37BC3E0D236F16840065CAEF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 37BC3E0B236F16840065CAEF /* LaunchScreen.storyboard */; }; 16 | 37BC3E18236F17D60065CAEF /* RefreshUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BC3E17236F17D60065CAEF /* RefreshUI.swift */; }; 17 | 37BC3E1B236F18020065CAEF /* Rotoscope in Frameworks */ = {isa = PBXBuildFile; productRef = 37BC3E1A236F18020065CAEF /* Rotoscope */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 37BC3DFD236F16820065CAEF /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 37BC3E00236F16820065CAEF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 23 | 37BC3E02236F16820065CAEF /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 24 | 37BC3E04236F16820065CAEF /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 25 | 37BC3E06236F16840065CAEF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 26 | 37BC3E09236F16840065CAEF /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 27 | 37BC3E0C236F16840065CAEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 37BC3E0E236F16840065CAEF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | 37BC3E17236F17D60065CAEF /* RefreshUI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RefreshUI.swift; path = ../../Sources/RefreshUI/RefreshUI.swift; sourceTree = ""; }; 30 | 37BC3E1C236F1A4B0065CAEF /* Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Example.entitlements; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 37BC3DFA236F16820065CAEF /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | 37BC3E1B236F18020065CAEF /* Rotoscope in Frameworks */, 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 37BC3DF4236F16820065CAEF = { 46 | isa = PBXGroup; 47 | children = ( 48 | 37BC3DFF236F16820065CAEF /* Example */, 49 | 37BC3DFE236F16820065CAEF /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 37BC3DFE236F16820065CAEF /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 37BC3DFD236F16820065CAEF /* Example.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 37BC3DFF236F16820065CAEF /* Example */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 37BC3E1C236F1A4B0065CAEF /* Example.entitlements */, 65 | 37BC3E17236F17D60065CAEF /* RefreshUI.swift */, 66 | 37BC3E00236F16820065CAEF /* AppDelegate.swift */, 67 | 37BC3E02236F16820065CAEF /* SceneDelegate.swift */, 68 | 37BC3E04236F16820065CAEF /* ContentView.swift */, 69 | 37BC3E06236F16840065CAEF /* Assets.xcassets */, 70 | 37BC3E0B236F16840065CAEF /* LaunchScreen.storyboard */, 71 | 37BC3E0E236F16840065CAEF /* Info.plist */, 72 | 37BC3E08236F16840065CAEF /* Preview Content */, 73 | ); 74 | path = Example; 75 | sourceTree = ""; 76 | }; 77 | 37BC3E08236F16840065CAEF /* Preview Content */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 37BC3E09236F16840065CAEF /* Preview Assets.xcassets */, 81 | ); 82 | path = "Preview Content"; 83 | sourceTree = ""; 84 | }; 85 | /* End PBXGroup section */ 86 | 87 | /* Begin PBXNativeTarget section */ 88 | 37BC3DFC236F16820065CAEF /* Example */ = { 89 | isa = PBXNativeTarget; 90 | buildConfigurationList = 37BC3E11236F16840065CAEF /* Build configuration list for PBXNativeTarget "Example" */; 91 | buildPhases = ( 92 | 37BC3DF9236F16820065CAEF /* Sources */, 93 | 37BC3DFA236F16820065CAEF /* Frameworks */, 94 | 37BC3DFB236F16820065CAEF /* Resources */, 95 | ); 96 | buildRules = ( 97 | ); 98 | dependencies = ( 99 | ); 100 | name = Example; 101 | packageProductDependencies = ( 102 | 37BC3E1A236F18020065CAEF /* Rotoscope */, 103 | ); 104 | productName = Example; 105 | productReference = 37BC3DFD236F16820065CAEF /* Example.app */; 106 | productType = "com.apple.product-type.application"; 107 | }; 108 | /* End PBXNativeTarget section */ 109 | 110 | /* Begin PBXProject section */ 111 | 37BC3DF5236F16820065CAEF /* Project object */ = { 112 | isa = PBXProject; 113 | attributes = { 114 | LastSwiftUpdateCheck = 1120; 115 | LastUpgradeCheck = 1120; 116 | ORGANIZATIONNAME = "Tomoya Hirano"; 117 | TargetAttributes = { 118 | 37BC3DFC236F16820065CAEF = { 119 | CreatedOnToolsVersion = 11.2; 120 | }; 121 | }; 122 | }; 123 | buildConfigurationList = 37BC3DF8236F16820065CAEF /* Build configuration list for PBXProject "Example" */; 124 | compatibilityVersion = "Xcode 9.3"; 125 | developmentRegion = en; 126 | hasScannedForEncodings = 0; 127 | knownRegions = ( 128 | en, 129 | Base, 130 | ); 131 | mainGroup = 37BC3DF4236F16820065CAEF; 132 | packageReferences = ( 133 | 37BC3E19236F18020065CAEF /* XCRemoteSwiftPackageReference "Rotoscope" */, 134 | ); 135 | productRefGroup = 37BC3DFE236F16820065CAEF /* Products */; 136 | projectDirPath = ""; 137 | projectRoot = ""; 138 | targets = ( 139 | 37BC3DFC236F16820065CAEF /* Example */, 140 | ); 141 | }; 142 | /* End PBXProject section */ 143 | 144 | /* Begin PBXResourcesBuildPhase section */ 145 | 37BC3DFB236F16820065CAEF /* Resources */ = { 146 | isa = PBXResourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | 37BC3E0D236F16840065CAEF /* LaunchScreen.storyboard in Resources */, 150 | 37BC3E0A236F16840065CAEF /* Preview Assets.xcassets in Resources */, 151 | 37BC3E07236F16840065CAEF /* Assets.xcassets in Resources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXResourcesBuildPhase section */ 156 | 157 | /* Begin PBXSourcesBuildPhase section */ 158 | 37BC3DF9236F16820065CAEF /* Sources */ = { 159 | isa = PBXSourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 37BC3E01236F16820065CAEF /* AppDelegate.swift in Sources */, 163 | 37BC3E03236F16820065CAEF /* SceneDelegate.swift in Sources */, 164 | 37BC3E05236F16820065CAEF /* ContentView.swift in Sources */, 165 | 37BC3E18236F17D60065CAEF /* RefreshUI.swift in Sources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXSourcesBuildPhase section */ 170 | 171 | /* Begin PBXVariantGroup section */ 172 | 37BC3E0B236F16840065CAEF /* LaunchScreen.storyboard */ = { 173 | isa = PBXVariantGroup; 174 | children = ( 175 | 37BC3E0C236F16840065CAEF /* Base */, 176 | ); 177 | name = LaunchScreen.storyboard; 178 | sourceTree = ""; 179 | }; 180 | /* End PBXVariantGroup section */ 181 | 182 | /* Begin XCBuildConfiguration section */ 183 | 37BC3E0F236F16840065CAEF /* Debug */ = { 184 | isa = XCBuildConfiguration; 185 | buildSettings = { 186 | ALWAYS_SEARCH_USER_PATHS = NO; 187 | CLANG_ANALYZER_NONNULL = YES; 188 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 189 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 190 | CLANG_CXX_LIBRARY = "libc++"; 191 | CLANG_ENABLE_MODULES = YES; 192 | CLANG_ENABLE_OBJC_ARC = YES; 193 | CLANG_ENABLE_OBJC_WEAK = YES; 194 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 195 | CLANG_WARN_BOOL_CONVERSION = YES; 196 | CLANG_WARN_COMMA = YES; 197 | CLANG_WARN_CONSTANT_CONVERSION = YES; 198 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 199 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 200 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 201 | CLANG_WARN_EMPTY_BODY = YES; 202 | CLANG_WARN_ENUM_CONVERSION = YES; 203 | CLANG_WARN_INFINITE_RECURSION = YES; 204 | CLANG_WARN_INT_CONVERSION = YES; 205 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 206 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 207 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 208 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 209 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 210 | CLANG_WARN_STRICT_PROTOTYPES = YES; 211 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 212 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 213 | CLANG_WARN_UNREACHABLE_CODE = YES; 214 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 215 | COPY_PHASE_STRIP = NO; 216 | DEBUG_INFORMATION_FORMAT = dwarf; 217 | ENABLE_STRICT_OBJC_MSGSEND = YES; 218 | ENABLE_TESTABILITY = YES; 219 | GCC_C_LANGUAGE_STANDARD = gnu11; 220 | GCC_DYNAMIC_NO_PIC = NO; 221 | GCC_NO_COMMON_BLOCKS = YES; 222 | GCC_OPTIMIZATION_LEVEL = 0; 223 | GCC_PREPROCESSOR_DEFINITIONS = ( 224 | "DEBUG=1", 225 | "$(inherited)", 226 | ); 227 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 228 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 229 | GCC_WARN_UNDECLARED_SELECTOR = YES; 230 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 231 | GCC_WARN_UNUSED_FUNCTION = YES; 232 | GCC_WARN_UNUSED_VARIABLE = YES; 233 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 234 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 235 | MTL_FAST_MATH = YES; 236 | ONLY_ACTIVE_ARCH = YES; 237 | SDKROOT = iphoneos; 238 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 239 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 240 | }; 241 | name = Debug; 242 | }; 243 | 37BC3E10236F16840065CAEF /* Release */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | ALWAYS_SEARCH_USER_PATHS = NO; 247 | CLANG_ANALYZER_NONNULL = YES; 248 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 249 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 250 | CLANG_CXX_LIBRARY = "libc++"; 251 | CLANG_ENABLE_MODULES = YES; 252 | CLANG_ENABLE_OBJC_ARC = YES; 253 | CLANG_ENABLE_OBJC_WEAK = YES; 254 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 255 | CLANG_WARN_BOOL_CONVERSION = YES; 256 | CLANG_WARN_COMMA = YES; 257 | CLANG_WARN_CONSTANT_CONVERSION = YES; 258 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 259 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 260 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 261 | CLANG_WARN_EMPTY_BODY = YES; 262 | CLANG_WARN_ENUM_CONVERSION = YES; 263 | CLANG_WARN_INFINITE_RECURSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 266 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 267 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 269 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 270 | CLANG_WARN_STRICT_PROTOTYPES = YES; 271 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 272 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 273 | CLANG_WARN_UNREACHABLE_CODE = YES; 274 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 275 | COPY_PHASE_STRIP = NO; 276 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 277 | ENABLE_NS_ASSERTIONS = NO; 278 | ENABLE_STRICT_OBJC_MSGSEND = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu11; 280 | GCC_NO_COMMON_BLOCKS = YES; 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 = NO; 289 | MTL_FAST_MATH = YES; 290 | SDKROOT = iphoneos; 291 | SWIFT_COMPILATION_MODE = wholemodule; 292 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 293 | VALIDATE_PRODUCT = YES; 294 | }; 295 | name = Release; 296 | }; 297 | 37BC3E12236F16840065CAEF /* Debug */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 301 | CODE_SIGN_ENTITLEMENTS = Example/Example.entitlements; 302 | CODE_SIGN_STYLE = Automatic; 303 | DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; 304 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\""; 305 | DEVELOPMENT_TEAM = FBQ6Z8AF3U; 306 | ENABLE_PREVIEWS = YES; 307 | INFOPLIST_FILE = Example/Info.plist; 308 | LD_RUNPATH_SEARCH_PATHS = ( 309 | "$(inherited)", 310 | "@executable_path/Frameworks", 311 | ); 312 | PRODUCT_BUNDLE_IDENTIFIER = com.noppelab.Example; 313 | PRODUCT_NAME = "$(TARGET_NAME)"; 314 | SUPPORTS_MACCATALYST = YES; 315 | SWIFT_VERSION = 5.0; 316 | TARGETED_DEVICE_FAMILY = "1,2"; 317 | }; 318 | name = Debug; 319 | }; 320 | 37BC3E13236F16840065CAEF /* Release */ = { 321 | isa = XCBuildConfiguration; 322 | buildSettings = { 323 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 324 | CODE_SIGN_ENTITLEMENTS = Example/Example.entitlements; 325 | CODE_SIGN_STYLE = Automatic; 326 | DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; 327 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\""; 328 | DEVELOPMENT_TEAM = FBQ6Z8AF3U; 329 | ENABLE_PREVIEWS = YES; 330 | INFOPLIST_FILE = Example/Info.plist; 331 | LD_RUNPATH_SEARCH_PATHS = ( 332 | "$(inherited)", 333 | "@executable_path/Frameworks", 334 | ); 335 | PRODUCT_BUNDLE_IDENTIFIER = com.noppelab.Example; 336 | PRODUCT_NAME = "$(TARGET_NAME)"; 337 | SUPPORTS_MACCATALYST = YES; 338 | SWIFT_VERSION = 5.0; 339 | TARGETED_DEVICE_FAMILY = "1,2"; 340 | }; 341 | name = Release; 342 | }; 343 | /* End XCBuildConfiguration section */ 344 | 345 | /* Begin XCConfigurationList section */ 346 | 37BC3DF8236F16820065CAEF /* Build configuration list for PBXProject "Example" */ = { 347 | isa = XCConfigurationList; 348 | buildConfigurations = ( 349 | 37BC3E0F236F16840065CAEF /* Debug */, 350 | 37BC3E10236F16840065CAEF /* Release */, 351 | ); 352 | defaultConfigurationIsVisible = 0; 353 | defaultConfigurationName = Release; 354 | }; 355 | 37BC3E11236F16840065CAEF /* Build configuration list for PBXNativeTarget "Example" */ = { 356 | isa = XCConfigurationList; 357 | buildConfigurations = ( 358 | 37BC3E12236F16840065CAEF /* Debug */, 359 | 37BC3E13236F16840065CAEF /* Release */, 360 | ); 361 | defaultConfigurationIsVisible = 0; 362 | defaultConfigurationName = Release; 363 | }; 364 | /* End XCConfigurationList section */ 365 | 366 | /* Begin XCRemoteSwiftPackageReference section */ 367 | 37BC3E19236F18020065CAEF /* XCRemoteSwiftPackageReference "Rotoscope" */ = { 368 | isa = XCRemoteSwiftPackageReference; 369 | repositoryURL = "git@github.com:noppefoxwolf/Rotoscope.git"; 370 | requirement = { 371 | kind = upToNextMajorVersion; 372 | minimumVersion = 0.1.0; 373 | }; 374 | }; 375 | /* End XCRemoteSwiftPackageReference section */ 376 | 377 | /* Begin XCSwiftPackageProductDependency section */ 378 | 37BC3E1A236F18020065CAEF /* Rotoscope */ = { 379 | isa = XCSwiftPackageProductDependency; 380 | package = 37BC3E19236F18020065CAEF /* XCRemoteSwiftPackageReference "Rotoscope" */; 381 | productName = Rotoscope; 382 | }; 383 | /* End XCSwiftPackageProductDependency section */ 384 | }; 385 | rootObject = 37BC3DF5236F16820065CAEF /* Project object */; 386 | } 387 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "Rotoscope", 6 | "repositoryURL": "git@github.com:noppefoxwolf/Rotoscope.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "99da0c0f2f9c3afde63c72cd15d910e5f504d057", 10 | "version": "0.1.2" 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /Example/Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Example 4 | // 5 | // Created by Tomoya Hirano on 2019/11/03. 6 | // Copyright © 2019 Tomoya Hirano. 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 | -------------------------------------------------------------------------------- /Example/Example/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 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/Example/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 | -------------------------------------------------------------------------------- /Example/Example/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // Example 4 | // 5 | // Created by Tomoya Hirano on 2019/11/03. 6 | // Copyright © 2019 Tomoya Hirano. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ContentView: View { 12 | @State var items: [Int] = [0,1,2,3,4,5,6,7,8,9] 13 | @State var isLoading: Bool = false 14 | 15 | var body: some View { 16 | List { 17 | ForEach(items, id: \.self) { item in 18 | Button(action: { 19 | 20 | }) { 21 | Text("\(item)") 22 | } 23 | } 24 | } 25 | .onPull(perform: { 26 | self.isLoading = false 27 | DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { 28 | self.items.shuffle() 29 | self.isLoading = true 30 | } 31 | }, isLoading: isLoading) 32 | } 33 | } 34 | 35 | struct ContentView_Previews: PreviewProvider { 36 | static var previews: some View { 37 | ContentView() 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Example/Example/Example.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.network.client 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/Example/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 | -------------------------------------------------------------------------------- /Example/Example/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/Example/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // Example 4 | // 5 | // Created by Tomoya Hirano on 2019/11/03. 6 | // Copyright © 2019 Tomoya Hirano. 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 | let contentView = ContentView() 24 | 25 | // Use a UIHostingController as window root view controller. 26 | if let windowScene = scene as? UIWindowScene { 27 | let window = UIWindow(windowScene: windowScene) 28 | window.rootViewController = UIHostingController(rootView: contentView) 29 | self.window = window 30 | window.makeKeyAndVisible() 31 | } 32 | } 33 | 34 | func sceneDidDisconnect(_ scene: UIScene) { 35 | // Called as the scene is being released by the system. 36 | // This occurs shortly after the scene enters the background, or when its session is discarded. 37 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 38 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 39 | } 40 | 41 | func sceneDidBecomeActive(_ scene: UIScene) { 42 | // Called when the scene has moved from an inactive state to an active state. 43 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 44 | } 45 | 46 | func sceneWillResignActive(_ scene: UIScene) { 47 | // Called when the scene will move from an active state to an inactive state. 48 | // This may occur due to temporary interruptions (ex. an incoming phone call). 49 | } 50 | 51 | func sceneWillEnterForeground(_ scene: UIScene) { 52 | // Called as the scene transitions from the background to the foreground. 53 | // Use this method to undo the changes made on entering the background. 54 | } 55 | 56 | func sceneDidEnterBackground(_ scene: UIScene) { 57 | // Called as the scene transitions from the foreground to the background. 58 | // Use this method to save data, release shared resources, and store enough scene-specific state information 59 | // to restore the scene back to its current state. 60 | } 61 | 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 noppe 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "Rotoscope", 6 | "repositoryURL": "git@github.com:noppefoxwolf/Rotoscope.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "99da0c0f2f9c3afde63c72cd15d910e5f504d057", 10 | "version": "0.1.2" 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.1 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "RefreshUI", 8 | platforms: [.iOS(.v13)], 9 | products: [ 10 | .library( 11 | name: "RefreshUI", 12 | targets: ["RefreshUI"]), 13 | ], 14 | dependencies: [ 15 | .package(url: "git@github.com:noppefoxwolf/Rotoscope.git", from: .init("0.1.2")) 16 | ], 17 | targets: [ 18 | .target( 19 | name: "RefreshUI", 20 | dependencies: ["Rotoscope"]), 21 | .testTarget( 22 | name: "RefreshUITests", 23 | dependencies: ["RefreshUI"]), 24 | ] 25 | ) 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RefreshUI is no longer available. 2 | I'm preferred to use Introspect. 3 | https://github.com/siteline/SwiftUI-Introspect 4 | 5 | # RefreshUI 6 | 7 | RefreshUI provide native refresh control to SwiftUI. 8 | 9 | ⚠️ This library uses blackmagic.🧞‍♂️ 10 | 11 | | iOS | macOS | 12 | |---|---| 13 | |![](https://github.com/noppefoxwolf/PullToRefresh/blob/master/.github/ios.gif)|![](https://github.com/noppefoxwolf/PullToRefresh/blob/master/.github/mac.gif)| 14 | 15 | # Usage 16 | 17 | ```swift 18 | List { 19 | ForEach(items, id: \.self) { (item) in 20 | Text("\(item)") 21 | } 22 | }.onPull(perform: { 23 | self.items.shuffle() 24 | }, isLoading: isLoading) 25 | ``` 26 | 27 | # License 28 | 29 | RefreshUI is licensed under the MIT License. See the LICENSE file for more information. 30 | -------------------------------------------------------------------------------- /Sources/RefreshUI/RefreshUI.swift: -------------------------------------------------------------------------------- 1 | import Rotoscope 2 | import UIKit 3 | import SwiftUI 4 | 5 | public struct Token: Identifiable { 6 | public let id: Int 7 | } 8 | 9 | public extension List { 10 | func onPull(perform: @escaping () -> Void, isLoading: Bool) -> some View { 11 | onPull(perform: perform, isLoading: isLoading, token: Token(id: 1)) 12 | } 13 | 14 | func onPull(perform: @escaping () -> Void, isLoading: Bool, token: T) -> some View where T.ID == Int { 15 | 16 | // run in body calculation 17 | if isLoading { 18 | NotificationCenter.default.post(name: .beginRefreshing, object: nil, userInfo: ["id" : token.id]) 19 | } else { 20 | NotificationCenter.default.post(name: .endRefreshing, object: nil, userInfo: ["id" : token.id]) 21 | } 22 | 23 | return tagging(token.id) { (target) in 24 | guard let managerBox = target else { return } 25 | guard let tableViewWrapper = managerBox.subviews.first else { return } 26 | guard let tableView = tableViewWrapper.subviews.first as? UITableView else { return } 27 | if tableView.refreshControlHandler == nil && tableView.refreshControl == nil { 28 | let refreshControl = UIRefreshControl() 29 | let handler = PullToRefreshHandler(refreshControl: refreshControl, id: token.id) 30 | handler.onPull = perform 31 | tableView.refreshControlHandler = handler 32 | tableView.refreshControl = refreshControl 33 | refreshControl.endRefreshing() 34 | } 35 | } 36 | } 37 | } 38 | 39 | extension Notification.Name { 40 | static var beginRefreshing: Notification.Name { 41 | Notification.Name(rawValue: "com.noppe.refreshUI.beginRefreshing") 42 | } 43 | static var endRefreshing: Notification.Name { 44 | Notification.Name(rawValue: "com.noppe.refreshUI.endRefreshing") 45 | } 46 | } 47 | 48 | internal class PullToRefreshHandler: NSObject { 49 | weak var refreshControl: UIRefreshControl? = nil 50 | var onPull: (() -> Void)? = nil 51 | let id: Int 52 | 53 | init(refreshControl: UIRefreshControl, id: Int) { 54 | self.id = id 55 | super.init() 56 | self.refreshControl = refreshControl 57 | let nc = NotificationCenter.default 58 | nc.addObserver(self, selector: #selector(PullToRefreshHandler.beginRefreshing), name: .beginRefreshing, object: nil) 59 | nc.addObserver(self, selector: #selector(PullToRefreshHandler.endRefreshing), name: .endRefreshing, object: nil) 60 | refreshControl.addTarget(self, action: #selector(PullToRefreshHandler.valueChanged), for: .valueChanged) 61 | } 62 | 63 | deinit { 64 | NotificationCenter.default.removeObserver(self) 65 | } 66 | 67 | @objc func valueChanged(_ sender: UIRefreshControl) { 68 | onPull?() 69 | } 70 | 71 | @objc func beginRefreshing(_ notification: Notification) { 72 | guard let id = notification.userInfo?["id"] as? Int else { return } 73 | guard self.id == id else { return } 74 | DispatchQueue.main.async { [weak self] in 75 | self?.refreshControl?.beginRefreshing() 76 | } 77 | } 78 | 79 | @objc func endRefreshing(_ notification: Notification) { 80 | guard let id = notification.userInfo?["id"] as? Int else { return } 81 | guard self.id == id else { return } 82 | DispatchQueue.main.async { [weak self] in 83 | self?.refreshControl?.endRefreshing() 84 | } 85 | } 86 | } 87 | 88 | var StoredPropertyKey: UInt8 = 0 89 | 90 | extension UITableView { 91 | var refreshControlHandler: PullToRefreshHandler? { 92 | get { 93 | guard let object = objc_getAssociatedObject(self, &StoredPropertyKey) as? PullToRefreshHandler else { 94 | return nil 95 | } 96 | return object 97 | } 98 | set { 99 | objc_setAssociatedObject(self, &StoredPropertyKey, newValue, .OBJC_ASSOCIATION_RETAIN) 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | import PullToRefreshTests 4 | 5 | var tests = [XCTestCaseEntry]() 6 | tests += PullToRefreshTests.allTests() 7 | XCTMain(tests) 8 | -------------------------------------------------------------------------------- /Tests/RefreshUITests/RefreshUITests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import RefreshUI 3 | 4 | final class RefreshUITests: XCTestCase { 5 | func testExample() { 6 | // This is an example of a functional test case. 7 | // Use XCTAssert and related functions to verify your tests produce the correct 8 | // results. 9 | 10 | } 11 | 12 | static var allTests = [ 13 | ("testExample", testExample), 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /Tests/RefreshUITests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | #if !canImport(ObjectiveC) 4 | public func allTests() -> [XCTestCaseEntry] { 5 | return [ 6 | testCase(PullToRefreshTests.allTests), 7 | ] 8 | } 9 | #endif 10 | --------------------------------------------------------------------------------