";
- };
-/* End PBXVariantGroup section */
-
-/* Begin XCBuildConfiguration section */
- F47A41E024EB222D0054DBB2 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = "";
- CLANG_ANALYZER_NONNULL = YES;
- CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_ENABLE_MODULES = YES;
- CLANG_ENABLE_OBJC_WEAK = YES;
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_COMMA = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
- CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INFINITE_RECURSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
- CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
- CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
- CLANG_WARN_STRICT_PROTOTYPES = YES;
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
- CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- CODE_SIGN_ENTITLEMENTS = "iOS Example/Entitlements.entitlements";
- CODE_SIGN_STYLE = Automatic;
- DEVELOPMENT_TEAM = Z384JW42NU;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- ENABLE_TESTABILITY = YES;
- GCC_C_LANGUAGE_STANDARD = gnu11;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- INFOPLIST_FILE = "iOS Example/Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 12.0;
- LD_RUNPATH_SEARCH_PATHS = (
- "$(inherited)",
- "@executable_path/Frameworks",
- );
- MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
- MTL_FAST_MATH = YES;
- PRODUCT_BUNDLE_IDENTIFIER = by.ivanvorobei.opensource.spdiffable;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SDKROOT = iphoneos;
- SUPPORTS_MACCATALYST = YES;
- SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
- SWIFT_VERSION = 5.0;
- TARGETED_DEVICE_FAMILY = "1,2";
- };
- name = Debug;
- };
- F47A41E124EB222D0054DBB2 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = "";
- CLANG_ANALYZER_NONNULL = YES;
- CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_ENABLE_MODULES = YES;
- CLANG_ENABLE_OBJC_WEAK = YES;
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_COMMA = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
- CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INFINITE_RECURSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
- CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
- CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
- CLANG_WARN_STRICT_PROTOTYPES = YES;
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
- CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- CODE_SIGN_ENTITLEMENTS = "iOS Example/Entitlements.entitlements";
- CODE_SIGN_STYLE = Automatic;
- COPY_PHASE_STRIP = NO;
- DEVELOPMENT_TEAM = Z384JW42NU;
- ENABLE_NS_ASSERTIONS = NO;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- GCC_C_LANGUAGE_STANDARD = gnu11;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- INFOPLIST_FILE = "iOS Example/Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 12.0;
- LD_RUNPATH_SEARCH_PATHS = (
- "$(inherited)",
- "@executable_path/Frameworks",
- );
- MTL_ENABLE_DEBUG_INFO = NO;
- MTL_FAST_MATH = YES;
- PRODUCT_BUNDLE_IDENTIFIER = by.ivanvorobei.opensource.spdiffable;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SDKROOT = iphoneos;
- SUPPORTS_MACCATALYST = YES;
- SWIFT_VERSION = 5.0;
- TARGETED_DEVICE_FAMILY = "1,2";
- VALIDATE_PRODUCT = YES;
- };
- name = Release;
- };
- OBJ_3 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_ENABLE_OBJC_ARC = YES;
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_COMMA = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INFINITE_RECURSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
- CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
- CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
- CLANG_WARN_STRICT_PROTOTYPES = YES;
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- COMBINE_HIDPI_IMAGES = YES;
- COPY_PHASE_STRIP = NO;
- DEBUG_INFORMATION_FORMAT = dwarf;
- DYLIB_INSTALL_NAME_BASE = "@rpath";
- ENABLE_NS_ASSERTIONS = YES;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- ENABLE_TESTABILITY = YES;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "$(inherited)",
- "SWIFT_PACKAGE=1",
- "DEBUG=1",
- );
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.10;
- ONLY_ACTIVE_ARCH = YES;
- OTHER_SWIFT_FLAGS = "$(inherited) -DXcode";
- PRODUCT_NAME = "$(TARGET_NAME)";
- SDKROOT = macosx;
- SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
- SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) SWIFT_PACKAGE DEBUG";
- SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- USE_HEADERMAP = NO;
- };
- name = Debug;
- };
- OBJ_4 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_ENABLE_OBJC_ARC = YES;
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_COMMA = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INFINITE_RECURSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
- CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
- CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
- CLANG_WARN_STRICT_PROTOTYPES = YES;
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- COMBINE_HIDPI_IMAGES = YES;
- COPY_PHASE_STRIP = YES;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- DYLIB_INSTALL_NAME_BASE = "@rpath";
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_OPTIMIZATION_LEVEL = s;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "$(inherited)",
- "SWIFT_PACKAGE=1",
- );
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.10;
- OTHER_SWIFT_FLAGS = "$(inherited) -DXcode";
- PRODUCT_NAME = "$(TARGET_NAME)";
- SDKROOT = macosx;
- SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
- SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) SWIFT_PACKAGE";
- SWIFT_COMPILATION_MODE = wholemodule;
- SWIFT_OPTIMIZATION_LEVEL = "-O";
- USE_HEADERMAP = NO;
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- F47A41DF24EB222D0054DBB2 /* Build configuration list for PBXNativeTarget "Example iOS" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- F47A41E024EB222D0054DBB2 /* Debug */,
- F47A41E124EB222D0054DBB2 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- OBJ_2 /* Build configuration list for PBXProject "SPDiffable" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- OBJ_3 /* Debug */,
- OBJ_4 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
-
-/* Begin XCSwiftPackageProductDependency section */
- F4DE1B2B27B681AA00A608F1 /* SPDiffable */ = {
- isa = XCSwiftPackageProductDependency;
- productName = SPDiffable;
- };
-/* End XCSwiftPackageProductDependency section */
- };
- rootObject = OBJ_1 /* Project object */;
-}
diff --git a/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/contents.xcworkspacedata
deleted file mode 100644
index fe1aa71..0000000
--- a/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
deleted file mode 100644
index 18d9810..0000000
--- a/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
- IDEDidComputeMac32BitWarning
-
-
-
diff --git a/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
deleted file mode 100644
index 54782e3..0000000
--- a/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
- IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded
-
-
-
diff --git a/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcuserdata/varabeis.xcuserdatad/UserInterfaceState.xcuserstate b/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcuserdata/varabeis.xcuserdatad/UserInterfaceState.xcuserstate
deleted file mode 100644
index 4c210ff..0000000
Binary files a/Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcuserdata/varabeis.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ
diff --git a/Example Apps/SPDiffable.xcodeproj/xcshareddata/xcschemes/Example iOS.xcscheme b/Example Apps/SPDiffable.xcodeproj/xcshareddata/xcschemes/Example iOS.xcscheme
deleted file mode 100644
index 43be2a1..0000000
--- a/Example Apps/SPDiffable.xcodeproj/xcshareddata/xcschemes/Example iOS.xcscheme
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Example Apps/SPDiffable.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Example Apps/SPDiffable.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
deleted file mode 100644
index 6747546..0000000
--- a/Example Apps/SPDiffable.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
diff --git a/Example Apps/SPDiffable.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcschemes/xcschememanagement.plist b/Example Apps/SPDiffable.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcschemes/xcschememanagement.plist
deleted file mode 100644
index a4006a7..0000000
--- a/Example Apps/SPDiffable.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcschemes/xcschememanagement.plist
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- SchemeUserState
-
- Example iOS.xcscheme_^#shared#^_
-
- orderHint
- 0
-
-
- SuppressBuildableAutocreation
-
- F47A41CD24EB222C0054DBB2
-
- primary
-
-
-
-
-
diff --git a/Example Apps/iOS Example/App/AppDelegate.swift b/Example Apps/iOS Example/App/AppDelegate.swift
deleted file mode 100644
index 222427b..0000000
--- a/Example Apps/iOS Example/App/AppDelegate.swift
+++ /dev/null
@@ -1,40 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@UIApplicationMain
-class AppDelegate: UIResponder, UIApplicationDelegate {
-
- var window: UIWindow?
-
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- let frame = UIScreen.main.bounds
- window = UIWindow(frame: frame)
- if #available(iOS 13.0, *) {
- window?.rootViewController = UINavigationController(rootViewController: RootController())
- } else {
- window?.rootViewController = UIViewController()
- }
- window?.makeKeyAndVisible()
- return true
- }
-}
diff --git a/Example Apps/iOS Example/App/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example Apps/iOS Example/App/Assets.xcassets/AppIcon.appiconset/Contents.json
deleted file mode 100644
index 9221b9b..0000000
--- a/Example Apps/iOS Example/App/Assets.xcassets/AppIcon.appiconset/Contents.json
+++ /dev/null
@@ -1,98 +0,0 @@
-{
- "images" : [
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "20x20"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "20x20"
- },
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "29x29"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "29x29"
- },
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "40x40"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "40x40"
- },
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "60x60"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "60x60"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "20x20"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "20x20"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "29x29"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "29x29"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "40x40"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "40x40"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "76x76"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "76x76"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "83.5x83.5"
- },
- {
- "idiom" : "ios-marketing",
- "scale" : "1x",
- "size" : "1024x1024"
- }
- ],
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/Example Apps/iOS Example/App/Assets.xcassets/Contents.json b/Example Apps/iOS Example/App/Assets.xcassets/Contents.json
deleted file mode 100644
index 73c0059..0000000
--- a/Example Apps/iOS Example/App/Assets.xcassets/Contents.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/Example Apps/iOS Example/App/Base.lproj/LaunchScreen.storyboard b/Example Apps/iOS Example/App/Base.lproj/LaunchScreen.storyboard
deleted file mode 100644
index 865e932..0000000
--- a/Example Apps/iOS Example/App/Base.lproj/LaunchScreen.storyboard
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Example Apps/iOS Example/Controllers/DiffableTableController.swift b/Example Apps/iOS Example/Controllers/DiffableTableController.swift
deleted file mode 100644
index 50ab108..0000000
--- a/Example Apps/iOS Example/Controllers/DiffableTableController.swift
+++ /dev/null
@@ -1,49 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-import SPDiffable
-
-@available(iOS 13.0, *)
-class DiffableTableController: SPDiffableTableController, SPDiffableTableMediator {
-
- init() {
- super.init(style: .insetGrouped)
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- diffableDataSource?.mediator = self
- configureDiffable(sections: content, cellProviders: SPDiffableTableDataSource.CellProvider.default)
- }
-
- var content: [SPDiffableSection] {
- return []
- }
-
- internal func updateContent(animated: Bool) {
- diffableDataSource?.set(content, animated: animated)
- }
-}
diff --git a/Example Apps/iOS Example/Controllers/RootController.swift b/Example Apps/iOS Example/Controllers/RootController.swift
deleted file mode 100644
index ed8228b..0000000
--- a/Example Apps/iOS Example/Controllers/RootController.swift
+++ /dev/null
@@ -1,157 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-import SPDiffable
-
-@available(iOS 13.0, *)
-class RootController: DiffableTableController {
-
- override func viewDidLoad() {
- super.viewDidLoad()
- navigationItem.title = "SPDiffable Examples"
- }
-
- enum Section: String {
-
- case basic = "basic"
- case sidebar = "sidebar"
- case accessory = "accessory"
- case checkmark = "checkmark"
- case customCellProvider = "customCellProvider"
-
- var id: String {
- return rawValue
- }
- }
-
- override var content: [SPDiffableSection] {
-
- var content: [SPDiffableSection] = []
-
- let accessorySection = SPDiffableSection(
- id: Section.accessory.id,
- header: SPDiffableTextHeaderFooter(text: "Accessory"),
- footer: SPDiffableTextHeaderFooter(text: "Getting default value before show. After changes in elements you can check prints in console."),
- items: [
- SPDiffableTableRowSwitch(text: "Switch", isOn: switchOn, action: { [weak self] (isOn) in
- guard let self = self else { return }
- self.switchOn = isOn
-
- }),
- SPDiffableTableRowStepper(text: "Stepper", stepValue: 1, value: stepperValue, minimumValue: -5, maximumValue: 5, action: { [weak self] (value) in
- guard let self = self else { return }
- self.stepperValue = value
- })
- ]
- )
- content.append(accessorySection)
-
- let basicSection = SPDiffableSection(
- id: Section.basic.id,
- header: SPDiffableTextHeaderFooter(text: "Presenter"),
- footer: SPDiffableTextHeaderFooter(text: "Push in navigation processing by table controller. Sometimes you need manually deselect cell."),
- items: [
- SPDiffableTableRow(text: "Deselect", accessoryType: .disclosureIndicator, selectionStyle: .default, action: { [weak self] model, indexPath in
- guard let self = self else { return }
- self.tableView.deselectRow(at: indexPath, animated: true)
- }),
- SPDiffableTableRow(text: "Push", accessoryType: .disclosureIndicator, selectionStyle: .default, action: { [weak self] model, indexPath in
- guard let self = self else { return }
- let controller = UIViewController()
- controller.view.backgroundColor = .secondarySystemGroupedBackground
- self.navigationController?.pushViewController(controller, animated: true)
- })
- ]
- )
- content.append(basicSection)
-
- if switchOn {
- accessorySection.items.insert(SPDiffableTableRow(text: "Switch Worked", accessoryType: .checkmark), at: 1)
- }
-
- if stepperValue != 0 {
- accessorySection.items.append(
- SPDiffableTableRow(id: stepperValueIdentifier, text: "Stepper Value", detail: "\(Int(stepperValue))")
- )
- }
-
- if #available(iOS 14, *) {
- let sideBarSections = SPDiffableSection(
- id: Section.sidebar.id,
- footer: SPDiffableTextHeaderFooter(text: "Example of new Side Bar."),
- items: [
- SPDiffableTableRow(text: "Present Side Bar", accessoryType: .disclosureIndicator, selectionStyle: .default, action: { [weak self] model, indexPath in
- guard let self = self else { return }
- self.tableView.deselectRow(at: indexPath, animated: true)
- let sideBarController = SideBarSplitController()
- sideBarController.modalPresentationStyle = .fullScreen
- self.present(sideBarController, animated: true)
- })
- ]
- )
- content.append(sideBarSections)
- }
-
- let checkmarkSections = SPDiffableSection(
- id: Section.checkmark.id,
- footer: SPDiffableTextHeaderFooter(text: "Example how usage search by models and change checkmark without reload table."),
- items: [
- SPDiffableTableRow(text: "Chekmarks", accessoryType: .disclosureIndicator, selectionStyle: .default, action: { [weak self] model, indexPath in
- guard let self = self else { return }
- self.tableView.deselectRow(at: indexPath, animated: true)
- })
- ]
- )
- content.append(checkmarkSections)
-
- let cellProviderSection = SPDiffableSection(
- id: Section.customCellProvider.id,
- footer: SPDiffableTextHeaderFooter(text: "Also you can add more providers for specific controller, and use default and custom specially for some contorllers."),
- items: [
- SPDiffableTableRow(text: "Custom Cell Provider", accessoryType: .disclosureIndicator, selectionStyle: .default, action: { [weak self] model, indexPath in
- guard let self = self else { return }
- self.tableView.deselectRow(at: indexPath, animated: true)
- })
- ]
- )
- content.append(cellProviderSection)
-
- return content
- }
-
- private var switchOn: Bool = false {
- didSet {
- print("Switch is on: \(switchOn)")
- updateContent(animated: true)
- }
- }
-
- private var stepperValue: Double = 0 {
- didSet {
- print("Stepper value is: \(stepperValue)")
- updateContent(animated: true)
- }
- }
-
- private var stepperValueIdentifier: String { return "Stepper Value Identifier" }
-}
-
diff --git a/Example Apps/iOS Example/Controllers/SideBarController.swift b/Example Apps/iOS Example/Controllers/SideBarController.swift
deleted file mode 100644
index ce9e65f..0000000
--- a/Example Apps/iOS Example/Controllers/SideBarController.swift
+++ /dev/null
@@ -1,128 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-import SPDiffable
-
-@available(iOS 14, *)
-class SidebarController: SPDiffableSideBarController {
-
- override func viewDidLoad() {
- super.viewDidLoad()
- configureDiffable(sections: content, cellProviders: SPDiffableCollectionDataSource.CellProvider.sideBar, headerAsFirstCell: true)
- }
-
- enum Section: String {
-
- case tabs
- case library
- case playlists
- }
-
- var content: [SPDiffableSection] {
- var content: [SPDiffableSection] = []
- content.append(
- SPDiffableSection(
- id: Section.tabs.rawValue,
- items: [
- SPDiffableSideBarItem(title: "Listen Now", image: UIImage(systemName: "play.circle"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Browse", image: UIImage(systemName: "square.grid.2x2"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Radio", image: UIImage(systemName: "dot.radiowaves.left.and.right"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Search", image: UIImage(systemName: "magnifyingglass"), action: { _, _ in
-
- }),
- SPDiffableSideBarButton(title: "Button", image: UIImage(systemName: "plus.square.fill"), action: { [weak self] _, _ in
- guard let self = self else { return }
- let controller = UIViewController()
- controller.view.backgroundColor = .systemBackground
- self.present(controller, animated: true, completion: nil)
- })
- ])
- )
- content.append(
- SPDiffableSection(
- id: Section.library.rawValue,
- header: SPDiffableSideBarHeader(text: "Library", accessories: [.outlineDisclosure()]),
- items: [
- SPDiffableSideBarItem(title: "Recently Added", image: UIImage(systemName: "clock"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Artists", image: UIImage(systemName: "music.mic"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Albums", image: UIImage(systemName: "rectangle.stack"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Songs", image: UIImage(systemName: "music.note"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Music Videos", image: UIImage(systemName: "tv.music.note"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "TV & Movies", image: UIImage(systemName: "tv"), action: { _, _ in })
- ])
- )
- content.append(
- SPDiffableSection(
- id: Section.playlists.rawValue,
- header: SPDiffableSideBarHeader(text: "Playlists", accessories: [.outlineDisclosure()]),
- items: [
- SPDiffableSideBarItem(title: "All Playlists", image: UIImage(systemName: "music.note.list"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Replay 2015", image: UIImage(systemName: "music.note.list"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Replay 2016", image: UIImage(systemName: "music.note.list"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Replay 2017", image: UIImage(systemName: "music.note.list"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Replay 2018", image: UIImage(systemName: "music.note.list"), action: { _, _ in }),
- SPDiffableSideBarItem(title: "Replay 2019", image: UIImage(systemName: "music.note.list"), action: { _, _ in })
- ])
- )
- return content
- }
-}
-
-@available(iOS 14, *)
-class SideBarSplitController: UISplitViewController {
-
- init() {
- super.init(style: .doubleColumn)
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- primaryBackgroundStyle = .sidebar
- preferredDisplayMode = .oneBesideSecondary
- presentsWithGesture = false
- preferredSplitBehavior = .tile
-
- let sideBarController = SidebarController()
- sideBarController.navigationItem.title = "Side Bar"
- sideBarController.navigationItem.rightBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .close, target: nil, action: #selector(self.dismissAnimated))
- let primaryController = UINavigationController(rootViewController: sideBarController)
- primaryController.navigationBar.prefersLargeTitles = true
- setViewController(primaryController, for: .primary)
-
- let controller = UIViewController()
- controller.view.backgroundColor = .systemBackground
- controller.navigationItem.title = "Secondary"
- let secondaryController = UINavigationController(rootViewController: controller)
- secondaryController.navigationBar.prefersLargeTitles = true
- setViewController(secondaryController, for: .secondary)
- }
-
- @objc func dismissAnimated() {
- self.dismiss(animated: true, completion: nil)
- }
-}
-
diff --git a/Example Apps/iOS Example/Entitlements.entitlements b/Example Apps/iOS Example/Entitlements.entitlements
deleted file mode 100644
index ee95ab7..0000000
--- a/Example Apps/iOS Example/Entitlements.entitlements
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
- com.apple.security.app-sandbox
-
- com.apple.security.network.client
-
-
-
diff --git a/Example Apps/iOS Example/Info.plist b/Example Apps/iOS Example/Info.plist
deleted file mode 100644
index 5a63475..0000000
--- a/Example Apps/iOS Example/Info.plist
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- $(DEVELOPMENT_LANGUAGE)
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- $(PRODUCT_BUNDLE_PACKAGE_TYPE)
- CFBundleShortVersionString
- 1.0
- CFBundleVersion
- 1
- LSRequiresIPhoneOS
-
- UILaunchStoryboardName
- LaunchScreen
- UIRequiredDeviceCapabilities
-
- armv7
-
- UISupportedInterfaceOrientations
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
- UISupportedInterfaceOrientations~ipad
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationPortraitUpsideDown
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
-
-
diff --git a/LICENSE b/LICENSE
index f61d0cc..a127164 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2020 Ivan Vorobei
+Copyright (c) 2023 Sparrow Code
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Package.swift b/Package.swift
index cd62cc1..b0aa185 100644
--- a/Package.swift
+++ b/Package.swift
@@ -3,24 +3,24 @@
import PackageDescription
let package = Package(
- name: "SPDiffable",
+ name: "DiffableKit",
platforms: [
- .iOS(.v12), .tvOS(.v12)
+ .iOS(.v14)
],
products: [
.library(
- name: "SPDiffable",
- targets: ["SPDiffable"]
- ),
+ name: "DiffableKit",
+ targets: ["DiffableKit"]
+ )
],
dependencies: [],
targets: [
.target(
- name: "SPDiffable",
+ name: "DiffableKit",
swiftSettings: [
- .define("SPDIFFABLE_SPM")
+ .define("DIFFABLEKIT_SPM")
]
- ),
+ )
],
swiftLanguageVersions: [.v5]
)
diff --git a/Readme.md b/Readme.md
index 930ced2..e404cd4 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,54 +1,56 @@
-# SPDiffable
-
-
-
-
-
+# SwiftBoost
+
+Collection of Swift-extensions to boost development process.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-Apple's diffable API requerid models for each object type. If you want use it in many place, you pass many time to implemenet and get over duplicates codes. This project help you do it elegant with shared models and special cell providers for one-usage models.
-
-## Navigate
-
-- [Installation](#installation)
- - [Swift Package Manager](#swift-package-manager)
- - [CocoaPods](#cocoapods)
- - [Manually](#manually)
-- [Russian Community](#russian-community)
-
## Installation
-Ready for use on iOS and tvOS 13+.
+Ready to use on iOS 13+, tvOS 13+, watchOS 6.0+.
### Swift Package Manager
-The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
+In Xcode go to Project -> Your Project Name -> `Package Dependencies` -> Tap *Plus*. Insert url:
+
+```
+https://github.com/sparrowcode/DiffableKit
+```
-Once you have your Swift package set up, adding as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.
+or adding it to the `dependencies` of your `Package.swift`:
```swift
dependencies: [
- .package(url: "https://github.com/ivanvorobei/SPDiffable", .upToNextMajor(from: "2.2.0"))
+ .package(url: "https://github.com/sparrowcode/DiffableKit", .upToNextMajor(from: "5.0.0"))
]
```
-### CocoaPods:
-
-[CocoaPods](https://cocoapods.org) is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your `Podfile`:
-
-```ruby
-pod 'SPDiffable'
-```
-
### Manually
-If you prefer not to use any of dependency managers, you can integrate manually. Put `Sources/SPDiffable` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`.
-
-## Russian Community
+If you prefer not to use any of dependency managers, you can integrate manually. Put `Sources/DiffableKit` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`.
-Я веду [телеграм-канал](https://sparrowcode.io/telegram), там публикую новости и туториалы.
-С проблемой помогут [в чате](https://sparrowcode.io/telegram/chat).
+## Apps Using
-Видео-туториалы выклыдываю на [YouTube](https://ivanvorobei.io/youtube):
+
+
+
+
+
+
+
+
+
-[](https://ivanvorobei.io/youtube)
+If you use a `SwiftBoost`, add your app via Pull Request.
\ No newline at end of file
diff --git a/SPDiffable.podspec b/SPDiffable.podspec
deleted file mode 100644
index 8f21658..0000000
--- a/SPDiffable.podspec
+++ /dev/null
@@ -1,17 +0,0 @@
-Pod::Spec.new do |s|
-
- s.name = 'SPDiffable'
- s.version = '4.1.2'
- s.summary = 'Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar.'
- s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
- s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }
- s.license = { :type => 'MIT', :file => "LICENSE" }
- s.author = { 'Ivan Vorobei' => 'hello@ivanvorobei.io' }
-
- s.swift_version = '5.1'
- s.ios.deployment_target = '12.0'
- s.tvos.deployment_target = '12.0'
-
- s.source_files = 'Sources/SPDiffable/**/*.swift'
-
-end
diff --git a/Sources/DiffableKit/Collection/DataSource/AppleCollectionDiffableDataSource.swift b/Sources/DiffableKit/Collection/DataSource/AppleCollectionDiffableDataSource.swift
new file mode 100644
index 0000000..b33714b
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/AppleCollectionDiffableDataSource.swift
@@ -0,0 +1,23 @@
+import UIKit
+
+class AppleCollectionDiffableDataSource: UICollectionViewDiffableDataSource {
+
+ // MARK: - Init
+
+ init(
+ collectionView: UICollectionView,
+ cellProvider: @escaping CellProvider,
+ headerFooterProvider: SupplementaryViewProvider?
+ ) {
+ super.init(collectionView: collectionView, cellProvider: cellProvider)
+ self.supplementaryViewProvider = headerFooterProvider
+ }
+
+ // MARK: - Wrappers
+
+ @available(tvOS 13.0, *)
+ typealias Snapshot = NSDiffableDataSourceSnapshot
+
+ @available(iOS 14.0, tvOS 14, *)
+ typealias SectionSnapshot = NSDiffableDataSourceSectionSnapshot
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/DiffableCollectinoDataSourceHeaderProcessWay.swift b/Sources/DiffableKit/Collection/DataSource/DiffableCollectinoDataSourceHeaderProcessWay.swift
new file mode 100644
index 0000000..077a8f2
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/DiffableCollectinoDataSourceHeaderProcessWay.swift
@@ -0,0 +1,7 @@
+import Foundation
+
+public enum DiffableCollectinoDataSourceHeaderProcessWay {
+
+ case normal
+ case headerIsFirstCell
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSoruce+UICollectionViewDelegateFlowLayout.swift b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSoruce+UICollectionViewDelegateFlowLayout.swift
new file mode 100644
index 0000000..7cedc11
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSoruce+UICollectionViewDelegateFlowLayout.swift
@@ -0,0 +1,12 @@
+import UIKit
+
+extension DiffableCollectionDataSource: UICollectionViewDelegateFlowLayout {
+
+ public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
+ return diffableLayoutDelegate?.diffableCollectionView(collectionView, layout: collectionViewLayout, sizeForItemAt: indexPath) ?? .zero
+ }
+
+ public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
+ return diffableLayoutDelegate?.diffableCollectionView(collectionView, layout: collectionViewLayout, insetForSectionAt: section) ?? .zero
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource+CellProvider.swift b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource+CellProvider.swift
new file mode 100644
index 0000000..fa5b60d
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource+CellProvider.swift
@@ -0,0 +1,132 @@
+import UIKit
+
+extension DiffableCollectionDataSource {
+
+ open class CellProvider {
+
+ open var clouser: Clouser
+
+ public init(clouser: @escaping Clouser) {
+ self.clouser = clouser
+ }
+
+ public typealias Clouser = (
+ _ collectionView: UICollectionView,
+ _ indexPath: IndexPath,
+ _ item: DiffableItem
+ ) -> UICollectionViewCell?
+
+ // MARK: - Ready Use
+
+ @available(iOS 14, *)
+ public static var sideBarItem: DiffableCollectionDataSource.CellProvider {
+ let cellRegistration = UICollectionView.CellRegistration { (cell, indexPath, item) in
+
+ var content = UIListContentConfiguration.sidebarCell()
+ content.text = item.title
+ content.image = item.image
+
+ switch item.higlight {
+ case .bg:
+ break
+ case .content:
+ content.textProperties.colorTransformer = UIConfigurationColorTransformer { _ in
+ if cell.isUserInteractionEnabled {
+ return .label.withAlphaComponent(cell.isHighlighted ? 0.5 : 1)
+ } else {
+ return UIColor.systemGray3
+ }
+ }
+
+ content.imageProperties.tintColorTransformer = UIConfigurationColorTransformer { _ in
+ if cell.isUserInteractionEnabled {
+ if #available(iOS 15.0, *) {
+ return .tintColor.withAlphaComponent(cell.isHighlighted ? 0.5 : 1)
+ } else {
+ return .systemBlue
+ }
+ } else {
+ return UIColor.systemGray3
+ }
+ }
+
+ var background = UIBackgroundConfiguration.clear()
+ background.strokeColor = .clear
+ background.backgroundColor = .clear
+ cell.backgroundConfiguration = background
+
+ if #available(iOS 15.0, *) {
+ cell.focusEffect = nil
+ }
+ }
+
+ cell.contentConfiguration = content
+ cell.accessories = item.accessories
+ cell.isUserInteractionEnabled = item.isEnabled
+ }
+ return DiffableCollectionDataSource.CellProvider() { (collectionView, indexPath, item) -> UICollectionViewCell? in
+ guard let item = item as? DiffableSideBarItem else { return nil }
+ let cell = collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
+ return cell
+ }
+ }
+
+ @available(iOS 14, *)
+ public static var sideBarButton: DiffableCollectionDataSource.CellProvider {
+ let cellRegistration = UICollectionView.CellRegistration { (cell, indexPath, item) in
+
+ var content = UIListContentConfiguration.sidebarCell()
+ content.text = item.title
+ content.image = item.image
+
+ let colorTransformer = UIConfigurationColorTransformer { _ in
+ if cell.isUserInteractionEnabled {
+ if #available(iOS 15.0, *) {
+ return .tintColor.withAlphaComponent(cell.isHighlighted ? 0.5 : 1)
+ } else {
+ return .systemBlue
+ }
+ } else {
+ return UIColor.systemGray3
+ }
+ }
+
+ content.textProperties.colorTransformer = colorTransformer
+ content.imageProperties.tintColorTransformer = colorTransformer
+ cell.contentConfiguration = content
+
+ var background = UIBackgroundConfiguration.clear()
+ background.strokeColor = .clear
+ background.backgroundColor = .clear
+ cell.backgroundConfiguration = background
+
+ cell.accessories = item.accessories
+ cell.isUserInteractionEnabled = item.isEnabled
+
+ if #available(iOS 15.0, *) {
+ cell.focusEffect = nil
+ }
+ }
+ return DiffableCollectionDataSource.CellProvider() { (collectionView, indexPath, item) -> UICollectionViewCell? in
+ guard let item = item as? DiffableSideBarButtonItem else { return nil }
+ let cell = collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
+ return cell
+ }
+ }
+
+ @available(iOS 14, *)
+ public static var sideBarHeader: DiffableCollectionDataSource.CellProvider {
+ let cellRegistration = UICollectionView.CellRegistration { (cell, indexPath, item) in
+ var content = UIListContentConfiguration.sidebarHeader()
+ content.text = item.text
+ content.image = nil
+ cell.contentConfiguration = content
+ cell.accessories = item.accessories
+ }
+ return DiffableCollectionDataSource.CellProvider() { (collectionView, indexPath, item) -> UICollectionViewCell? in
+ guard let item = item as? DiffableSideBarHeader else { return nil }
+ return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
+ }
+ }
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource+HeaderFooterProvider.swift b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource+HeaderFooterProvider.swift
new file mode 100644
index 0000000..cd678b9
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource+HeaderFooterProvider.swift
@@ -0,0 +1,19 @@
+import UIKit
+
+extension DiffableCollectionDataSource {
+
+ open class HeaderFooterProvider {
+
+ open var clouser: Clouser
+
+ public init(clouser: @escaping Clouser) {
+ self.clouser = clouser
+ }
+
+ public typealias Clouser = (
+ _ collectionView: UICollectionView,
+ _ section: Int,
+ _ item: DiffableItem
+ ) -> UICollectionReusableView?
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource+UICollectionViewDelegate.swift b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource+UICollectionViewDelegate.swift
new file mode 100644
index 0000000..743701a
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource+UICollectionViewDelegate.swift
@@ -0,0 +1,49 @@
+import UIKit
+
+extension DiffableCollectionDataSource: UICollectionViewDelegate {
+
+ #if os(iOS)
+ public func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
+ return self.diffableDelegate?.diffableCollectionView(collectionView, contextMenuConfigurationForItemAt: indexPath, point: point)
+ }
+ #endif
+
+ public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+ guard let item = getItem(indexPath: indexPath) else { return }
+ diffableDelegate?.diffableCollectionView(collectionView, didSelectItem: item, indexPath: indexPath)
+ switch item {
+ case let item as DiffableActionableItem:
+ item.action?(item, indexPath)
+ default:
+ break
+ }
+ }
+
+ public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
+ guard let item = getItem(indexPath: indexPath) else { return }
+ diffableDelegate?.diffableCollectionView(collectionView, didDeselectItem: item, indexPath: indexPath)
+ }
+
+ public func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool {
+ guard let item = getItem(indexPath: indexPath) else { fatalError() }
+ return diffableDelegate?.diffableCollectionView(collectionView, shouldHighlightItem: item, at: indexPath) ?? true
+ }
+
+ public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
+ guard let item = getItem(indexPath: indexPath) else { fatalError() }
+ return diffableDelegate?.diffableCollectionView(collectionView, shouldSelectItem: item, at: indexPath) ?? true
+ }
+
+ public func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveFromItemAt currentIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath {
+ guard let item = getItem(indexPath: currentIndexPath) else { fatalError() }
+ return diffableDelegate?.diffableCollectionView(collectionView, item: item, targetIndexPathForMoveFromItemAt: currentIndexPath, toProposedIndexPath: proposedIndexPath) ?? proposedIndexPath
+ }
+
+ public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
+ return diffableDelegate?.diffableCollectionView(collectionView, layout: collectionViewLayout, referenceSizeForHeaderInSection: section) ?? .zero
+ }
+
+ public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
+ return diffableDelegate?.diffableCollectionView(collectionView, layout: collectionViewLayout, referenceSizeForFooterInSection: section) ?? .zero
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource.swift b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource.swift
new file mode 100644
index 0000000..5266e79
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/DiffableCollectionDataSource.swift
@@ -0,0 +1,187 @@
+import UIKit
+
+@available(iOS 13.0, tvOS 13, *)
+open class DiffableCollectionDataSource: NSObject, DiffableDataSourceInterface {
+
+ open weak var diffableDelegate: DiffableCollectionDelegate? {
+ didSet {
+ if #available(iOS 14.0, *) {
+ if let delegate = self.diffableDelegate {
+ self.appleDiffableDataSource?.reorderingHandlers.canReorderItem = { item in
+ return self.diffableDelegate?.diffableCollectionViewCanReorderItem(item) ?? false
+ }
+ self.appleDiffableDataSource?.reorderingHandlers.willReorder = { transaction in
+ delegate.diffableCollectionViewWillReorder(transaction)
+ }
+ self.appleDiffableDataSource?.reorderingHandlers.didReorder = { transaction in
+ delegate.diffableCollectionViewDidReorder(transaction)
+ }
+ } else {
+ self.appleDiffableDataSource?.reorderingHandlers.canReorderItem = nil
+ self.appleDiffableDataSource?.reorderingHandlers.willReorder = nil
+ self.appleDiffableDataSource?.reorderingHandlers.didReorder = nil
+ }
+ }
+ }
+ }
+
+ open weak var diffableLayoutDelegate: DiffableCollectionViewDelegateFlowLayout?
+
+ private var appleDiffableDataSource: AppleCollectionDiffableDataSource?
+ private weak var collectionView: UICollectionView?
+
+ // MARK: - Init
+
+ public init(
+ collectionView: UICollectionView,
+ cellProviders: [CellProvider],
+ headerFooterProviders: [HeaderFooterProvider]
+ ) {
+ self.collectionView = collectionView
+
+ super.init()
+ self.appleDiffableDataSource = .init(
+ collectionView: collectionView,
+ cellProvider: { collectionView, indexPath, item in
+ for provider in cellProviders {
+ if let cell = provider.clouser(collectionView, indexPath, item) {
+ return cell
+ }
+ }
+ return nil
+ },
+ headerFooterProvider: { collectionView, elementKind, indexPath in
+ for provider in headerFooterProviders {
+ let sectionIndex = indexPath.section
+ guard let section = self.getSection(index: sectionIndex) else { break }
+ switch elementKind {
+ case UICollectionView.elementKindSectionHeader:
+ guard let headerItem = section.header else { continue }
+ if let view = provider.clouser(collectionView, sectionIndex, headerItem) {
+ return view
+ }
+ case UICollectionView.elementKindSectionFooter:
+ guard let footerItem = section.footer else { continue }
+ if let view = provider.clouser(collectionView, sectionIndex, footerItem) {
+ return view
+ }
+ default:
+ return nil
+ }
+ }
+ return nil
+ }
+ )
+
+ self.collectionView = collectionView
+ self.collectionView?.delegate = self
+ self.collectionView?.dragInteractionEnabled = true
+ }
+
+ // MARK: - DiffableDataSourceInterface
+
+ // MARK: Set
+
+ public func set(_ sections: [DiffableSection], animated: Bool, completion: (() -> Void)? = nil) {
+
+ let convertToSnapshot: ((_ sections: [DiffableSection]) -> AppleTableDiffableDataSource.Snapshot) = { sections in
+ var snapshot = AppleCollectionDiffableDataSource.Snapshot()
+ snapshot.appendSections(sections)
+ for section in sections {
+ snapshot.appendItems(section.items, toSection: section)
+ }
+ return snapshot
+ }
+
+ // 1. Add, remove & reoder
+
+ let newSnaphsot = convertToSnapshot(sections)
+ appleDiffableDataSource?.apply(newSnaphsot, animatingDifferences: animated, completion: completion)
+
+ // 2. Update visible cells
+
+ var items: [DiffableItem] = []
+ for indexPath in self.collectionView?.indexPathsForVisibleItems ?? [] {
+ if let item = getItem(indexPath: indexPath) {
+ items.append(item)
+ }
+ }
+
+ if !items.isEmpty {
+ reconfigure(items)
+ }
+
+ for section in sections {
+ var sectionSnapshot = AppleCollectionDiffableDataSource.SectionSnapshot()
+ if let collectionSection = section as? DiffableCollectionSection, collectionSection.headerProcess == .headerIsFirstCell {
+ if let header = section.header {
+ sectionSnapshot.append([header])
+ sectionSnapshot.append(section.items, to: header)
+ } else {
+ sectionSnapshot.append(section.items, to: nil)
+ }
+ } else {
+ sectionSnapshot.append(section.items)
+ }
+
+ if let section = section as? DiffableCollectionSection {
+ if section.expanded {
+ sectionSnapshot.expand(sectionSnapshot.items)
+ } else {
+ sectionSnapshot.collapse(sectionSnapshot.items)
+ }
+ } else {
+ sectionSnapshot.expand(sectionSnapshot.items)
+ }
+
+ appleDiffableDataSource?.apply(sectionSnapshot, to: section, animatingDifferences: animated)
+ }
+ }
+
+ public func reconfigure(_ items: [DiffableItem]) {
+ guard var snapshot = appleDiffableDataSource?.snapshot() else { return }
+ if #available(iOS 15.0, tvOS 15, *) {
+ snapshot.reconfigureItems(items)
+ } else {
+ snapshot.reloadItems(items)
+ }
+ appleDiffableDataSource?.apply(snapshot, animatingDifferences: true)
+ }
+
+ // MARK: Get
+
+ public func getItem(id: String) -> DiffableItem? {
+ let snapshot = appleDiffableDataSource?.snapshot()
+ return snapshot?.itemIdentifiers.first(where: { $0.id == id })
+ }
+
+ public func getItem(indexPath: IndexPath) -> DiffableItem? {
+ return appleDiffableDataSource?.itemIdentifier(for: indexPath)
+ }
+
+ public func getSection(id: String) -> DiffableSection? {
+ return appleDiffableDataSource?.snapshot().sectionIdentifiers.first(where: { $0.id == id })
+ }
+
+ public func getSection(index: Int) -> DiffableSection? {
+ if #available(iOS 15.0, *) {
+ return appleDiffableDataSource?.sectionIdentifier(for: index)
+ } else {
+ guard let snapshot = appleDiffableDataSource?.snapshot() else { return nil }
+ guard index < snapshot.sectionIdentifiers.count else { return nil }
+ return snapshot.sectionIdentifiers[index]
+ }
+ }
+
+ public func getIndexPath(id: String) -> IndexPath? {
+ guard let item = getItem(id: id) else { return nil }
+ return appleDiffableDataSource?.indexPath(for: item)
+ }
+
+ public func getIndexPath(item: DiffableItem) -> IndexPath? {
+ return appleDiffableDataSource?.indexPath(for: item)
+ }
+
+ @available(iOS 14.0, *)
+ public typealias Transaction = (NSDiffableDataSourceTransaction)
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/Models/DiffableCollectionSection.swift b/Sources/DiffableKit/Collection/DataSource/Models/DiffableCollectionSection.swift
new file mode 100644
index 0000000..25bbd8a
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/Models/DiffableCollectionSection.swift
@@ -0,0 +1,22 @@
+import UIKit
+
+open class DiffableCollectionSection: DiffableSection {
+
+ open var headerProcess: DiffableCollectinoDataSourceHeaderProcessWay
+ open var expanded: Bool
+
+ // MARK: - Init
+
+ public init(
+ id: String,
+ header: DiffableItem? = nil,
+ headerProcess: DiffableCollectinoDataSourceHeaderProcessWay,
+ footer: DiffableItem? = nil,
+ items: [DiffableItem] = [],
+ expanded: Bool = true
+ ) {
+ self.headerProcess = headerProcess
+ self.expanded = expanded
+ super.init(id: id, header: header, footer: footer, items: items)
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/Models/SideBar/DiffableSideBarButtonItem.swift b/Sources/DiffableKit/Collection/DataSource/Models/SideBar/DiffableSideBarButtonItem.swift
new file mode 100644
index 0000000..b459808
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/Models/SideBar/DiffableSideBarButtonItem.swift
@@ -0,0 +1,18 @@
+import UIKit
+
+@available(iOS 14, *)
+open class DiffableSideBarButtonItem: DiffableActionableItem {
+
+ open var title: String
+ open var image: UIImage?
+ open var isEnabled: Bool
+ open var accessories: [UICellAccessory]
+
+ public init(id: String? = nil, title: String, image: UIImage?, isEnabled: Bool = true, accessories: [UICellAccessory] = [], action: @escaping Action) {
+ self.title = title
+ self.image = image
+ self.isEnabled = isEnabled
+ self.accessories = accessories
+ super.init(id: id ?? title, action: action)
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/Models/SideBar/DiffableSideBarHeader.swift b/Sources/DiffableKit/Collection/DataSource/Models/SideBar/DiffableSideBarHeader.swift
new file mode 100644
index 0000000..05e5322
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/Models/SideBar/DiffableSideBarHeader.swift
@@ -0,0 +1,14 @@
+import UIKit
+
+@available(iOS 14, *)
+open class DiffableSideBarHeader: DiffableItem {
+
+ open var text: String
+ open var accessories: [UICellAccessory]
+
+ public init(id: String? = nil, text: String, accessories: [UICellAccessory] = []) {
+ self.text = text
+ self.accessories = accessories
+ super.init(id: id ?? text)
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DataSource/Models/SideBar/DiffableSideBarItem.swift b/Sources/DiffableKit/Collection/DataSource/Models/SideBar/DiffableSideBarItem.swift
new file mode 100644
index 0000000..fcf9f72
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DataSource/Models/SideBar/DiffableSideBarItem.swift
@@ -0,0 +1,26 @@
+import UIKit
+
+@available(iOS 14, *)
+open class DiffableSideBarItem: DiffableActionableItem {
+
+ open var title: String
+ open var image: UIImage?
+ open var isEnabled: Bool
+ open var higlight: Higlight
+ open var accessories: [UICellAccessory]
+
+ public init(id: String? = nil, title: String, image: UIImage?, isEnabled: Bool = true, higlight: Higlight = .bg, accessories: [UICellAccessory] = [], action: @escaping Action) {
+ self.title = title
+ self.image = image
+ self.isEnabled = isEnabled
+ self.higlight = higlight
+ self.accessories = accessories
+ super.init(id: id ?? title, action: action)
+ }
+
+ public enum Higlight {
+
+ case bg
+ case content
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DiffableCollectionController.swift b/Sources/DiffableKit/Collection/DiffableCollectionController.swift
new file mode 100644
index 0000000..90783b3
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DiffableCollectionController.swift
@@ -0,0 +1,28 @@
+import UIKit
+
+open class DiffableCollectionController: UICollectionViewController {
+
+ open var diffableDataSource: DiffableCollectionDataSource?
+
+ // MARK: - Lifecycle
+
+ open override func viewDidLoad() {
+ super.viewDidLoad()
+ collectionView.delaysContentTouches = false
+ }
+
+ // MARK: - Configure
+
+ open func configureDiffable(
+ sections: [DiffableSection],
+ cellProviders: [DiffableCollectionDataSource.CellProvider],
+ headerFooterProviders: [DiffableCollectionDataSource.HeaderFooterProvider] = []
+ ) {
+ diffableDataSource = DiffableCollectionDataSource(
+ collectionView: collectionView,
+ cellProviders: cellProviders,
+ headerFooterProviders: headerFooterProviders
+ )
+ diffableDataSource?.set(sections, animated: false)
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DiffableCollectionDelegate.swift b/Sources/DiffableKit/Collection/DiffableCollectionDelegate.swift
new file mode 100644
index 0000000..d303b57
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DiffableCollectionDelegate.swift
@@ -0,0 +1,66 @@
+import UIKit
+
+public protocol DiffableCollectionDelegate: AnyObject {
+
+ func diffableCollectionView(_ collectionView: UICollectionView, didSelectItem item: DiffableItem, indexPath: IndexPath)
+
+ func diffableCollectionView(_ collectionView: UICollectionView, didDeselectItem item: DiffableItem, indexPath: IndexPath)
+
+ #if canImport(UIKit) && (os(iOS))
+ func diffableCollectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration?
+ #endif
+
+ func diffableCollectionView(_ collectionView: UICollectionView, item: DiffableItem, targetIndexPathForMoveFromItemAt currentIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath
+
+ func diffableCollectionView(_ collectionView: UICollectionView, shouldHighlightItem item: DiffableItem, at indexPath: IndexPath) -> Bool
+
+ func diffableCollectionView(_ collectionView: UICollectionView, shouldSelectItem item: DiffableItem, at indexPath: IndexPath) -> Bool
+
+ // MARK: - Reordering Handlers
+
+ // New API of reoder.
+ // Can work together with UIDrag & UIDrop Delegates.
+ @available(iOS 14.0, *)
+ func diffableCollectionViewCanReorderItem(_ item: DiffableItem) -> Bool
+ @available(iOS 14.0, *)
+ func diffableCollectionViewWillReorder(_ transaction: DiffableCollectionDataSource.Transaction) -> Void
+ @available(iOS 14.0, *)
+ func diffableCollectionViewDidReorder(_ transaction: DiffableCollectionDataSource.Transaction) -> Void
+
+ // MARK: - Layout
+
+ func diffableCollectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize
+
+ func diffableCollectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize
+}
+
+public extension DiffableCollectionDelegate {
+
+ func diffableCollectionView(_ collectionView: UICollectionView, didSelectItem item: DiffableItem, indexPath: IndexPath) {}
+ func diffableCollectionView(_ collectionView: UICollectionView, didDeselectItem item: DiffableItem, indexPath: IndexPath) {}
+
+ #if canImport(UIKit) && (os(iOS))
+ func diffableCollectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { return nil }
+ #endif
+
+ func diffableCollectionView(_ collectionView: UICollectionView, item: DiffableItem, targetIndexPathForMoveFromItemAt currentIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath { return proposedIndexPath }
+
+ func diffableCollectionView(_ collectionView: UICollectionView, shouldHighlightItem item: DiffableItem, at indexPath: IndexPath) -> Bool { return true }
+
+ func diffableCollectionView(_ collectionView: UICollectionView, shouldSelectItem item: DiffableItem, at indexPath: IndexPath) -> Bool { return true }
+
+ // MARK: - Reordering Handlers
+
+ @available(iOS 14.0, *)
+ func diffableCollectionViewCanReorderItem(_ item: DiffableItem) -> Bool { return false }
+ @available(iOS 14.0, *)
+ func diffableCollectionViewWillReorder(_ transaction: DiffableCollectionDataSource.Transaction) -> Void {}
+ @available(iOS 14.0, *)
+ func diffableCollectionViewDidReorder(_ transaction: DiffableCollectionDataSource.Transaction) -> Void {}
+
+ // MARK: - Layout
+
+ func diffableCollectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { return .zero }
+
+ func diffableCollectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { return .zero }
+}
diff --git a/Sources/DiffableKit/Collection/DiffableCollectionView.swift b/Sources/DiffableKit/Collection/DiffableCollectionView.swift
new file mode 100644
index 0000000..129a564
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DiffableCollectionView.swift
@@ -0,0 +1,41 @@
+import UIKit
+
+@available(iOS 13.0, tvOS 13, *)
+open class DiffableCollectionView: UICollectionView {
+
+ open var diffableDataSource: DiffableCollectionDataSource?
+
+ // MARK: - Init
+
+ public init() {
+ super.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
+ commonInit()
+ }
+
+ required public init?(coder: NSCoder) {
+ super.init(coder: coder)
+ commonInit()
+ }
+
+ private func commonInit() {
+ backgroundColor = .clear
+ showsHorizontalScrollIndicator = false
+ showsVerticalScrollIndicator = false
+ delaysContentTouches = false
+ }
+
+ // MARK: - Configure
+
+ open func configureDiffable(
+ sections: [DiffableSection],
+ cellProviders: [DiffableCollectionDataSource.CellProvider],
+ headerFooterProviders: [DiffableCollectionDataSource.HeaderFooterProvider] = []
+ ) {
+ diffableDataSource = DiffableCollectionDataSource(
+ collectionView: self,
+ cellProviders: cellProviders,
+ headerFooterProviders: headerFooterProviders
+ )
+ diffableDataSource?.set(sections, animated: false)
+ }
+}
diff --git a/Sources/DiffableKit/Collection/DiffableCollectionViewDelegateFlowLayout.swift b/Sources/DiffableKit/Collection/DiffableCollectionViewDelegateFlowLayout.swift
new file mode 100644
index 0000000..1d1c68c
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DiffableCollectionViewDelegateFlowLayout.swift
@@ -0,0 +1,15 @@
+import UIKit
+
+public protocol DiffableCollectionViewDelegateFlowLayout: AnyObject {
+
+ func diffableCollectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
+
+ func diffableCollectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets
+}
+
+public extension DiffableCollectionViewDelegateFlowLayout {
+
+ func diffableCollectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return .zero }
+
+ func diffableCollectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { return .zero }
+}
diff --git a/Sources/DiffableKit/Collection/DiffableSideBarController.swift b/Sources/DiffableKit/Collection/DiffableSideBarController.swift
new file mode 100644
index 0000000..aace155
--- /dev/null
+++ b/Sources/DiffableKit/Collection/DiffableSideBarController.swift
@@ -0,0 +1,34 @@
+import UIKit
+
+@available(iOS 14, *)
+open class DiffableSideBarController: DiffableCollectionController {
+
+ // MARK: - Init
+
+ public init() {
+ super.init(collectionViewLayout: UICollectionViewFlowLayout())
+ commonInit()
+ }
+
+ public required init?(coder: NSCoder) {
+ super.init(coder: coder)
+ commonInit()
+ }
+
+ private func commonInit() {
+ collectionView.setCollectionViewLayout(makeLayout(), animated: false)
+ }
+
+ // MARK: - Layout
+
+ private func makeLayout() -> UICollectionViewCompositionalLayout {
+ return UICollectionViewCompositionalLayout { [weak self] (section, layoutEnvironment) -> NSCollectionLayoutSection? in
+ var configuration = UICollectionLayoutListConfiguration(appearance: .sidebar)
+ let header = self?.diffableDataSource?.getSection(index: section)?.header
+ configuration.headerMode = (header == nil) ? .none : .firstItemInSection
+ let footer = self?.diffableDataSource?.getSection(index: section)?.footer
+ configuration.footerMode = (footer == nil) ? .none : .supplementary
+ return NSCollectionLayoutSection.list(using: configuration, layoutEnvironment: layoutEnvironment)
+ }
+ }
+}
diff --git a/Sources/DiffableKit/DiffableDataSourceInterface.swift b/Sources/DiffableKit/DiffableDataSourceInterface.swift
new file mode 100644
index 0000000..3d80cc1
--- /dev/null
+++ b/Sources/DiffableKit/DiffableDataSourceInterface.swift
@@ -0,0 +1,18 @@
+import UIKit
+
+@available(iOS 13.0, *)
+public protocol DiffableDataSourceInterface: AnyObject {
+
+ // MARK: - Set
+
+ func set(_ sections: [DiffableSection], animated: Bool, completion: (() -> Void)?)
+
+ // MARK: - Get
+
+ func getItem(id: String) -> DiffableItem?
+ func getItem(indexPath: IndexPath) -> DiffableItem?
+ func getSection(id: String) -> DiffableSection?
+ func getSection(index: Int) -> DiffableSection?
+ func getIndexPath(id: String) -> IndexPath?
+ func getIndexPath(item: DiffableItem) -> IndexPath?
+}
diff --git a/Sources/DiffableKit/Models/DiffableActionableItem.swift b/Sources/DiffableKit/Models/DiffableActionableItem.swift
new file mode 100644
index 0000000..caf689a
--- /dev/null
+++ b/Sources/DiffableKit/Models/DiffableActionableItem.swift
@@ -0,0 +1,13 @@
+import UIKit
+
+open class DiffableActionableItem: DiffableItem {
+
+ open var action: Action?
+
+ public init(id: String, action: Action? = nil) {
+ self.action = action
+ super.init(id: id)
+ }
+
+ public typealias Action = (_ item: DiffableItem, _ indexPath: IndexPath) -> Void
+}
diff --git a/Sources/DiffableKit/Models/DiffableItem.swift b/Sources/DiffableKit/Models/DiffableItem.swift
new file mode 100644
index 0000000..2d06080
--- /dev/null
+++ b/Sources/DiffableKit/Models/DiffableItem.swift
@@ -0,0 +1,25 @@
+import UIKit
+
+open class DiffableItem: NSObject {
+
+ open var id: String
+
+ // MARK: - Init
+
+ public init(id: String) {
+ self.id = id
+ }
+
+ // MARK: - Hashable and Equatable
+
+ open override var hash: Int {
+ var hasher = Hasher()
+ hasher.combine(id)
+ return hasher.finalize()
+ }
+
+ open override func isEqual(_ object: Any?) -> Bool {
+ guard let object = object as? DiffableItem else { return false }
+ return id == object.id
+ }
+}
diff --git a/Sources/DiffableKit/Models/DiffableSection.swift b/Sources/DiffableKit/Models/DiffableSection.swift
new file mode 100644
index 0000000..b9770af
--- /dev/null
+++ b/Sources/DiffableKit/Models/DiffableSection.swift
@@ -0,0 +1,37 @@
+import UIKit
+
+open class DiffableSection: NSObject {
+
+ open var id: String
+
+ open var header: DiffableItem?
+ open var footer: DiffableItem?
+ open var items: [DiffableItem]
+
+ // MARK: - Init
+
+ public init(
+ id: String,
+ header: DiffableItem? = nil,
+ footer: DiffableItem? = nil,
+ items: [DiffableItem] = []
+ ) {
+ self.id = id
+ self.header = header
+ self.footer = footer
+ self.items = items
+ }
+
+ // MARK: - Hashable and Equatable
+
+ open override var hash: Int {
+ var hasher = Hasher()
+ hasher.combine(id)
+ return hasher.finalize()
+ }
+
+ open override func isEqual(_ object: Any?) -> Bool {
+ guard let object = object as? DiffableSection else { return false }
+ return id == object.id
+ }
+}
diff --git a/Sources/DiffableKit/Models/DiffableTextHeaderFooter.swift b/Sources/DiffableKit/Models/DiffableTextHeaderFooter.swift
new file mode 100644
index 0000000..9752931
--- /dev/null
+++ b/Sources/DiffableKit/Models/DiffableTextHeaderFooter.swift
@@ -0,0 +1,11 @@
+import UIKit
+
+open class DiffableTextHeaderFooter: DiffableItem {
+
+ open var text: String
+
+ public init(id: String? = nil, text: String) {
+ self.text = text
+ super.init(id: id ?? text)
+ }
+}
diff --git a/Sources/DiffableKit/Models/DiffableWrapperItem.swift b/Sources/DiffableKit/Models/DiffableWrapperItem.swift
new file mode 100644
index 0000000..511e958
--- /dev/null
+++ b/Sources/DiffableKit/Models/DiffableWrapperItem.swift
@@ -0,0 +1,12 @@
+import UIKit
+
+open class DiffableWrapperItem: DiffableActionableItem {
+
+ open var model: Any
+
+ public init(id: String, model: Any, action: Action? = nil) {
+ self.model = model
+ super.init(id: id, action: action)
+ }
+}
+
diff --git a/Sources/DiffableKit/Table/Cells/DiffableTableSubtitleViewCell.swift b/Sources/DiffableKit/Table/Cells/DiffableTableSubtitleViewCell.swift
new file mode 100644
index 0000000..c876820
--- /dev/null
+++ b/Sources/DiffableKit/Table/Cells/DiffableTableSubtitleViewCell.swift
@@ -0,0 +1,21 @@
+import UIKit
+
+open class DiffableTableSubtitleViewCell: UITableViewCell {
+
+ public static let reuseIdentifier = "DiffableTableSubtitleViewCell"
+
+ public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+ super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
+ }
+
+ public required init?(coder: NSCoder) {
+ super.init(coder: coder)
+ }
+
+ open override func prepareForReuse() {
+ super.prepareForReuse()
+ accessoryView = nil
+ textLabel?.text = nil
+ detailTextLabel?.text = nil
+ }
+}
diff --git a/Sources/DiffableKit/Table/Cells/DiffableTableViewCell.swift b/Sources/DiffableKit/Table/Cells/DiffableTableViewCell.swift
new file mode 100644
index 0000000..53d50bf
--- /dev/null
+++ b/Sources/DiffableKit/Table/Cells/DiffableTableViewCell.swift
@@ -0,0 +1,21 @@
+import UIKit
+
+open class DiffableTableViewCell: UITableViewCell {
+
+ public static var reuseIdentifier: String { "DiffableTableViewCell" }
+
+ public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+ super.init(style: .value1, reuseIdentifier: reuseIdentifier)
+ }
+
+ public required init?(coder: NSCoder) {
+ super.init(coder: coder)
+ }
+
+ open override func prepareForReuse() {
+ super.prepareForReuse()
+ accessoryView = nil
+ textLabel?.text = nil
+ detailTextLabel?.text = nil
+ }
+}
diff --git a/Sources/DiffableKit/Table/Cells/Views/DiffableStepper.swift b/Sources/DiffableKit/Table/Cells/Views/DiffableStepper.swift
new file mode 100644
index 0000000..4f7bf61
--- /dev/null
+++ b/Sources/DiffableKit/Table/Cells/Views/DiffableStepper.swift
@@ -0,0 +1,22 @@
+#if canImport(UIKit) && os(iOS)
+import UIKit
+
+open class DiffableStepper: UIStepper {
+
+ var action: (_ value: Double) -> Void = { _ in }
+
+ public init() {
+ super.init(frame: .zero)
+ addTarget(self, action: #selector(self.valueChanged), for: .valueChanged)
+ }
+
+ required public init?(coder: NSCoder) {
+ self.action = { _ in }
+ super.init(coder: coder)
+ }
+
+ @objc func valueChanged() {
+ action(value)
+ }
+}
+#endif
diff --git a/Sources/DiffableKit/Table/Cells/Views/DiffableSwitch.swift b/Sources/DiffableKit/Table/Cells/Views/DiffableSwitch.swift
new file mode 100644
index 0000000..9fc8541
--- /dev/null
+++ b/Sources/DiffableKit/Table/Cells/Views/DiffableSwitch.swift
@@ -0,0 +1,22 @@
+#if canImport(UIKit) && os(iOS)
+import UIKit
+
+open class DiffableSwitch: UISwitch {
+
+ public var action: (_ state: Bool) -> Void = { _ in }
+
+ public init() {
+ super.init(frame: .zero)
+ addTarget(self, action: #selector(self.valueChanged), for: .valueChanged)
+ }
+
+ required public init?(coder: NSCoder) {
+ self.action = { _ in }
+ super.init(coder: coder)
+ }
+
+ @objc func valueChanged() {
+ action(isOn)
+ }
+}
+#endif
diff --git a/Sources/DiffableKit/Table/DataSource/AppleTableDiffableDataSource.swift b/Sources/DiffableKit/Table/DataSource/AppleTableDiffableDataSource.swift
new file mode 100644
index 0000000..112d41c
--- /dev/null
+++ b/Sources/DiffableKit/Table/DataSource/AppleTableDiffableDataSource.swift
@@ -0,0 +1,44 @@
+import UIKit
+
+class AppleTableDiffableDataSource: UITableViewDiffableDataSource {
+
+ // MARK: - Init
+
+ override init(
+ tableView: UITableView,
+ cellProvider: @escaping CellProvider
+ ) {
+ super.init(tableView: tableView, cellProvider: cellProvider)
+ }
+
+ // MARK: - Wrappers
+
+ typealias Snapshot = NSDiffableDataSourceSnapshot
+
+ // MARK: - Ovveride
+
+ override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
+ if let header = snapshot().sectionIdentifiers[section].header as? DiffableTextHeaderFooter {
+ return header.text
+ }
+ return nil
+ }
+
+ override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
+ if let footer = snapshot().sectionIdentifiers[section].footer as? DiffableTextHeaderFooter {
+ return footer.text
+ }
+ return nil
+ }
+
+ #warning("to methods move it")
+ override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
+ return true
+ }
+
+#warning("to methods move it")
+ override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
+
+ }
+
+}
diff --git a/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+CellProvider.swift b/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+CellProvider.swift
new file mode 100644
index 0000000..c330a8e
--- /dev/null
+++ b/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+CellProvider.swift
@@ -0,0 +1,108 @@
+import UIKit
+
+extension DiffableTableDataSource {
+
+ open class CellProvider {
+
+ open var clouser: Clouser
+
+ public init(clouser: @escaping Clouser) {
+ self.clouser = clouser
+ }
+
+ public typealias Clouser = (
+ _ tableView: UITableView,
+ _ indexPath: IndexPath,
+ _ item: DiffableItem
+ ) -> UITableViewCell?
+
+ // MARK: - Ready Use
+
+ public static var rowDetail: CellProvider {
+ return CellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
+ guard let item = item as? DiffableTableRow else { return nil }
+ let cell = tableView.dequeueReusableCell(withIdentifier: DiffableTableViewCell.reuseIdentifier, for: indexPath) as! DiffableTableViewCell
+ cell.textLabel?.text = item.text
+ cell.detailTextLabel?.text = item.detail
+ cell.imageView?.image = item.icon
+ cell.accessoryType = item.accessoryType
+ cell.selectionStyle = item.selectionStyle
+ return cell
+ }
+ }
+
+ public static var rowSubtitle: CellProvider {
+ return CellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
+ guard let item = item as? DiffableTableRowSubtitle else { return nil }
+ let cell = tableView.dequeueReusableCell(withIdentifier: DiffableTableSubtitleViewCell.reuseIdentifier, for: indexPath) as! DiffableTableSubtitleViewCell
+ cell.textLabel?.text = item.text
+ cell.detailTextLabel?.text = item.subtitle
+ cell.imageView?.image = item.icon
+ cell.accessoryType = item.accessoryType
+ cell.selectionStyle = item.selectionStyle
+ return cell
+ }
+ }
+
+ #if os(iOS)
+ public static var `switch`: CellProvider {
+ return CellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
+ guard let item = item as? DiffableTableRowSwitch else { return nil }
+ let cell = tableView.dequeueReusableCell(withIdentifier: DiffableTableViewCell.reuseIdentifier, for: indexPath) as! DiffableTableViewCell
+
+ cell.textLabel?.text = item.text
+ cell.imageView?.image = item.icon
+ cell.selectionStyle = .none
+
+ let configureControl: (_ control: DiffableSwitch) -> Void = { control in
+ control.isOn = item.isOn
+ control.action = { value in
+ item.action(item, indexPath, value)
+ }
+ }
+
+ if let control = cell.accessoryView as? DiffableSwitch {
+ configureControl(control)
+ } else {
+ let control = DiffableSwitch()
+ configureControl(control)
+ cell.accessoryView = control
+ }
+
+ return cell
+ }
+ }
+
+ public static var stepper: CellProvider {
+ return CellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
+ guard let item = item as? DiffableTableRowStepper else { return nil }
+ let cell = tableView.dequeueReusableCell(withIdentifier: DiffableTableViewCell.reuseIdentifier, for: indexPath) as! DiffableTableViewCell
+
+ cell.textLabel?.text = item.text
+ cell.imageView?.image = item.icon
+ cell.selectionStyle = .none
+
+ let configureControl: (_ control: DiffableStepper) -> Void = { control in
+ control.stepValue = item.stepValue
+ control.value = item.value
+ control.minimumValue = item.minimumValue
+ control.maximumValue = item.maximumValue
+ control.action = { value in
+ item.action(item, indexPath, value)
+ }
+ }
+
+ if let control = cell.accessoryView as? DiffableStepper {
+ configureControl(control)
+ } else {
+ let control = DiffableStepper()
+ configureControl(control)
+ cell.accessoryView = control
+ }
+
+ return cell
+ }
+ }
+ #endif
+ }
+}
diff --git a/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+HeaderFooterProvider.swift b/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+HeaderFooterProvider.swift
new file mode 100644
index 0000000..f9c58a1
--- /dev/null
+++ b/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+HeaderFooterProvider.swift
@@ -0,0 +1,19 @@
+import UIKit
+
+extension DiffableTableDataSource {
+
+ open class HeaderFooterProvider {
+
+ open var clouser: Clouser
+
+ public init(clouser: @escaping Clouser) {
+ self.clouser = clouser
+ }
+
+ public typealias Clouser = (
+ _ tableView: UITableView,
+ _ section: Int,
+ _ item: DiffableItem
+ ) -> UIView?
+ }
+}
diff --git a/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource+UITableViewDelegate.swift b/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+UITableViewDelegate.swift
similarity index 59%
rename from Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource+UITableViewDelegate.swift
rename to Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+UITableViewDelegate.swift
index d103628..c198bad 100644
--- a/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource+UITableViewDelegate.swift
+++ b/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+UITableViewDelegate.swift
@@ -1,35 +1,13 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
import UIKit
-@available(iOS 13.0, tvOS 13, *)
-extension SPDiffableTableDataSource: UITableViewDelegate {
+extension DiffableTableDataSource: UITableViewDelegate {
open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let item = getItem(indexPath: indexPath) else { return }
diffableDelegate?.diffableTableView?(tableView, didSelectItem: item, indexPath: indexPath)
switch item {
- case let model as SPDiffableItemActionable:
+ case let model as DiffableActionableItem :
model.action?(item, indexPath)
default:
break
@@ -67,4 +45,14 @@ extension SPDiffableTableDataSource: UITableViewDelegate {
}
return nil
}
+
+ open func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool {
+ guard let item = getItem(indexPath: indexPath) else { return false }
+ return diffableDelegate?.diffableTableView?(tableView, shouldIndentWhileEditingItem: item, indexPath: indexPath) ?? false
+ }
+
+ open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
+ guard let item = getItem(indexPath: indexPath) else { return .none }
+ return diffableDelegate?.diffableTableView?(tableView, editingStyleForItem: item, indexPath: indexPath) ?? .none
+ }
}
diff --git a/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource.swift b/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource.swift
new file mode 100644
index 0000000..33aceab
--- /dev/null
+++ b/Sources/DiffableKit/Table/DataSource/DiffableTableDataSource.swift
@@ -0,0 +1,134 @@
+import UIKit
+
+@available(iOS 13.0, tvOS 13, *)
+open class DiffableTableDataSource: NSObject, DiffableDataSourceInterface {
+
+ open weak var diffableDelegate: DiffableTableDelegate?
+
+ internal var headerFooterProviders: [HeaderFooterProvider]
+ private var appleDiffableDataSource: AppleTableDiffableDataSource?
+ private weak var tableView: UITableView?
+
+ // MARK: - Init
+
+ public init(
+ tableView: UITableView,
+ cellProviders: [CellProvider],
+ headerFooterProviders: [HeaderFooterProvider]
+ ) {
+
+ // Table doesn't have `supplementaryViewProvider`. Did it manually.
+ self.headerFooterProviders = headerFooterProviders
+
+ super.init()
+
+ self.appleDiffableDataSource = .init(
+ tableView: tableView,
+ cellProvider: { tableView, indexPath, item in
+ for provider in cellProviders {
+ if let cell = provider.clouser(tableView, indexPath, item) {
+ return cell
+ }
+ }
+ return nil
+ }
+ )
+
+ self.tableView = tableView
+ self.tableView?.delegate = self
+ }
+
+ // MARK: - DiffableDataSourceInterface
+
+ public func updateLayout(animated: Bool, completion: (() -> Void)? = nil) {
+ guard let snapshot = appleDiffableDataSource?.snapshot() else { return }
+ appleDiffableDataSource?.apply(snapshot, animatingDifferences: animated, completion: completion)
+ }
+
+ // MARK: Set
+
+ public func set(_ sections: [DiffableSection], animated: Bool, completion: (() -> Void)? = nil) {
+
+ let convertToSnapshot: ((_ sections: [DiffableSection]) -> AppleTableDiffableDataSource.Snapshot) = { sections in
+ var snapshot = AppleTableDiffableDataSource.Snapshot()
+ snapshot.appendSections(sections)
+ for section in sections {
+ snapshot.appendItems(section.items, toSection: section)
+ }
+ return snapshot
+ }
+
+ // 1. Add, remove & reoder
+
+ let newSnaphsot = convertToSnapshot(sections)
+ appleDiffableDataSource?.apply(newSnaphsot, animatingDifferences: animated, completion: completion)
+
+ // 2. Update visible cells
+
+ var items: [DiffableItem] = []
+ for indexPath in self.tableView?.indexPathsForVisibleRows ?? [] {
+ if let item = getItem(indexPath: indexPath) {
+ items.append(item)
+ }
+ }
+
+ if !items.isEmpty {
+ reconfigure(items)
+ }
+ }
+
+ public func reconfigureVisibleItems() {
+ let visibleIndexPaths = tableView?.indexPathsForVisibleRows ?? []
+ var visibleItems: [DiffableItem] = []
+ for indexPath in visibleIndexPaths {
+ if let item = getItem(indexPath: indexPath) {
+ visibleItems.append(item)
+ }
+ }
+ reconfigure(visibleItems)
+ }
+
+ public func reconfigure(_ items: [DiffableItem]) {
+ guard var snapshot = appleDiffableDataSource?.snapshot() else { return }
+ if #available(iOS 15.0, tvOS 15, *) {
+ snapshot.reconfigureItems(items)
+ } else {
+ snapshot.reloadItems(items)
+ }
+ appleDiffableDataSource?.apply(snapshot, animatingDifferences: true)
+ }
+
+ // MARK: Get
+
+ public func getItem(id: String) -> DiffableItem? {
+ let snapshot = appleDiffableDataSource?.snapshot()
+ return snapshot?.itemIdentifiers.first(where: { $0.id == id })
+ }
+
+ public func getItem(indexPath: IndexPath) -> DiffableItem? {
+ return appleDiffableDataSource?.itemIdentifier(for: indexPath)
+ }
+
+ public func getSection(id: String) -> DiffableSection? {
+ return appleDiffableDataSource?.snapshot().sectionIdentifiers.first(where: { $0.id == id })
+ }
+
+ public func getSection(index: Int) -> DiffableSection? {
+ if #available(iOS 15.0, *) {
+ return appleDiffableDataSource?.sectionIdentifier(for: index)
+ } else {
+ guard let snapshot = appleDiffableDataSource?.snapshot() else { return nil }
+ guard index < snapshot.sectionIdentifiers.count else { return nil }
+ return snapshot.sectionIdentifiers[index]
+ }
+ }
+
+ public func getIndexPath(id: String) -> IndexPath? {
+ guard let item = getItem(id: id) else { return nil }
+ return appleDiffableDataSource?.indexPath(for: item)
+ }
+
+ public func getIndexPath(item: DiffableItem) -> IndexPath? {
+ return appleDiffableDataSource?.indexPath(for: item)
+ }
+}
diff --git a/Sources/DiffableKit/Table/DiffableTableController.swift b/Sources/DiffableKit/Table/DiffableTableController.swift
new file mode 100644
index 0000000..975a689
--- /dev/null
+++ b/Sources/DiffableKit/Table/DiffableTableController.swift
@@ -0,0 +1,31 @@
+import UIKit
+
+open class DiffableTableController: UITableViewController {
+
+ open var diffableDataSource: DiffableTableDataSource?
+
+ // MARK: - Lifecycle
+
+ open override func viewDidLoad() {
+ super.viewDidLoad()
+ tableView.delaysContentTouches = false
+ tableView.cellLayoutMarginsFollowReadableWidth = true
+ tableView.layoutMargins = .zero
+ tableView.register(DiffableTableViewCell.self, forCellReuseIdentifier: DiffableTableViewCell.reuseIdentifier)
+ }
+
+ // MARK: - Configure
+
+ open func configureDiffable(
+ sections: [DiffableSection],
+ cellProviders: [DiffableTableDataSource.CellProvider],
+ headerFooterProviders: [DiffableTableDataSource.HeaderFooterProvider] = []
+ ) {
+ diffableDataSource = DiffableTableDataSource(
+ tableView: tableView,
+ cellProviders: cellProviders,
+ headerFooterProviders: headerFooterProviders
+ )
+ diffableDataSource?.set(sections, animated: false)
+ }
+}
diff --git a/Sources/DiffableKit/Table/DiffableTableDelegate.swift b/Sources/DiffableKit/Table/DiffableTableDelegate.swift
new file mode 100644
index 0000000..a1e7600
--- /dev/null
+++ b/Sources/DiffableKit/Table/DiffableTableDelegate.swift
@@ -0,0 +1,16 @@
+import UIKit
+
+@objc public protocol DiffableTableDelegate: AnyObject {
+
+ @objc optional func diffableTableView(_ tableView: UITableView, didSelectItem item: DiffableItem, indexPath: IndexPath)
+
+ @objc optional func diffableTableView(_ tableView: UITableView, shouldIndentWhileEditingItem item: DiffableItem, indexPath: IndexPath) -> Bool
+
+ @objc optional func diffableTableView(_ tableView: UITableView, editingStyleForItem item: DiffableItem, indexPath: IndexPath) -> UITableViewCell.EditingStyle
+
+ #if canImport(UIKit) && (os(iOS))
+ @objc optional func diffableTableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForItem item: DiffableItem, at indexPath: IndexPath) -> UISwipeActionsConfiguration?
+
+ @objc optional func diffableTableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForItem item: DiffableItem, at indexPath: IndexPath) -> UISwipeActionsConfiguration?
+ #endif
+}
diff --git a/Sources/DiffableKit/Table/DiffableTableView.swift b/Sources/DiffableKit/Table/DiffableTableView.swift
new file mode 100644
index 0000000..5a174c9
--- /dev/null
+++ b/Sources/DiffableKit/Table/DiffableTableView.swift
@@ -0,0 +1,40 @@
+import UIKit
+
+open class DiffableTableView: UITableView {
+
+ open var diffableDataSource: DiffableTableDataSource?
+
+ // MARK: - Configure
+
+ open func configureDiffable(
+ sections: [DiffableSection],
+ cellProviders: [DiffableTableDataSource.CellProvider],
+ headerFooterProviders: [DiffableTableDataSource.HeaderFooterProvider] = []
+ ) {
+ diffableDataSource = DiffableTableDataSource(
+ tableView: self,
+ cellProviders: cellProviders,
+ headerFooterProviders: headerFooterProviders
+ )
+ diffableDataSource?.set(sections, animated: false)
+ }
+
+ public init() {
+ super.init(frame: .zero, style: .insetGrouped)
+ commonInit()
+ }
+
+ public init(style: UITableView.Style) {
+ super.init(frame: .zero, style: style)
+ commonInit()
+ }
+
+ private func commonInit() {
+ delaysContentTouches = false
+ cellLayoutMarginsFollowReadableWidth = true
+ }
+
+ required public init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+}
diff --git a/Sources/DiffableKit/Table/Models/DiffableTableRow.swift b/Sources/DiffableKit/Table/Models/DiffableTableRow.swift
new file mode 100644
index 0000000..1b82dee
--- /dev/null
+++ b/Sources/DiffableKit/Table/Models/DiffableTableRow.swift
@@ -0,0 +1,27 @@
+import UIKit
+
+open class DiffableTableRow: DiffableActionableItem {
+
+ open var text: String
+ open var detail: String? = nil
+ open var icon: UIImage? = nil
+ open var selectionStyle: UITableViewCell.SelectionStyle
+ open var accessoryType: UITableViewCell.AccessoryType
+
+ public init(
+ id: String? = nil,
+ text: String,
+ detail: String? = nil,
+ icon: UIImage? = nil,
+ accessoryType: UITableViewCell.AccessoryType = .none,
+ selectionStyle: UITableViewCell.SelectionStyle = .none,
+ action: Action? = nil
+ ) {
+ self.text = text
+ self.detail = detail
+ self.icon = icon
+ self.accessoryType = accessoryType
+ self.selectionStyle = selectionStyle
+ super.init(id: id ?? text, action: action)
+ }
+}
diff --git a/Sources/DiffableKit/Table/Models/DiffableTableRowStepper.swift b/Sources/DiffableKit/Table/Models/DiffableTableRowStepper.swift
new file mode 100644
index 0000000..9edb4e9
--- /dev/null
+++ b/Sources/DiffableKit/Table/Models/DiffableTableRowStepper.swift
@@ -0,0 +1,45 @@
+import UIKit
+
+open class DiffableTableRowStepper: DiffableItem {
+
+ open var stepValue: Double
+ open var value: Double
+ open var minimumValue: Double
+ open var maximumValue: Double
+ open var text: String
+ open var icon: UIImage? = nil
+ open var action: Action
+
+ public init(
+ id: String? = nil,
+ text: String,
+ icon: UIImage? = nil,
+ stepValue: Double,
+ value: Double,
+ minimumValue: Double,
+ maximumValue: Double,
+ action: @escaping Action
+ ) {
+ self.text = text
+ self.icon = icon
+ self.stepValue = stepValue
+ self.value = value
+ self.minimumValue = minimumValue
+ self.maximumValue = maximumValue
+ self.action = action
+ super.init(id: id ?? text)
+ }
+
+ open override var hash: Int {
+ var hasher = Hasher()
+ hasher.combine(id)
+ return hasher.finalize()
+ }
+
+ open override func isEqual(_ object: Any?) -> Bool {
+ guard let object = object as? DiffableItem else { return false }
+ return id == object.id
+ }
+
+ public typealias Action = (_ item: DiffableItem, _ indexPath: IndexPath, _ value: Double) -> Void
+}
diff --git a/Sources/DiffableKit/Table/Models/DiffableTableRowSubtitle.swift b/Sources/DiffableKit/Table/Models/DiffableTableRowSubtitle.swift
new file mode 100644
index 0000000..022c8c3
--- /dev/null
+++ b/Sources/DiffableKit/Table/Models/DiffableTableRowSubtitle.swift
@@ -0,0 +1,27 @@
+import UIKit
+
+open class DiffableTableRowSubtitle: DiffableActionableItem {
+
+ open var text: String
+ open var subtitle: String? = nil
+ open var icon: UIImage? = nil
+ open var selectionStyle: UITableViewCell.SelectionStyle
+ open var accessoryType: UITableViewCell.AccessoryType
+
+ public init(
+ id: String? = nil,
+ text: String,
+ subtitle: String?,
+ icon: UIImage? = nil,
+ accessoryType: UITableViewCell.AccessoryType = .none,
+ selectionStyle: UITableViewCell.SelectionStyle = .none,
+ action: Action? = nil
+ ) {
+ self.text = text
+ self.subtitle = subtitle
+ self.icon = icon
+ self.accessoryType = accessoryType
+ self.selectionStyle = selectionStyle
+ super.init(id: id ?? text, action: action)
+ }
+}
diff --git a/Sources/DiffableKit/Table/Models/DiffableTableRowSwitch.swift b/Sources/DiffableKit/Table/Models/DiffableTableRowSwitch.swift
new file mode 100644
index 0000000..0755333
--- /dev/null
+++ b/Sources/DiffableKit/Table/Models/DiffableTableRowSwitch.swift
@@ -0,0 +1,25 @@
+import UIKit
+
+open class DiffableTableRowSwitch: DiffableItem {
+
+ open var text: String
+ open var icon: UIImage?
+ open var isOn: Bool
+ open var action: Action
+
+ public init(
+ id: String? = nil,
+ text: String,
+ icon: UIImage? = nil,
+ isOn: Bool,
+ action: @escaping Action
+ ) {
+ self.text = text
+ self.icon = icon
+ self.isOn = isOn
+ self.action = action
+ super.init(id: id ?? text)
+ }
+
+ public typealias Action = (_ item: DiffableItem, _ indexPath: IndexPath, _ state: Bool) -> Void
+}
diff --git a/Sources/SPDiffable/Collection/DataSource/AppleCollectionDiffableDataSource.swift b/Sources/SPDiffable/Collection/DataSource/AppleCollectionDiffableDataSource.swift
deleted file mode 100644
index 6cfe9eb..0000000
--- a/Sources/SPDiffable/Collection/DataSource/AppleCollectionDiffableDataSource.swift
+++ /dev/null
@@ -1,45 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-class AppleCollectionDiffableDataSource: UICollectionViewDiffableDataSource {
-
- // MARK: - Init
-
- init(
- collectionView: UICollectionView,
- cellProvider: @escaping CellProvider,
- headerFooterProvider: SupplementaryViewProvider?
- ) {
- super.init(collectionView: collectionView, cellProvider: cellProvider)
- self.supplementaryViewProvider = headerFooterProvider
- }
-
- // MARK: - Wrappers
-
- @available(tvOS 13.0, *)
- typealias Snapshot = NSDiffableDataSourceSnapshot
-
- @available(iOS 14.0, tvOS 14, *)
- typealias SectionSnapshot = NSDiffableDataSourceSectionSnapshot
-}
diff --git a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+CellProvider.swift b/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+CellProvider.swift
deleted file mode 100644
index 9fb7e0a..0000000
--- a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+CellProvider.swift
+++ /dev/null
@@ -1,88 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-extension SPDiffableCollectionDataSource {
-
- open class CellProvider {
-
- open var clouser: Clouser
-
- public init(clouser: @escaping Clouser) {
- self.clouser = clouser
- }
-
- public typealias Clouser = (_ collectionView: UICollectionView, _ indexPath: IndexPath, _ item: SPDiffableItem) -> UICollectionViewCell?
-
- // MARK: - Ready Use
-
- #if os(iOS)
- @available(iOS 14, *)
- public static var sideBar: [SPDiffableCollectionDataSource.CellProvider] {
- [sideBarItem, sideBarButton, sideBarHeader]
- }
-
- @available(iOS 14, *)
- public static var sideBarItem: SPDiffableCollectionDataSource.CellProvider {
- let cellRegistration = UICollectionView.CellRegistration { (cell, indexPath, item) in
- var content = UIListContentConfiguration.sidebarCell()
- content.text = item.title
- content.image = item.image
- cell.contentConfiguration = content
- cell.accessories = item.accessories
- }
- return SPDiffableCollectionDataSource.CellProvider() { (collectionView, indexPath, item) -> UICollectionViewCell? in
- guard let item = item as? SPDiffableSideBarItem else { return nil }
- return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
- }
- }
-
- @available(iOS 14, *)
- public static var sideBarButton: SPDiffableCollectionDataSource.CellProvider {
- let cellRegistration = UICollectionView.CellRegistration { (cell, indexPath, item) in
- cell.updateWithItem(item)
- cell.accessories = item.accessories
- }
- return SPDiffableCollectionDataSource.CellProvider() { (collectionView, indexPath, item) -> UICollectionViewCell? in
- guard let item = item as? SPDiffableSideBarButton else { return nil }
- return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
- }
- }
-
- @available(iOS 14, *)
- public static var sideBarHeader: SPDiffableCollectionDataSource.CellProvider {
- let cellRegistration = UICollectionView.CellRegistration { (cell, indexPath, item) in
- var content = UIListContentConfiguration.sidebarHeader()
- content.text = item.text
- content.image = nil
- cell.contentConfiguration = content
- cell.accessories = item.accessories
- }
- return SPDiffableCollectionDataSource.CellProvider() { (collectionView, indexPath, item) -> UICollectionViewCell? in
- guard let item = item as? SPDiffableSideBarHeader else { return nil }
- return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
- }
- }
- #endif
- }
-}
diff --git a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+HeaderFooterProvider.swift b/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+HeaderFooterProvider.swift
deleted file mode 100644
index 349f2dd..0000000
--- a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+HeaderFooterProvider.swift
+++ /dev/null
@@ -1,38 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-extension SPDiffableCollectionDataSource {
-
- open class HeaderFooterProvider {
-
- open var clouser: Clouser
-
- public init(clouser: @escaping Clouser) {
- self.clouser = clouser
- }
-
- public typealias Clouser = (_ collectionView: UICollectionView, _ kind: String, _ indexPath: IndexPath, _ item: SPDiffableItem) -> UICollectionReusableView?
- }
-}
-
diff --git a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+UICollectionViewDelegate.swift b/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+UICollectionViewDelegate.swift
deleted file mode 100644
index 435d4f5..0000000
--- a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+UICollectionViewDelegate.swift
+++ /dev/null
@@ -1,37 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-extension SPDiffableCollectionDataSource: UICollectionViewDelegate {
-
- open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
- guard let item = getItem(indexPath: indexPath) else { return }
- diffableDelegate?.diffableCollectionView?(collectionView, didSelectItem: item, indexPath: indexPath)
- switch item {
- case let model as SPDiffableActionableItem:
- model.action?(model, indexPath)
- default:
- break
- }
- }
-}
diff --git a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource.swift b/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource.swift
deleted file mode 100644
index 346158a..0000000
--- a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource.swift
+++ /dev/null
@@ -1,270 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-open class SPDiffableCollectionDataSource: NSObject, SPDiffableDataSourceInterface {
-
- open weak var diffableDelegate: SPDiffableCollectionDelegate?
-
- internal let headerAsFirstCell: Bool
- internal weak var collectionView: UICollectionView?
- internal var sections: [SPDiffableSection]
-
- private var appleDiffableDataSource: AppleCollectionDiffableDataSource?
-
- public init(
- collectionView: UICollectionView,
- cellProviders: [CellProvider],
- headerFooterProviders: [HeaderFooterProvider],
- headerAsFirstCell: Bool
- ) {
-
- self.headerAsFirstCell = headerAsFirstCell
- self.collectionView = collectionView
- self.sections = []
-
- super.init()
-
- self.collectionView?.delegate = self
-
- self.appleDiffableDataSource = .init(
- collectionView: collectionView,
- cellProvider: { collectionView, indexPath, itemIdentifier in
- for provider in cellProviders {
- let itemID = itemIdentifier.id
- let item: SPDiffableItem? = {
- if indexPath.row == .zero && headerAsFirstCell {
- let section = self.sections[indexPath.section]
- return section.header ?? self.getItem(id: itemID)
- } else {
- return self.getItem(id: itemID)
- }
- }()
- guard let item = item else { continue }
- if let cell = provider.clouser(collectionView, indexPath, item) {
- return cell
- }
- }
- return nil
- },
- headerFooterProvider: { collectionView, elementKind, indexPath in
- for provider in headerFooterProviders {
- let sectionIndex = indexPath.section
- let section = self.sections[sectionIndex]
- switch elementKind {
- case UICollectionView.elementKindSectionHeader:
- guard let headerItem = section.header else { continue }
- if let view = provider.clouser(collectionView, elementKind, indexPath, headerItem) {
- return view
- }
- case UICollectionView.elementKindSectionFooter:
- guard let footerItem = section.footer else { continue }
- if let view = provider.clouser(collectionView, elementKind, indexPath, footerItem) {
- return view
- }
- default:
- return nil
- }
- }
- return nil
- }
- )
- }
-
- // MARK: - Configure
-
- public func set(_ sections: [SPDiffableSection], animated: Bool, completion: (() -> Void)? = nil) {
-
- // Update content
-
- self.sections = sections
-
- // Add, remove or reoder
-
- let snapshot = convertToSnapshot(sections)
- appleDiffableDataSource?.apply(snapshot, animatingDifferences: true, completion: completion)
-
- // Update items in Sections
-
- if #available(iOS 14.0, tvOS 14, *) {
- for section in sections {
- var sectionSnapshot = AppleCollectionDiffableDataSource.SectionSnapshot()
-
- if headerAsFirstCell {
- let header = section.header
- if let header = header {
- sectionSnapshot.append([header])
- }
- sectionSnapshot.append(section.items, to: header)
- } else {
- sectionSnapshot.append(section.items)
- }
-
- sectionSnapshot.expand(sectionSnapshot.items)
- appleDiffableDataSource?.apply(sectionSnapshot, to: section, animatingDifferences: animated)
- }
- }
-
- // Update visible cells
-
- var items: [SPDiffableItem] = []
- let visibleIndexPaths = self.collectionView?.indexPathsForVisibleItems ?? []
- for indexPath in visibleIndexPaths {
- if let item = getItem(indexPath: indexPath) {
- items.append(item)
- }
- }
-
- if !items.isEmpty {
- reconfigure(items)
- }
- }
-
- public func set(_ items: [SPDiffableItem], animated: Bool, completion: (() -> Void)? = nil) {
-
- // Update content
-
- for newItem in items {
- for (sectionIndex, section) in sections.enumerated() {
- if let itemIndex = section.items.firstIndex(where: { $0.id == newItem.id }) {
- sections[sectionIndex].items[itemIndex] = newItem
- }
- }
- }
-
- // Update snapshot
-
- var snapshot = convertToSnapshot(sections)
- if #available(iOS 15.0, tvOS 15, *) {
- snapshot.reconfigureItems(items)
- } else {
- snapshot.reloadItems(items)
- }
- appleDiffableDataSource?.apply(snapshot, animatingDifferences: false)
- }
-
- public func reconfigure(_ items: [SPDiffableItem]) {
- guard var snapshot = appleDiffableDataSource?.snapshot() else { return }
- if #available(iOS 15.0, tvOS 15, *) {
- snapshot.reconfigureItems(items)
- } else {
- snapshot.reloadItems(items)
- }
- appleDiffableDataSource?.apply(snapshot, animatingDifferences: false)
- }
-
- public func updateLayout(animated: Bool, completion: (() -> Void)? = nil) {
- guard let snapshot = appleDiffableDataSource?.snapshot() else { return }
- appleDiffableDataSource?.apply(snapshot, animatingDifferences: animated, completion: completion)
- }
-
- // MARK: - Get
-
- public func getItem(id: String) -> SPDiffableItem? {
- for section in sections {
- if let item = section.items.first(where: { $0.id == id }) {
- return item
- }
- }
- return nil
- }
-
- public func getItem(indexPath: IndexPath) -> SPDiffableItem? {
- guard let itemID = appleDiffableDataSource?.itemIdentifier(for: indexPath)?.id else { return nil }
- return getItem(id: itemID)
- }
-
- public func getSection(id: String) -> SPDiffableSection? {
- return sections.first(where: { $0.id == id })
- }
-
- public func getSection(index: Int) -> SPDiffableSection? {
- guard let snapshot = appleDiffableDataSource?.snapshot() else { return nil }
- guard index < snapshot.sectionIdentifiers.count else { return nil }
- return snapshot.sectionIdentifiers[index]
- }
-
- // MARK: - Private
-
- private func convertToSnapshot(_ sections: [SPDiffableSection]) -> AppleCollectionDiffableDataSource.Snapshot {
- if #available(iOS 14, *) {
-
- var snapshot = appleDiffableDataSource?.snapshot() ?? AppleCollectionDiffableDataSource.Snapshot()
-
- // Delete
-
- let deletedSections = snapshot.sectionIdentifiers.filter({ (checkSection) -> Bool in
- return !sections.contains(where: { $0.id == checkSection.id })
- })
- if !deletedSections.isEmpty {
- snapshot.deleteSections(deletedSections)
- }
-
- // Add
-
- let addedSections = sections.filter { checkSection in
- return !snapshot.sectionIdentifiers.contains(where: {
- $0.id == checkSection.id
- })
- }
- if !addedSections.isEmpty {
- snapshot.appendSections(addedSections)
- }
-
- // Reoder
-
- for (sectionIndex, section) in sections.enumerated() {
- let previousSectionIndex = sectionIndex - 1
- guard (sections.count > previousSectionIndex) && (previousSectionIndex >= 0) else { continue }
- let previousSection = sections[previousSectionIndex]
- guard let _ = snapshot.sectionIdentifiers.first(where: { $0.id == section.id }) else { continue }
- guard let _ = snapshot.sectionIdentifiers.first(where: { $0.id == previousSection.id }) else { continue }
-
- // If try move section to same index as original.
- // This line allow skip it action.
- // Can happen crash for collection if doing it.
- if (previousSectionIndex + 1) == sectionIndex { continue }
-
- snapshot.moveSection(section, afterSection: previousSection)
- }
-
- // Set new header and footer
-
- for checkSection in snapshot.sectionIdentifiers {
- if let newSection = sections.first(where: { $0.id == checkSection.id }) {
- checkSection.header = newSection.header
- checkSection.footer = newSection.footer
- }
- }
-
- return snapshot
- } else {
- var snapshot = AppleCollectionDiffableDataSource.Snapshot()
- snapshot.appendSections(sections)
- for section in sections {
- snapshot.appendItems(section.items, toSection: section)
- }
- return snapshot
- }
- }
-}
diff --git a/Sources/SPDiffable/Collection/Models/SPDiffableSideBarButton.swift b/Sources/SPDiffable/Collection/Models/SPDiffableSideBarButton.swift
deleted file mode 100644
index 0eca6ca..0000000
--- a/Sources/SPDiffable/Collection/Models/SPDiffableSideBarButton.swift
+++ /dev/null
@@ -1,42 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Buton item in side bar.
-
- Colorful title usually.
- */
-@available(iOS 14, tvOS 14, *)
-open class SPDiffableSideBarButton: SPDiffableActionableItem {
-
- open var title: String
- open var image: UIImage?
- open var accessories: [UICellAccessory]
-
- public init(id: SPDiffableItem.Identifier? = nil, title: String, image: UIImage?, accessories: [UICellAccessory] = [], action: @escaping Action) {
- self.title = title
- self.image = image
- self.accessories = accessories
- super.init(id: id ?? title, action: action)
- }
-}
diff --git a/Sources/SPDiffable/Collection/Models/SPDiffableSideBarHeader.swift b/Sources/SPDiffable/Collection/Models/SPDiffableSideBarHeader.swift
deleted file mode 100644
index 125a345..0000000
--- a/Sources/SPDiffable/Collection/Models/SPDiffableSideBarHeader.swift
+++ /dev/null
@@ -1,38 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Header model for side bar item.
- */
-@available(iOS 14, tvOS 14, *)
-open class SPDiffableSideBarHeader: SPDiffableItem {
-
- open var text: String
- open var accessories: [UICellAccessory]
-
- public init(id: SPDiffableItem.Identifier? = nil, text: String, accessories: [UICellAccessory] = []) {
- self.text = text
- self.accessories = accessories
- super.init(id: id ?? text)
- }
-}
diff --git a/Sources/SPDiffable/Collection/Models/SPDiffableSideBarItem.swift b/Sources/SPDiffable/Collection/Models/SPDiffableSideBarItem.swift
deleted file mode 100644
index 5257a9c..0000000
--- a/Sources/SPDiffable/Collection/Models/SPDiffableSideBarItem.swift
+++ /dev/null
@@ -1,42 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Menu item in side bar.
-
- For header use `SPDiffableSideBarHeader` class.
- */
-@available(iOS 14, tvOS 14, *)
-open class SPDiffableSideBarItem: SPDiffableActionableItem {
-
- open var title: String
- open var image: UIImage?
- open var accessories: [UICellAccessory]
-
- public init(id: SPDiffableItem.Identifier? = nil, title: String, image: UIImage?, accessories: [UICellAccessory] = [], action: @escaping Action) {
- self.title = title
- self.image = image
- self.accessories = accessories
- super.init(id: id ?? title, action: action)
- }
-}
diff --git a/Sources/SPDiffable/Collection/Protocols/SPDiffableCollectionDelegate.swift b/Sources/SPDiffable/Collection/Protocols/SPDiffableCollectionDelegate.swift
deleted file mode 100644
index 7674605..0000000
--- a/Sources/SPDiffable/Collection/Protocols/SPDiffableCollectionDelegate.swift
+++ /dev/null
@@ -1,31 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Protocol for mirrir `UICollectionViewDelegate`.
- */
-@available(iOS 13.0, *)
-@objc public protocol SPDiffableCollectionDelegate: AnyObject {
-
- @objc optional func diffableCollectionView(_ collectionView: UICollectionView, didSelectItem item: SPDiffableItem, indexPath: IndexPath)
-}
diff --git a/Sources/SPDiffable/Collection/SPDiffableCollectionController.swift b/Sources/SPDiffable/Collection/SPDiffableCollectionController.swift
deleted file mode 100644
index 00e7446..0000000
--- a/Sources/SPDiffable/Collection/SPDiffableCollectionController.swift
+++ /dev/null
@@ -1,52 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-open class SPDiffableCollectionController: UICollectionViewController {
-
- open var diffableDataSource: SPDiffableCollectionDataSource?
-
- // MARK: - Lifecycle
-
- open override func viewDidLoad() {
- super.viewDidLoad()
- collectionView.delaysContentTouches = false
- }
-
- // MARK: - Configure
-
- open func configureDiffable(
- sections: [SPDiffableSection],
- cellProviders: [SPDiffableCollectionDataSource.CellProvider],
- headerFooterProviders: [SPDiffableCollectionDataSource.HeaderFooterProvider] = [],
- headerAsFirstCell: Bool
- ) {
- diffableDataSource = SPDiffableCollectionDataSource(
- collectionView: collectionView,
- cellProviders: cellProviders,
- headerFooterProviders: headerFooterProviders,
- headerAsFirstCell: headerAsFirstCell
- )
- diffableDataSource?.set(sections, animated: false)
- }
-}
diff --git a/Sources/SPDiffable/Collection/SPDiffableCollectionView.swift b/Sources/SPDiffable/Collection/SPDiffableCollectionView.swift
deleted file mode 100644
index 4024c30..0000000
--- a/Sources/SPDiffable/Collection/SPDiffableCollectionView.swift
+++ /dev/null
@@ -1,62 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-open class SPDiffableCollectionView: UICollectionView, UICollectionViewDelegate {
-
- open var diffableDataSource: SPDiffableCollectionDataSource?
-
- // MARK: - Init
-
- public init() {
- super.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
- commonInit()
- }
-
- required public init?(coder: NSCoder) {
- super.init(coder: coder)
- commonInit()
- }
-
- private func commonInit() {
- backgroundColor = .clear
- delaysContentTouches = false
- }
-
- // MARK: - Configure
-
- open func configureDiffable(
- sections: [SPDiffableSection],
- cellProviders: [SPDiffableCollectionDataSource.CellProvider],
- headerFooterProviders: [SPDiffableCollectionDataSource.HeaderFooterProvider] = [],
- headerAsFirstCell: Bool
- ) {
- diffableDataSource = SPDiffableCollectionDataSource(
- collectionView: self,
- cellProviders: cellProviders,
- headerFooterProviders: headerFooterProviders,
- headerAsFirstCell: headerAsFirstCell
- )
- diffableDataSource?.set(sections, animated: false)
- }
-}
diff --git a/Sources/SPDiffable/Collection/SPDiffableSideBarButtonCollectionViewListCell.swift b/Sources/SPDiffable/Collection/SPDiffableSideBarButtonCollectionViewListCell.swift
deleted file mode 100644
index 51122fd..0000000
--- a/Sources/SPDiffable/Collection/SPDiffableSideBarButtonCollectionViewListCell.swift
+++ /dev/null
@@ -1,53 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-#if canImport(UIKit) && os(iOS)
-import UIKit
-
-@available(iOS 14, *)
-class SPDiffableSideBarButtonCollectionViewListCell: UICollectionViewListCell {
-
- private var item: SPDiffableSideBarButton? = nil
-
- open func updateWithItem(_ newItem: SPDiffableSideBarButton) {
- guard item != newItem else { return }
- item = newItem
- setNeedsUpdateConfiguration()
- }
-
- override func updateConfiguration(using state: UICellConfigurationState) {
- var content = UIListContentConfiguration.sidebarCell().updated(for: state)
- content.text = item?.title
- content.image = item?.image
- content.textProperties.color = tintColor
- contentConfiguration = content
- }
-
- override func tintColorDidChange() {
- super.tintColorDidChange()
- setNeedsUpdateConfiguration()
- }
-
- override var isSelected: Bool {
- didSet { if isSelected { isSelected = false } }
- }
-}
-#endif
diff --git a/Sources/SPDiffable/Collection/SPDiffableSideBarController.swift b/Sources/SPDiffable/Collection/SPDiffableSideBarController.swift
deleted file mode 100644
index 94da5d2..0000000
--- a/Sources/SPDiffable/Collection/SPDiffableSideBarController.swift
+++ /dev/null
@@ -1,57 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-#if canImport(UIKit) && os(iOS)
-import UIKit
-
-@available(iOS 14, *)
-open class SPDiffableSideBarController: SPDiffableCollectionController {
-
- // MARK: - Init
-
- public init() {
- super.init(collectionViewLayout: UICollectionViewFlowLayout())
- commonInit()
- }
-
- public required init?(coder: NSCoder) {
- super.init(coder: coder)
- commonInit()
- }
-
- private func commonInit() {
- collectionView.setCollectionViewLayout(makeLayout(), animated: false)
- }
-
- // MARK: - Layout
-
- private func makeLayout() -> UICollectionViewCompositionalLayout {
- return UICollectionViewCompositionalLayout { [weak self] (section, layoutEnvironment) -> NSCollectionLayoutSection? in
- var configuration = UICollectionLayoutListConfiguration(appearance: .sidebar)
- let header = self?.diffableDataSource?.getSection(index: section)?.header
- configuration.headerMode = (header == nil) ? .none : .firstItemInSection
- let footer = self?.diffableDataSource?.getSection(index: section)?.footer
- configuration.footerMode = (footer == nil) ? .none : .supplementary
- return NSCollectionLayoutSection.list(using: configuration, layoutEnvironment: layoutEnvironment)
- }
- }
-}
-#endif
diff --git a/Sources/SPDiffable/Models/SPDiffableActionableItem.swift b/Sources/SPDiffable/Models/SPDiffableActionableItem.swift
deleted file mode 100644
index c8b4224..0000000
--- a/Sources/SPDiffable/Models/SPDiffableActionableItem.swift
+++ /dev/null
@@ -1,35 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Actionable collection item model.
- */
-open class SPDiffableActionableItem: SPDiffableItem, SPDiffableItemActionable {
-
- open var action: Action?
-
- public init(id: String, action: Action? = nil) {
- self.action = action
- super.init(id: id)
- }
-}
diff --git a/Sources/SPDiffable/Models/SPDiffableItem.swift b/Sources/SPDiffable/Models/SPDiffableItem.swift
deleted file mode 100644
index 7523737..0000000
--- a/Sources/SPDiffable/Models/SPDiffableItem.swift
+++ /dev/null
@@ -1,69 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Basic class for items and sections.
-
- All next model's classes shoud be extend from it class.
- */
-open class SPDiffableItem: NSObject, NSCopying {
-
- /**
- SPDiffable: Identifier help for detect uniq cell and doing diffable work and animations.
-
- Always shoud be uniq. But if it changed, diffable system remove old and insert new (not reload).
- Identifier uses in `Hashable` and `Equatable` protocols.
- */
- open var id: Identifier
-
- // MARK: - Init
-
- public init(id: Identifier) {
- self.id = id
- }
-
- // MARK: - Hashable and Equatable
-
- open override var hash: Int {
- var hasher = Hasher()
- hasher.combine(id)
- return hasher.finalize()
- }
-
- open override func isEqual(_ object: Any?) -> Bool {
- guard let object = object as? SPDiffableItem else { return false }
- return id == object.id
- }
-
- // MARK: - NSCopying
-
- // Implemented becouse when using with collection,
- // sometimes catch error about unregognized selector.
- open func copy(with zone: NSZone? = nil) -> Any {
- return SPDiffableItem(id: self.id)
- }
-
- // MARK: - Identifier
-
- public typealias Identifier = String
-}
diff --git a/Sources/SPDiffable/Models/SPDiffableItemActionable.swift b/Sources/SPDiffable/Models/SPDiffableItemActionable.swift
deleted file mode 100644
index e2a8d4f..0000000
--- a/Sources/SPDiffable/Models/SPDiffableItemActionable.swift
+++ /dev/null
@@ -1,33 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Protocol for items which shoud have actions.
- In default controllers will be handled.
- */
-public protocol SPDiffableItemActionable: AnyObject {
-
- var action: Action? { get set }
-
- typealias Action = (_ item: SPDiffableItem, _ indexPath: IndexPath) -> Void
-}
diff --git a/Sources/SPDiffable/Models/SPDiffableSection.swift b/Sources/SPDiffable/Models/SPDiffableSection.swift
deleted file mode 100644
index 0c8a04c..0000000
--- a/Sources/SPDiffable/Models/SPDiffableSection.swift
+++ /dev/null
@@ -1,83 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Basic section class. Can set header, footer and items in it section.
-
- Using in diffable work. All sections shoud be inhert from it.
- Can init with empty models if need configure later.
- */
-open class SPDiffableSection: NSObject, NSCopying {
-
- /**
- SPDiffable: Identifier help for detect uniq section and doing diffable work and animations.
-
- Always shoud be uniq. But if it changed, diffable system remove old and insert new (not reload).
- Identifier uses in `Hashable` and `Equatable` protocols.
- */
- open var id: SectionIdentifier
-
- open var header: SPDiffableItem?
- open var footer: SPDiffableItem?
-
- open var items: [SPDiffableItem]
-
- // MARK: - Init
-
- public init(id: SectionIdentifier, header: SPDiffableItem? = nil, footer: SPDiffableItem? = nil, items: [SPDiffableItem] = []) {
- self.id = id
- self.header = header
- self.footer = footer
- self.items = items
- }
-
- // MARK: - Hashable and Equatable
-
- open override var hash: Int {
- var hasher = Hasher()
- hasher.combine(id)
- return hasher.finalize()
- }
-
- open override func isEqual(_ object: Any?) -> Bool {
- guard let object = object as? SPDiffableSection else { return false }
- return id == object.id
- }
-
- // MARK: - NSCopying
-
- // Implemented becouse when using with collection,
- // sometimes catch error about unregognized selector.
- open func copy(with zone: NSZone? = nil) -> Any {
- return SPDiffableSection(
- id: self.id,
- header: self.header,
- footer: self.footer,
- items: self.items
- )
- }
-
- // MARK: - Item Identifier
-
- public typealias SectionIdentifier = String
-}
diff --git a/Sources/SPDiffable/Models/SPDiffableSnapshot.swift b/Sources/SPDiffable/Models/SPDiffableSnapshot.swift
deleted file mode 100644
index 97f9954..0000000
--- a/Sources/SPDiffable/Models/SPDiffableSnapshot.swift
+++ /dev/null
@@ -1,35 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-/*
-/**
- SPDiffable: Wrapper of `NSDiffableDataSourceSnapshot` with basic `SPDiffableSection` & `SPDiffableItem`.
- */
-@available(iOS 13.0, *)
-public typealias SPDiffableSnapshot = NSDiffableDataSourceSnapshot
-
-/**
- SPDiffable: Wrapper of NSDiffableDataSourceSectionSnapshot with basic `SPDiffableItem`.
- */
-@available(iOS 14, *)
-public typealias SPDiffableSectionSnapshot = NSDiffableDataSourceSectionSnapshot
-*/
diff --git a/Sources/SPDiffable/Models/SPDiffableTextHeaderFooter.swift b/Sources/SPDiffable/Models/SPDiffableTextHeaderFooter.swift
deleted file mode 100644
index 3cdfd6b..0000000
--- a/Sources/SPDiffable/Models/SPDiffableTextHeaderFooter.swift
+++ /dev/null
@@ -1,35 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Header & Footer model class with simple text.
- */
-open class SPDiffableTextHeaderFooter: SPDiffableItem {
-
- open var text: String
-
- public init(id: String? = nil, text: String) {
- self.text = text
- super.init(id: id ?? text)
- }
-}
diff --git a/Sources/SPDiffable/Models/SPDiffableWrapperItem.swift b/Sources/SPDiffable/Models/SPDiffableWrapperItem.swift
deleted file mode 100644
index f69b8b1..0000000
--- a/Sources/SPDiffable/Models/SPDiffableWrapperItem.swift
+++ /dev/null
@@ -1,44 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-/**
- SPDiffable: Wrapper class for any model.
-
- Using it class if you no need create custom model to diffable.
- You can pass any object and unwrap in cell provider.
-
- Also need pass uniq `identifier`.
- */
-open class SPDiffableWrapperItem: SPDiffableActionableItem {
-
- /**
- SPDiffable: You can pass any object as model.
- Later need uwrap it for get.
- */
- open var model: Any
-
- public init(id: String, model: Any, action: Action? = nil) {
- self.model = model
- super.init(id: id, action: action)
- }
-}
diff --git a/Sources/SPDiffable/SPDiffableDataSourceInterface.swift b/Sources/SPDiffable/SPDiffableDataSourceInterface.swift
deleted file mode 100644
index ee49579..0000000
--- a/Sources/SPDiffable/SPDiffableDataSourceInterface.swift
+++ /dev/null
@@ -1,40 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, *)
-public protocol SPDiffableDataSourceInterface: AnyObject {
-
- // MARK: - Set
-
- func set(_ sections: [SPDiffableSection], animated: Bool, completion: (() -> Void)?)
- func set(_ items: [SPDiffableItem], animated: Bool, completion: (() -> Void)?)
- func reconfigure(_ items: [SPDiffableItem])
- func updateLayout(animated: Bool, completion: (() -> Void)?)
-
- // MARK: - Get
-
- func getItem(id: String) -> SPDiffableItem?
- func getItem(indexPath: IndexPath) -> SPDiffableItem?
- func getSection(id: String) -> SPDiffableSection?
- func getSection(index: Int) -> SPDiffableSection?
-}
diff --git a/Sources/SPDiffable/Table/Cells/SPDiffableSubtitleTableViewCell.swift b/Sources/SPDiffable/Table/Cells/SPDiffableSubtitleTableViewCell.swift
deleted file mode 100644
index 6e48c1f..0000000
--- a/Sources/SPDiffable/Table/Cells/SPDiffableSubtitleTableViewCell.swift
+++ /dev/null
@@ -1,46 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableSubtitleTableViewCell: UITableViewCell {
-
- public static let reuseIdentifier = "SPDiffableSubtitleTableViewCell"
-
- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
- }
-
- public required init?(coder: NSCoder) {
- super.init(coder: coder)
- }
-
- open override func prepareForReuse() {
- super.prepareForReuse()
- accessoryView = nil
- detailTextLabel?.text = nil
- }
-
- open override func sizeThatFits(_ size: CGSize) -> CGSize {
- let superSize = super.sizeThatFits(size)
- return .init(width: superSize.width, height: superSize.height + 4)
- }
-}
diff --git a/Sources/SPDiffable/Table/Cells/SPDiffableTableViewCell.swift b/Sources/SPDiffable/Table/Cells/SPDiffableTableViewCell.swift
deleted file mode 100644
index 31e711f..0000000
--- a/Sources/SPDiffable/Table/Cells/SPDiffableTableViewCell.swift
+++ /dev/null
@@ -1,46 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTableViewCell: UITableViewCell {
-
- public static var reuseIdentifier: String { "SPDiffableTableViewCell" }
-
- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: .value1, reuseIdentifier: reuseIdentifier)
- }
-
- public required init?(coder: NSCoder) {
- super.init(coder: coder)
- }
-
- open override func prepareForReuse() {
- super.prepareForReuse()
- accessoryView = nil
- detailTextLabel?.text = nil
- }
-
- open override func sizeThatFits(_ size: CGSize) -> CGSize {
- let superSize = super.sizeThatFits(size)
- return .init(width: superSize.width, height: superSize.height)
- }
-}
diff --git a/Sources/SPDiffable/Table/Cells/SPDiffableTextFieldTableViewCell.swift b/Sources/SPDiffable/Table/Cells/SPDiffableTextFieldTableViewCell.swift
deleted file mode 100644
index eeb2397..0000000
--- a/Sources/SPDiffable/Table/Cells/SPDiffableTextFieldTableViewCell.swift
+++ /dev/null
@@ -1,87 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTextFieldTableViewCell: UITableViewCell {
-
- // MARK: - Data
-
- public static var reuseIdentifier: String { "SPDiffableTextFieldTableViewCell" }
-
- // MARK: - Views
-
- public let textField = UITextField()
-
- // MARK: - Init
-
- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: .value1, reuseIdentifier: reuseIdentifier)
- commonInit()
- }
-
- public required init?(coder: NSCoder) {
- super.init(coder: coder)
- commonInit()
- }
-
- private func commonInit() {
- textField.backgroundColor = .clear
- contentView.addSubview(textField)
- }
-
- open override func prepareForReuse() {
- super.prepareForReuse()
- textField.text = nil
- accessoryView = nil
- detailTextLabel?.text = nil
- }
-
- open func configure(with item: SPDiffableTableRowTextField) {
- imageView?.image = item.icon
- textField.text = item.text
- textField.placeholder = item.placeholder
- textField.autocorrectionType = item.autocorrectionType
- textField.keyboardType = item.keyboardType
- textField.autocapitalizationType = item.autocapitalizationType
- textField.delegate = item.delegate
- textField.clearButtonMode = item.clearButtonMode
- accessoryView = .none
- selectionStyle = .none
- }
-
- // MARK: - Layout
-
- open override func layoutSubviews() {
- super.layoutSubviews()
- textField.frame = .init(
- x: contentView.layoutMargins.left,
- y: .zero,
- width: contentView.frame.width - contentView.layoutMargins.left - contentView.layoutMargins.right,
- height: contentView.frame.height
- )
- }
-
- open override func sizeThatFits(_ size: CGSize) -> CGSize {
- let superSize = super.sizeThatFits(size)
- return .init(width: superSize.width, height: superSize.height + 4)
- }
-}
diff --git a/Sources/SPDiffable/Table/Cells/SPDiffableTextFieldTitleTableViewCell.swift b/Sources/SPDiffable/Table/Cells/SPDiffableTextFieldTitleTableViewCell.swift
deleted file mode 100644
index d194cd2..0000000
--- a/Sources/SPDiffable/Table/Cells/SPDiffableTextFieldTitleTableViewCell.swift
+++ /dev/null
@@ -1,96 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTextFieldTitleTableViewCell: UITableViewCell {
-
- // MARK: - Data
-
- public static var reuseIdentifier: String { "SPDiffableTextFieldTitleTableViewCell" }
-
- // MARK: - Views
-
- public let textField = UITextField()
-
- // MARK: - Init
-
- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: .value1, reuseIdentifier: reuseIdentifier)
- commonInit()
- }
-
- public required init?(coder: NSCoder) {
- super.init(coder: coder)
- commonInit()
- }
-
- private func commonInit() {
- if #available(iOS 13.0, tvOS 13.0, *) {
- textLabel?.textColor = .secondaryLabel
- }
- textField.backgroundColor = .clear
- contentView.addSubview(textField)
- }
-
- open override func prepareForReuse() {
- super.prepareForReuse()
- accessoryView = nil
- detailTextLabel?.text = nil
- }
-
- open func configure(with item: SPDiffableTableRowTextFieldTitle) {
- imageView?.image = item.icon
- textLabel?.text = item.title
- textField.text = item.text
- textField.placeholder = item.placeholder
- textField.autocorrectionType = item.autocorrectionType
- textField.keyboardType = item.keyboardType
- textField.autocapitalizationType = item.autocapitalizationType
- textField.delegate = item.delegate
- textField.clearButtonMode = item.clearButtonMode
- textField.textAlignment = .right
- textField.isEnabled = item.editable
- accessoryView = .none
- selectionStyle = .none
- }
-
- // MARK: - Layout
-
- open override func layoutSubviews() {
- super.layoutSubviews()
- if let textLabel = self.textLabel {
- let textFieldX = textLabel.frame.origin.x + textLabel.frame.width
- textField.frame = .init(
- x: textFieldX,
- y: .zero,
- width: contentView.frame.width - textFieldX - contentView.layoutMargins.right,
- height: contentView.frame.height
- )
- }
-
- }
-
- open override func sizeThatFits(_ size: CGSize) -> CGSize {
- let superSize = super.sizeThatFits(size)
- return .init(width: superSize.width, height: superSize.height + 4)
- }
-}
diff --git a/Sources/SPDiffable/Table/Cells/Views/SPDiffableSlider.swift b/Sources/SPDiffable/Table/Cells/Views/SPDiffableSlider.swift
deleted file mode 100644
index 8aa4fbd..0000000
--- a/Sources/SPDiffable/Table/Cells/Views/SPDiffableSlider.swift
+++ /dev/null
@@ -1,45 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-#if canImport(UIKit) && os(iOS)
-import UIKit
-
-open class SPDiffableSlider: UISlider {
-
- var action: (_ value: Double) -> Void
-
- public init(action: @escaping (Double) -> Void) {
- self.action = action
- super.init(frame: .zero)
- addTarget(self, action: #selector(self.valueChanged), for: .valueChanged)
- }
-
- required public init?(coder: NSCoder) {
- self.action = { _ in }
- super.init(coder: coder)
- }
-
- @objc func valueChanged() {
- action(Double(value))
- }
-}
-#endif
-
diff --git a/Sources/SPDiffable/Table/Cells/Views/SPDiffableStepper.swift b/Sources/SPDiffable/Table/Cells/Views/SPDiffableStepper.swift
deleted file mode 100644
index 28e93dd..0000000
--- a/Sources/SPDiffable/Table/Cells/Views/SPDiffableStepper.swift
+++ /dev/null
@@ -1,44 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-#if canImport(UIKit) && os(iOS)
-import UIKit
-
-open class SPDiffableStepper: UIStepper {
-
- var action: (_ value: Double) -> Void
-
- public init(action: @escaping (Double) -> Void) {
- self.action = action
- super.init(frame: .zero)
- addTarget(self, action: #selector(self.valueChanged), for: .valueChanged)
- }
-
- required public init?(coder: NSCoder) {
- self.action = { _ in }
- super.init(coder: coder)
- }
-
- @objc func valueChanged() {
- action(value)
- }
-}
-#endif
diff --git a/Sources/SPDiffable/Table/Cells/Views/SPDiffableSwitch.swift b/Sources/SPDiffable/Table/Cells/Views/SPDiffableSwitch.swift
deleted file mode 100644
index 9257e9d..0000000
--- a/Sources/SPDiffable/Table/Cells/Views/SPDiffableSwitch.swift
+++ /dev/null
@@ -1,43 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-#if canImport(UIKit) && os(iOS)
-import UIKit
-
-open class SPDiffableSwitch: UISwitch {
-
- var action: (_ state: Bool) -> Void
-
- public init(action: @escaping (_ state: Bool) -> Void) {
- self.action = action
- super.init(frame: .zero)
- addTarget(self, action: #selector(self.valueChanged), for: .valueChanged)
- }
-
- required public init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- @objc func valueChanged() {
- action(isOn)
- }
-}
-#endif
diff --git a/Sources/SPDiffable/Table/DataSource/AppleTableDiffableDataSource.swift b/Sources/SPDiffable/Table/DataSource/AppleTableDiffableDataSource.swift
deleted file mode 100644
index 07b1324..0000000
--- a/Sources/SPDiffable/Table/DataSource/AppleTableDiffableDataSource.swift
+++ /dev/null
@@ -1,73 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-class AppleTableDiffableDataSource: UITableViewDiffableDataSource {
-
- weak var mediator: SPDiffableTableMediator?
-
- // MARK: - Init
-
- override init(
- tableView: UITableView,
- cellProvider: @escaping CellProvider
- ) {
- super.init(tableView: tableView, cellProvider: cellProvider)
- }
-
- // MARK: - Mediator
-
- override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
- if let header = snapshot().sectionIdentifiers[section].header as? SPDiffableTextHeaderFooter {
- return header.text
- }
- return nil
- }
-
- override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
- if let footer = snapshot().sectionIdentifiers[section].footer as? SPDiffableTextHeaderFooter {
- return footer.text
- }
- return nil
- }
-
- override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
- return mediator?.diffableTableView?(tableView, canEditRowAt: indexPath) ?? false
- }
-
- override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
- mediator?.diffableTableView?(tableView, commit: editingStyle, forRowAt: indexPath)
- }
-
- override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
- return mediator?.diffableTableView?(tableView, canMoveRowAt: indexPath) ?? false
- }
-
- override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
- mediator?.diffableTableView?(tableView, moveRowAt: sourceIndexPath, to: destinationIndexPath)
- }
-
- // MARK: - Wrappers
-
- typealias Snapshot = NSDiffableDataSourceSnapshot
-}
diff --git a/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource+CellProvider.swift b/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource+CellProvider.swift
deleted file mode 100644
index 0162efa..0000000
--- a/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource+CellProvider.swift
+++ /dev/null
@@ -1,143 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-extension SPDiffableTableDataSource {
-
- open class CellProvider {
-
- open var clouser: Clouser
-
- public init(clouser: @escaping Clouser) {
- self.clouser = clouser
- }
-
- public typealias Clouser = (_ tableView: UITableView, _ indexPath: IndexPath, _ item: SPDiffableItem) -> UITableViewCell?
-
- // MARK: - Ready Use
-
-
- public static var `default`: [CellProvider] {
-#if os(iOS)
- return [rowDetail, rowSubtitle, `switch`, stepper, textField]
-#else
- return [rowDetail, rowSubtitle, textField]
-#endif
- }
-
- public static var rowDetail: CellProvider {
- return CellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
- guard let item = item as? SPDiffableTableRow else { return nil }
- let cell = tableView.dequeueReusableCell(withIdentifier: SPDiffableTableViewCell.reuseIdentifier, for: indexPath) as! SPDiffableTableViewCell
- cell.textLabel?.text = item.text
- cell.detailTextLabel?.text = item.detail
- cell.imageView?.image = item.icon
- cell.accessoryType = item.accessoryType
- cell.selectionStyle = item.selectionStyle
- return cell
- }
- }
-
- public static var rowSubtitle: CellProvider {
- return CellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
- guard let item = item as? SPDiffableTableRowSubtitle else { return nil }
- let cell = tableView.dequeueReusableCell(withIdentifier: SPDiffableSubtitleTableViewCell.reuseIdentifier, for: indexPath) as! SPDiffableSubtitleTableViewCell
- cell.textLabel?.text = item.text
- cell.detailTextLabel?.text = item.subtitle
- cell.imageView?.image = item.icon
- cell.accessoryType = item.accessoryType
- cell.selectionStyle = item.selectionStyle
- return cell
- }
- }
-
- #if os(iOS)
- public static var `switch`: CellProvider {
- return CellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
- guard let item = item as? SPDiffableTableRowSwitch else { return nil }
- let cell = tableView.dequeueReusableCell(withIdentifier: SPDiffableTableViewCell.reuseIdentifier, for: indexPath) as! SPDiffableTableViewCell
- cell.textLabel?.text = item.text
- cell.imageView?.image = item.icon
-
- if let control = cell.accessoryView as? SPDiffableSwitch {
- control.action = item.action
- control.isOn = item.isOn
- } else {
- let control = SPDiffableSwitch(action: item.action)
- control.isOn = item.isOn
- cell.accessoryView = control
- }
-
- cell.selectionStyle = .none
- return cell
- }
- }
- #endif
-
- #if os(iOS)
- public static var stepper: CellProvider {
- return CellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
- guard let item = item as? SPDiffableTableRowStepper else { return nil }
- let cell = tableView.dequeueReusableCell(withIdentifier: SPDiffableTableViewCell.reuseIdentifier, for: indexPath) as! SPDiffableTableViewCell
- cell.textLabel?.text = item.text
- cell.imageView?.image = item.icon
-
- if let control = cell.accessoryView as? SPDiffableStepper {
- control.action = item.action
- control.stepValue = item.stepValue
- control.value = item.value
- control.minimumValue = item.minimumValue
- control.maximumValue = item.maximumValue
- } else {
- let control = SPDiffableStepper(action: item.action)
- control.stepValue = item.stepValue
- control.value = item.value
- control.minimumValue = item.minimumValue
- control.maximumValue = item.maximumValue
- cell.accessoryView = control
- }
-
- cell.selectionStyle = .none
- return cell
- }
- }
- #endif
-
- public static var textField: CellProvider {
- return CellProvider() { (tableView, indexPath, item) -> UITableViewCell? in
- switch item {
- case let item as SPDiffableTableRowTextFieldTitle:
- let cell = tableView.dequeueReusableCell(withIdentifier: SPDiffableTextFieldTitleTableViewCell.reuseIdentifier, for: indexPath) as! SPDiffableTextFieldTitleTableViewCell
- cell.configure(with: item)
- return cell
- case let item as SPDiffableTableRowTextField :
- let cell = tableView.dequeueReusableCell(withIdentifier: SPDiffableTextFieldTableViewCell.reuseIdentifier, for: indexPath) as! SPDiffableTextFieldTableViewCell
- cell.configure(with: item)
- return cell
- default:
- return nil
- }
- }
- }
- }
-}
diff --git a/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource+HeaderFooterProvider.swift b/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource+HeaderFooterProvider.swift
deleted file mode 100644
index d69df47..0000000
--- a/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource+HeaderFooterProvider.swift
+++ /dev/null
@@ -1,37 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-extension SPDiffableTableDataSource {
-
- open class HeaderFooterProvider {
-
- open var clouser: Clouser
-
- public init(clouser: @escaping Clouser) {
- self.clouser = clouser
- }
-
- public typealias Clouser = (_ tableView: UITableView, _ section: Int, _ item: SPDiffableItem) -> UIView?
- }
-}
diff --git a/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource.swift b/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource.swift
deleted file mode 100644
index 18ab5d1..0000000
--- a/Sources/SPDiffable/Table/DataSource/SPDiffableTableDataSource.swift
+++ /dev/null
@@ -1,184 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-open class SPDiffableTableDataSource: NSObject, SPDiffableDataSourceInterface {
-
- open weak var mediator: SPDiffableTableMediator? {
- get { appleDiffableDataSource?.mediator }
- set { appleDiffableDataSource?.mediator = newValue }
- }
-
- open weak var diffableDelegate: SPDiffableTableDelegate?
-
- internal weak var tableView: UITableView?
- internal var sections: [SPDiffableSection]
- internal var headerFooterProviders: [HeaderFooterProvider]
-
- private var appleDiffableDataSource: AppleTableDiffableDataSource?
-
- // MARK: - Init
-
- init(
- tableView: UITableView,
- cellProviders: [CellProvider],
- headerFooterProviders: [HeaderFooterProvider]
- ) {
-
- self.tableView = tableView
- self.sections = []
- self.headerFooterProviders = headerFooterProviders
-
- super.init()
-
- self.appleDiffableDataSource = .init(
- tableView: tableView,
- cellProvider: { tableView, indexPath, itemIdentifier in
- for provider in cellProviders {
- let itemID = itemIdentifier.id
- guard let item = self.getItem(id: itemID) else { continue }
- if let cell = provider.clouser(tableView, indexPath, item) {
- return cell
- }
- }
- return nil
- }
- )
-
- self.tableView?.delegate = self
- }
-
- // MARK: - Set
-
- public func set(_ sections: [SPDiffableSection], animated: Bool, completion: (() -> Void)? = nil) {
-
- // Update content
-
- self.sections = sections
-
- // Add, remove or reoder
-
- let snapshot = convertToSnapshot(self.sections)
- appleDiffableDataSource?.apply(snapshot, animatingDifferences: animated, completion: completion)
-
- // Update visible cells
-
- var items: [SPDiffableItem] = []
- let visibleIndexPaths = self.tableView?.indexPathsForVisibleRows ?? []
- for indexPath in visibleIndexPaths {
- if let item = getItem(indexPath: indexPath) {
- items.append(item)
- }
- }
-
- if !items.isEmpty {
- reconfigure(items)
- }
- }
-
- public func set(_ items: [SPDiffableItem], animated: Bool, completion: (() -> Void)? = nil) {
-
- // Update content
-
- for newItem in items {
- for (sectionIndex, section) in sections.enumerated() {
- if let itemIndex = section.items.firstIndex(where: { $0.id == newItem.id }) {
- sections[sectionIndex].items[itemIndex] = newItem
- }
- }
- }
-
- // Update snapshot
-
- var snapshot = convertToSnapshot(sections)
- if #available(iOS 15.0, tvOS 15, *) {
- snapshot.reconfigureItems(items)
- } else {
- snapshot.reloadItems(items)
- }
- appleDiffableDataSource?.apply(snapshot, animatingDifferences: false)
- }
-
- public func reconfigure(_ items: [SPDiffableItem]) {
- guard var snapshot = appleDiffableDataSource?.snapshot() else { return }
- if #available(iOS 15.0, tvOS 15, *) {
- snapshot.reconfigureItems(items)
- } else {
- snapshot.reloadItems(items)
- }
- appleDiffableDataSource?.apply(snapshot, animatingDifferences: false)
- }
-
- public func updateLayout(animated: Bool, completion: (() -> Void)? = nil) {
- guard let snapshot = appleDiffableDataSource?.snapshot() else { return }
- appleDiffableDataSource?.apply(snapshot, animatingDifferences: animated, completion: completion)
- }
-
- // MARK: - Get
-
- public func getItem(id: String) -> SPDiffableItem? {
- for section in sections {
- if let item = section.items.first(where: { $0.id == id }) {
- return item
- }
- }
- return nil
- }
-
- public func getItem(indexPath: IndexPath) -> SPDiffableItem? {
- guard let itemID = appleDiffableDataSource?.itemIdentifier(for: indexPath)?.id else { return nil }
- return getItem(id: itemID)
- }
-
- public func getSection(id: String) -> SPDiffableSection? {
- return sections.first(where: { $0.id == id })
- }
-
- public func getSection(index: Int) -> SPDiffableSection? {
- guard let snapshot = appleDiffableDataSource?.snapshot() else { return nil }
- guard index < snapshot.sectionIdentifiers.count else { return nil }
- return snapshot.sectionIdentifiers[index]
- }
-
- public func getIndexPath(id: String) -> IndexPath? {
- guard let item = getItem(id: id) else { return nil }
- guard let indexPath = appleDiffableDataSource?.indexPath(for: item) else { return nil }
- return indexPath
- }
-
- public func getIndexPath(item: SPDiffableItem) -> IndexPath? {
- guard let indexPath = appleDiffableDataSource?.indexPath(for: item) else { return nil }
- return indexPath
- }
-
- // MARK: - Private
-
- private func convertToSnapshot(_ sections: [SPDiffableSection]) -> AppleTableDiffableDataSource.Snapshot {
- var snapshot = AppleTableDiffableDataSource.Snapshot()
- snapshot.appendSections(sections)
- for section in sections {
- snapshot.appendItems(section.items, toSection: section)
- }
- return snapshot
- }
-}
diff --git a/Sources/SPDiffable/Table/Models/SPDiffableTableRow.swift b/Sources/SPDiffable/Table/Models/SPDiffableTableRow.swift
deleted file mode 100644
index 5708686..0000000
--- a/Sources/SPDiffable/Table/Models/SPDiffableTableRow.swift
+++ /dev/null
@@ -1,48 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTableRow: SPDiffableActionableItem {
-
- open var text: String
- open var detail: String? = nil
- open var icon: UIImage? = nil
- open var selectionStyle: UITableViewCell.SelectionStyle
- open var accessoryType: UITableViewCell.AccessoryType
-
- public init(
- id: String? = nil,
- text: String,
- detail: String? = nil,
- icon: UIImage? = nil,
- accessoryType: UITableViewCell.AccessoryType = .none,
- selectionStyle: UITableViewCell.SelectionStyle = .none,
- action: Action? = nil
- ) {
- self.text = text
- self.detail = detail
- self.icon = icon
- self.accessoryType = accessoryType
- self.selectionStyle = selectionStyle
- super.init(id: id ?? text, action: action)
- }
-}
diff --git a/Sources/SPDiffable/Table/Models/SPDiffableTableRowButton.swift b/Sources/SPDiffable/Table/Models/SPDiffableTableRowButton.swift
deleted file mode 100644
index df04ae3..0000000
--- a/Sources/SPDiffable/Table/Models/SPDiffableTableRowButton.swift
+++ /dev/null
@@ -1,50 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTableRowButton: SPDiffableItem {
-
- open var text: String
- open var detail: String?
- open var icon: UIImage?
- open var accessoryType: UITableViewCell.AccessoryType
- open var action: Action
-
- public init(
- id: String? = nil,
- text: String,
- detail: String? = nil,
- icon: UIImage? = nil,
- accessoryType: UITableViewCell.AccessoryType = .none,
- selectionStyle: UITableViewCell.SelectionStyle = .default,
- action: @escaping Action
- ) {
- self.text = text
- self.detail = detail
- self.icon = icon
- self.accessoryType = accessoryType
- self.action = action
- super.init(id: id ?? text)
- }
-
- public typealias Action = (_ indexPath: IndexPath) -> Void
-}
diff --git a/Sources/SPDiffable/Table/Models/SPDiffableTableRowStepper.swift b/Sources/SPDiffable/Table/Models/SPDiffableTableRowStepper.swift
deleted file mode 100644
index 81b6bba..0000000
--- a/Sources/SPDiffable/Table/Models/SPDiffableTableRowStepper.swift
+++ /dev/null
@@ -1,55 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTableRowStepper: SPDiffableItem {
-
- open var stepValue: Double
- open var value: Double
- open var minimumValue: Double
- open var maximumValue: Double
- open var text: String
- open var icon: UIImage? = nil
- open var action: Action
-
- public init(
- id: String? = nil,
- text: String,
- icon: UIImage? = nil,
- stepValue: Double,
- value: Double,
- minimumValue: Double,
- maximumValue: Double,
- action: @escaping Action
- ) {
- self.text = text
- self.icon = icon
- self.stepValue = stepValue
- self.value = value
- self.minimumValue = minimumValue
- self.maximumValue = maximumValue
- self.action = action
- super.init(id: id ?? text)
- }
-
- public typealias Action = (_ value: Double) -> Void
-}
diff --git a/Sources/SPDiffable/Table/Models/SPDiffableTableRowSubtitle.swift b/Sources/SPDiffable/Table/Models/SPDiffableTableRowSubtitle.swift
deleted file mode 100644
index 8d99b1a..0000000
--- a/Sources/SPDiffable/Table/Models/SPDiffableTableRowSubtitle.swift
+++ /dev/null
@@ -1,48 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTableRowSubtitle: SPDiffableActionableItem {
-
- open var text: String
- open var subtitle: String? = nil
- open var icon: UIImage? = nil
- open var selectionStyle: UITableViewCell.SelectionStyle
- open var accessoryType: UITableViewCell.AccessoryType
-
- public init(
- id: String? = nil,
- text: String,
- subtitle: String?,
- icon: UIImage? = nil,
- accessoryType: UITableViewCell.AccessoryType = .none,
- selectionStyle: UITableViewCell.SelectionStyle = .none,
- action: Action? = nil
- ) {
- self.text = text
- self.subtitle = subtitle
- self.icon = icon
- self.accessoryType = accessoryType
- self.selectionStyle = selectionStyle
- super.init(id: id ?? text, action: action)
- }
-}
diff --git a/Sources/SPDiffable/Table/Models/SPDiffableTableRowSwitch.swift b/Sources/SPDiffable/Table/Models/SPDiffableTableRowSwitch.swift
deleted file mode 100644
index 76d75a2..0000000
--- a/Sources/SPDiffable/Table/Models/SPDiffableTableRowSwitch.swift
+++ /dev/null
@@ -1,46 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTableRowSwitch: SPDiffableItem {
-
- open var text: String
- open var icon: UIImage?
- open var isOn: Bool
- open var action: Action
-
- public init(
- id: String? = nil,
- text: String,
- icon: UIImage? = nil,
- isOn: Bool,
- action: @escaping Action
- ) {
- self.text = text
- self.icon = icon
- self.isOn = isOn
- self.action = action
- super.init(id: id ?? text)
- }
-
- public typealias Action = (_ state: Bool) -> Void
-}
diff --git a/Sources/SPDiffable/Table/Models/SPDiffableTableRowTextField.swift b/Sources/SPDiffable/Table/Models/SPDiffableTableRowTextField.swift
deleted file mode 100644
index 87fab3a..0000000
--- a/Sources/SPDiffable/Table/Models/SPDiffableTableRowTextField.swift
+++ /dev/null
@@ -1,59 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTableRowTextField: SPDiffableItem {
-
- open var icon: UIImage?
- open var text: String?
- open var placeholder: String
- open var autocorrectionType: UITextAutocorrectionType
- open var keyboardType: UIKeyboardType
- open var autocapitalizationType: UITextAutocapitalizationType
- open var clearButtonMode: UITextField.ViewMode
- open weak var delegate: UITextFieldDelegate?
- open var editable: Bool
-
- public init(
- id: String,
- icon: UIImage? = nil,
- text: String?,
- placeholder: String,
- autocorrectionType: UITextAutocorrectionType,
- keyboardType: UIKeyboardType,
- autocapitalizationType: UITextAutocapitalizationType,
- clearButtonMode: UITextField.ViewMode,
- delegate: UITextFieldDelegate?,
- editable: Bool = true
- ) {
- self.icon = icon
- self.text = text
- self.placeholder = placeholder
- self.delegate = delegate
- self.autocorrectionType = autocorrectionType
- self.keyboardType = keyboardType
- self.autocapitalizationType = autocapitalizationType
- self.clearButtonMode = clearButtonMode
- self.editable = editable
- super.init(id: id)
- }
-}
diff --git a/Sources/SPDiffable/Table/Models/SPDiffableTableRowTextFieldTitle.swift b/Sources/SPDiffable/Table/Models/SPDiffableTableRowTextFieldTitle.swift
deleted file mode 100644
index 2abf33a..0000000
--- a/Sources/SPDiffable/Table/Models/SPDiffableTableRowTextFieldTitle.swift
+++ /dev/null
@@ -1,44 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-open class SPDiffableTableRowTextFieldTitle: SPDiffableTableRowTextField {
-
- open var title: String
-
- public init(
- id: String,
- icon: UIImage? = nil,
- title: String,
- text: String?,
- placeholder: String,
- autocorrectionType: UITextAutocorrectionType,
- keyboardType: UIKeyboardType,
- autocapitalizationType: UITextAutocapitalizationType,
- clearButtonMode: UITextField.ViewMode,
- delegate: UITextFieldDelegate?,
- editable: Bool = true
- ) {
- self.title = title
- super.init(id: id, icon: icon, text: text, placeholder: placeholder, autocorrectionType: autocorrectionType, keyboardType: keyboardType, autocapitalizationType: autocapitalizationType, clearButtonMode: clearButtonMode, delegate: delegate, editable: editable)
- }
-}
diff --git a/Sources/SPDiffable/Table/Protocols/SPDiffableTableDelegate.swift b/Sources/SPDiffable/Table/Protocols/SPDiffableTableDelegate.swift
deleted file mode 100644
index b6438d1..0000000
--- a/Sources/SPDiffable/Table/Protocols/SPDiffableTableDelegate.swift
+++ /dev/null
@@ -1,34 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, *)
-@objc public protocol SPDiffableTableDelegate: AnyObject {
-
- @objc optional func diffableTableView(_ tableView: UITableView, didSelectItem item: SPDiffableItem, indexPath: IndexPath)
-
- #if canImport(UIKit) && (os(iOS))
- @objc optional func diffableTableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForItem item: SPDiffableItem, at indexPath: IndexPath) -> UISwipeActionsConfiguration?
-
- @objc optional func diffableTableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForItem item: SPDiffableItem, at indexPath: IndexPath) -> UISwipeActionsConfiguration?
- #endif
-}
diff --git a/Sources/SPDiffable/Table/Protocols/SPDiffableTableMediator.swift b/Sources/SPDiffable/Table/Protocols/SPDiffableTableMediator.swift
deleted file mode 100644
index e572cef..0000000
--- a/Sources/SPDiffable/Table/Protocols/SPDiffableTableMediator.swift
+++ /dev/null
@@ -1,34 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, *)
-@objc public protocol SPDiffableTableMediator: AnyObject {
-
- @objc optional func diffableTableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
-
- @objc optional func diffableTableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath)
-
- @objc optional func diffableTableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool
-
- @objc optional func diffableTableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath)
-}
diff --git a/Sources/SPDiffable/Table/SPDiffableTableController.swift b/Sources/SPDiffable/Table/SPDiffableTableController.swift
deleted file mode 100644
index 60c4d10..0000000
--- a/Sources/SPDiffable/Table/SPDiffableTableController.swift
+++ /dev/null
@@ -1,54 +0,0 @@
-// The MIT License (MIT)
-// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.io)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-import UIKit
-
-@available(iOS 13.0, tvOS 13, *)
-open class SPDiffableTableController: UITableViewController {
-
- open var diffableDataSource: SPDiffableTableDataSource?
-
- // MARK: - Lifecycle
-
- open override func viewDidLoad() {
- super.viewDidLoad()
- tableView.delaysContentTouches = false
- tableView.register(SPDiffableTableViewCell.self, forCellReuseIdentifier: SPDiffableTableViewCell.reuseIdentifier)
- tableView.register(SPDiffableSubtitleTableViewCell.self, forCellReuseIdentifier: SPDiffableSubtitleTableViewCell.reuseIdentifier)
- tableView.register(SPDiffableTextFieldTableViewCell.self, forCellReuseIdentifier: SPDiffableTextFieldTableViewCell.reuseIdentifier)
- tableView.register(SPDiffableTextFieldTitleTableViewCell.self, forCellReuseIdentifier: SPDiffableTextFieldTitleTableViewCell.reuseIdentifier)
- }
-
- // MARK: - Configure
-
- open func configureDiffable(
- sections: [SPDiffableSection],
- cellProviders: [SPDiffableTableDataSource.CellProvider],
- headerFooterProviders: [SPDiffableTableDataSource.HeaderFooterProvider] = []
- ) {
- diffableDataSource = SPDiffableTableDataSource(
- tableView: tableView,
- cellProviders: cellProviders,
- headerFooterProviders: headerFooterProviders
- )
- diffableDataSource?.set(sections, animated: false)
- }
-}
diff --git a/TODO.md b/TODO.md
deleted file mode 100644
index f8da982..0000000
--- a/TODO.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# TODO
-
-Here provided ideas or features which will be implemented soon.
-
-- Complete class `SPDiffableTableView`.