diff --git a/Example/DebugAdjustableDemo.xcodeproj/project.pbxproj b/Example/AdjustableDemo.xcodeproj/project.pbxproj similarity index 89% rename from Example/DebugAdjustableDemo.xcodeproj/project.pbxproj rename to Example/AdjustableDemo.xcodeproj/project.pbxproj index 197e96e..a758ba4 100644 --- a/Example/DebugAdjustableDemo.xcodeproj/project.pbxproj +++ b/Example/AdjustableDemo.xcodeproj/project.pbxproj @@ -13,19 +13,19 @@ 66DFDEF42BBB96310042EE92 /* ReplicatorLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DFDEF32BBB96310042EE92 /* ReplicatorLayerViewController.swift */; }; 66DFDEF92BBB96320042EE92 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 66DFDEF82BBB96320042EE92 /* Assets.xcassets */; }; 66DFDEFC2BBB96320042EE92 /* Base in Resources */ = {isa = PBXBuildFile; fileRef = 66DFDEFB2BBB96320042EE92 /* Base */; }; - 66DFDF092BBBBA620042EE92 /* DebugAdjustable in Frameworks */ = {isa = PBXBuildFile; productRef = 66DFDF082BBBBA620042EE92 /* DebugAdjustable */; }; + 66DFDF092BBBBA620042EE92 /* Adjustable in Frameworks */ = {isa = PBXBuildFile; productRef = 66DFDF082BBBBA620042EE92 /* Adjustable */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 66270C4A2C0D62B000F20019 /* SwiftUIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIViewController.swift; sourceTree = ""; }; - 66DFDEEC2BBB96310042EE92 /* DebugAdjustableDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DebugAdjustableDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 66DFDEEC2BBB96310042EE92 /* AdjustableDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AdjustableDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 66DFDEEF2BBB96310042EE92 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 66DFDEF12BBB96310042EE92 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 66DFDEF32BBB96310042EE92 /* ReplicatorLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReplicatorLayerViewController.swift; sourceTree = ""; }; 66DFDEF82BBB96320042EE92 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 66DFDEFB2BBB96320042EE92 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 66DFDEFD2BBB96320042EE92 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 66DFDF072BBBBA520042EE92 /* DebugAdjustable */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = DebugAdjustable; path = ..; sourceTree = ""; }; + 66DFDF072BBBBA520042EE92 /* Adjustable */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Adjustable; path = ..; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -33,7 +33,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 66DFDF092BBBBA620042EE92 /* DebugAdjustable in Frameworks */, + 66DFDF092BBBBA620042EE92 /* Adjustable in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -43,8 +43,8 @@ 66DFDEE32BBB96310042EE92 = { isa = PBXGroup; children = ( - 66DFDF072BBBBA520042EE92 /* DebugAdjustable */, - 66DFDEEE2BBB96310042EE92 /* DebugAdjustableDemo */, + 66DFDF072BBBBA520042EE92 /* Adjustable */, + 66DFDEEE2BBB96310042EE92 /* AdjustableDemo */, 66DFDEED2BBB96310042EE92 /* Products */, 66DFDF042BBB96540042EE92 /* Frameworks */, ); @@ -53,12 +53,12 @@ 66DFDEED2BBB96310042EE92 /* Products */ = { isa = PBXGroup; children = ( - 66DFDEEC2BBB96310042EE92 /* DebugAdjustableDemo.app */, + 66DFDEEC2BBB96310042EE92 /* AdjustableDemo.app */, ); name = Products; sourceTree = ""; }; - 66DFDEEE2BBB96310042EE92 /* DebugAdjustableDemo */ = { + 66DFDEEE2BBB96310042EE92 /* AdjustableDemo */ = { isa = PBXGroup; children = ( 66DFDEEF2BBB96310042EE92 /* AppDelegate.swift */, @@ -69,7 +69,7 @@ 66DFDEFA2BBB96320042EE92 /* LaunchScreen.storyboard */, 66DFDEFD2BBB96320042EE92 /* Info.plist */, ); - path = DebugAdjustableDemo; + path = AdjustableDemo; sourceTree = ""; }; 66DFDF042BBB96540042EE92 /* Frameworks */ = { @@ -82,9 +82,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 66DFDEEB2BBB96310042EE92 /* DebugAdjustableDemo */ = { + 66DFDEEB2BBB96310042EE92 /* AdjustableDemo */ = { isa = PBXNativeTarget; - buildConfigurationList = 66DFDF002BBB96320042EE92 /* Build configuration list for PBXNativeTarget "DebugAdjustableDemo" */; + buildConfigurationList = 66DFDF002BBB96320042EE92 /* Build configuration list for PBXNativeTarget "AdjustableDemo" */; buildPhases = ( 66DFDEE82BBB96310042EE92 /* Sources */, 66DFDEE92BBB96310042EE92 /* Frameworks */, @@ -94,12 +94,12 @@ ); dependencies = ( ); - name = DebugAdjustableDemo; + name = AdjustableDemo; packageProductDependencies = ( - 66DFDF082BBBBA620042EE92 /* DebugAdjustable */, + 66DFDF082BBBBA620042EE92 /* Adjustable */, ); - productName = DebugAdjustableDemo; - productReference = 66DFDEEC2BBB96310042EE92 /* DebugAdjustableDemo.app */; + productName = AdjustableDemo; + productReference = 66DFDEEC2BBB96310042EE92 /* AdjustableDemo.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -117,7 +117,7 @@ }; }; }; - buildConfigurationList = 66DFDEE72BBB96310042EE92 /* Build configuration list for PBXProject "DebugAdjustableDemo" */; + buildConfigurationList = 66DFDEE72BBB96310042EE92 /* Build configuration list for PBXProject "AdjustableDemo" */; compatibilityVersion = "Xcode 14.0"; developmentRegion = en; hasScannedForEncodings = 0; @@ -130,7 +130,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 66DFDEEB2BBB96310042EE92 /* DebugAdjustableDemo */, + 66DFDEEB2BBB96310042EE92 /* AdjustableDemo */, ); }; /* End PBXProject section */ @@ -301,7 +301,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 6TK23TLYP7; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = DebugAdjustableDemo/Info.plist; + INFOPLIST_FILE = AdjustableDemo/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; @@ -311,7 +311,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = ca.adambell.DebugAdjustableDemo; + PRODUCT_BUNDLE_IDENTIFIER = ca.adambell.AdjustableDemo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; @@ -328,7 +328,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 6TK23TLYP7; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = DebugAdjustableDemo/Info.plist; + INFOPLIST_FILE = AdjustableDemo/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; @@ -338,7 +338,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = ca.adambell.DebugAdjustableDemo; + PRODUCT_BUNDLE_IDENTIFIER = ca.adambell.AdjustableDemo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; @@ -349,7 +349,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 66DFDEE72BBB96310042EE92 /* Build configuration list for PBXProject "DebugAdjustableDemo" */ = { + 66DFDEE72BBB96310042EE92 /* Build configuration list for PBXProject "AdjustableDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( 66DFDEFE2BBB96320042EE92 /* Debug */, @@ -358,7 +358,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 66DFDF002BBB96320042EE92 /* Build configuration list for PBXNativeTarget "DebugAdjustableDemo" */ = { + 66DFDF002BBB96320042EE92 /* Build configuration list for PBXNativeTarget "AdjustableDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( 66DFDF012BBB96320042EE92 /* Debug */, @@ -370,9 +370,9 @@ /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ - 66DFDF082BBBBA620042EE92 /* DebugAdjustable */ = { + 66DFDF082BBBBA620042EE92 /* Adjustable */ = { isa = XCSwiftPackageProductDependency; - productName = DebugAdjustable; + productName = Adjustable; }; /* End XCSwiftPackageProductDependency section */ }; diff --git a/Example/DebugAdjustableDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/AdjustableDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from Example/DebugAdjustableDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to Example/AdjustableDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/Example/DebugAdjustableDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/AdjustableDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from Example/DebugAdjustableDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to Example/AdjustableDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Example/DebugAdjustableDemo.xcodeproj/xcshareddata/xcschemes/DebugAdjustableDemo.xcscheme b/Example/AdjustableDemo.xcodeproj/xcshareddata/xcschemes/AdjustableDemo.xcscheme similarity index 81% rename from Example/DebugAdjustableDemo.xcodeproj/xcshareddata/xcschemes/DebugAdjustableDemo.xcscheme rename to Example/AdjustableDemo.xcodeproj/xcshareddata/xcschemes/AdjustableDemo.xcscheme index 7cb9f88..f68a36d 100644 --- a/Example/DebugAdjustableDemo.xcodeproj/xcshareddata/xcschemes/DebugAdjustableDemo.xcscheme +++ b/Example/AdjustableDemo.xcodeproj/xcshareddata/xcschemes/AdjustableDemo.xcscheme @@ -16,9 +16,9 @@ + BuildableName = "AdjustableDemo.app" + BlueprintName = "AdjustableDemo" + ReferencedContainer = "container:AdjustableDemo.xcodeproj"> @@ -45,9 +45,9 @@ + BuildableName = "AdjustableDemo.app" + BlueprintName = "AdjustableDemo" + ReferencedContainer = "container:AdjustableDemo.xcodeproj"> @@ -62,9 +62,9 @@ + BuildableName = "AdjustableDemo.app" + BlueprintName = "AdjustableDemo" + ReferencedContainer = "container:AdjustableDemo.xcodeproj"> diff --git a/Example/DebugAdjustableDemo/AppDelegate.swift b/Example/AdjustableDemo/AppDelegate.swift similarity index 98% rename from Example/DebugAdjustableDemo/AppDelegate.swift rename to Example/AdjustableDemo/AppDelegate.swift index 01c6a85..7ece8c9 100644 --- a/Example/DebugAdjustableDemo/AppDelegate.swift +++ b/Example/AdjustableDemo/AppDelegate.swift @@ -1,6 +1,6 @@ // // AppDelegate.swift -// DebugAdjustableDemo +// AdjustableDemo // // Created by Adam Bell on 4/1/24. // diff --git a/Example/DebugAdjustableDemo/Assets.xcassets/AccentColor.colorset/Contents.json b/Example/AdjustableDemo/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from Example/DebugAdjustableDemo/Assets.xcassets/AccentColor.colorset/Contents.json rename to Example/AdjustableDemo/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/Example/AdjustableDemo/Assets.xcassets/AdjustableLogo.imageset/AdjustableLogo.png b/Example/AdjustableDemo/Assets.xcassets/AdjustableLogo.imageset/AdjustableLogo.png new file mode 100644 index 0000000..13b94b9 Binary files /dev/null and b/Example/AdjustableDemo/Assets.xcassets/AdjustableLogo.imageset/AdjustableLogo.png differ diff --git a/Example/DebugAdjustableDemo/Assets.xcassets/DebugAdjustable.imageset/Contents.json b/Example/AdjustableDemo/Assets.xcassets/AdjustableLogo.imageset/Contents.json similarity index 74% rename from Example/DebugAdjustableDemo/Assets.xcassets/DebugAdjustable.imageset/Contents.json rename to Example/AdjustableDemo/Assets.xcassets/AdjustableLogo.imageset/Contents.json index 56caaaf..3566c2c 100644 --- a/Example/DebugAdjustableDemo/Assets.xcassets/DebugAdjustable.imageset/Contents.json +++ b/Example/AdjustableDemo/Assets.xcassets/AdjustableLogo.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "DebugAdjustable.png", + "filename" : "AdjustableLogo.png", "idiom" : "universal" } ], diff --git a/Example/DebugAdjustableDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/AdjustableDemo/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Example/DebugAdjustableDemo/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Example/AdjustableDemo/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/Example/DebugAdjustableDemo/Assets.xcassets/Contents.json b/Example/AdjustableDemo/Assets.xcassets/Contents.json similarity index 100% rename from Example/DebugAdjustableDemo/Assets.xcassets/Contents.json rename to Example/AdjustableDemo/Assets.xcassets/Contents.json diff --git a/Example/DebugAdjustableDemo/Base.lproj/LaunchScreen.storyboard b/Example/AdjustableDemo/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from Example/DebugAdjustableDemo/Base.lproj/LaunchScreen.storyboard rename to Example/AdjustableDemo/Base.lproj/LaunchScreen.storyboard diff --git a/Example/DebugAdjustableDemo/Info.plist b/Example/AdjustableDemo/Info.plist similarity index 100% rename from Example/DebugAdjustableDemo/Info.plist rename to Example/AdjustableDemo/Info.plist diff --git a/Example/DebugAdjustableDemo/ReplicatorLayerViewController.swift b/Example/AdjustableDemo/ReplicatorLayerViewController.swift similarity index 82% rename from Example/DebugAdjustableDemo/ReplicatorLayerViewController.swift rename to Example/AdjustableDemo/ReplicatorLayerViewController.swift index e934751..78c4864 100644 --- a/Example/DebugAdjustableDemo/ReplicatorLayerViewController.swift +++ b/Example/AdjustableDemo/ReplicatorLayerViewController.swift @@ -1,11 +1,11 @@ // // ViewController.swift -// DebugAdjustableDemo +// AdjustableDemo // // Created by Adam Bell on 4/1/24. // -import DebugAdjustable +import Adjustable import UIKit public let MotionBlue = UIColor(red: 0.47, green: 0.80, blue: 0.99, alpha: 1.00) @@ -14,22 +14,22 @@ import Combine class DemoView: UIView { - @DebugAdjustable(24...144.0, title: "square.size") var squareSize: Double = 44 + @Adjustable(24...144.0, title: "square.size") var squareSize: Double = 44 - @DebugAdjustable(0.0...100.0) var sourceCopyCount: Double = 0.0 - @DebugAdjustable(-200...200.0) var sourceInstanceTransformX: Double = 0.0 - @DebugAdjustable(-200...200.0) var sourceInstanceTransformY: Double = 0.0 + @Adjustable(0.0...100.0) var sourceCopyCount: Double = 0.0 + @Adjustable(-200...200.0) var sourceInstanceTransformX: Double = 0.0 + @Adjustable(-200...200.0) var sourceInstanceTransformY: Double = 0.0 - @DebugAdjustable(0.0...100.0) var copyCopyCount: Double = 0.0 - @DebugAdjustable(-200...200.0) var copyInstanceTransformX: Double = 0.0 - @DebugAdjustable(-200...200.0) var copyInstanceTransformY: Double = 0.0 + @Adjustable(0.0...100.0) var copyCopyCount: Double = 0.0 + @Adjustable(-200...200.0) var copyInstanceTransformX: Double = 0.0 + @Adjustable(-200...200.0) var copyInstanceTransformY: Double = 0.0 - @DebugAdjustable(-200...200.0, valueChanged: { enclosingSelf, value in + @Adjustable(-200...200.0, valueChanged: { enclosingSelf, value in print(enclosingSelf) print(value) }) var testPrint: Double = 0.0 - @DebugAdjustable(-10...10.0) var somePublishedValue: Double = 0.0 + @Adjustable(-10...10.0) var somePublishedValue: Double = 0.0 let adjustableSquare = CALayer() diff --git a/Example/DebugAdjustableDemo/SceneDelegate.swift b/Example/AdjustableDemo/SceneDelegate.swift similarity index 99% rename from Example/DebugAdjustableDemo/SceneDelegate.swift rename to Example/AdjustableDemo/SceneDelegate.swift index b46bd0d..ca1f6de 100644 --- a/Example/DebugAdjustableDemo/SceneDelegate.swift +++ b/Example/AdjustableDemo/SceneDelegate.swift @@ -1,6 +1,6 @@ // // SceneDelegate.swift -// DebugAdjustableDemo +// AdjustableDemo // // Created by Adam Bell on 4/1/24. // diff --git a/Example/DebugAdjustableDemo/SwiftUIViewController.swift b/Example/AdjustableDemo/SwiftUIViewController.swift similarity index 76% rename from Example/DebugAdjustableDemo/SwiftUIViewController.swift rename to Example/AdjustableDemo/SwiftUIViewController.swift index 54d3d2e..dd4d08d 100644 --- a/Example/DebugAdjustableDemo/SwiftUIViewController.swift +++ b/Example/AdjustableDemo/SwiftUIViewController.swift @@ -1,18 +1,18 @@ // // SwiftUIViewController.swift -// DebugAdjustableDemo +// AdjustableDemo // // Created by Adam Bell on 6/2/24. // -import DebugAdjustable +import Adjustable import SwiftUI class Model: ObservableObject { - @DebugAdjustable(0.0...Double.pi) var rotation: Double = 0.0 - @DebugAdjustable(0.0...2.0) var response: Double = 0.3 - @DebugAdjustable(0.0...1.0) var dampingFraction: Double = 1.0 + @Adjustable(0.0...Double.pi) var rotation: Double = 0.0 + @Adjustable(0.0...2.0) var response: Double = 0.3 + @Adjustable(0.0...1.0) var dampingFraction: Double = 1.0 } @@ -23,7 +23,7 @@ struct SwiftUIView: View { @State var pressed: Bool = false var body: some View { - Image("DebugAdjustable") + Image("AdjustableLogo") .resizable() .aspectRatio(contentMode: .fit) .padding(24.0) @@ -36,16 +36,16 @@ struct SwiftUIView: View { .scaleEffect(pressed ? CGSize(width: 0.8, height: 0.8) : CGSize(width: 1.0, height: 1.0)) .gesture( DragGesture(minimumDistance: 0) - .onChanged({ _ in + .onChanged { _ in withAnimation(.spring(response: model.response, dampingFraction: model.dampingFraction)) { self.pressed = true } - }) - .onEnded({ _ in + } + .onEnded { _ in withAnimation(.spring(response: model.response, dampingFraction: model.dampingFraction)) { self.pressed = false } - }) + } ) .scaleEffect(CGSize(width: 0.8, height: 0.8)) } diff --git a/Example/DebugAdjustableDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/DebugAdjustableDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index ca4b968..0000000 --- a/Example/DebugAdjustableDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,23 +0,0 @@ -{ - "pins" : [ - { - "identity" : "motion", - "kind" : "remoteSourceControl", - "location" : "https://github.com/b3ll/Motion", - "state" : { - "revision" : "d0439dd8f31ef16c3e17ef12e8d1921b00341d67", - "version" : "0.1.5" - } - }, - { - "identity" : "swift-numerics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-numerics", - "state" : { - "revision" : "0a5bc04095a675662cf24757cc0640aa2204253b", - "version" : "1.0.2" - } - } - ], - "version" : 2 -} diff --git a/Example/DebugAdjustableDemo/Assets.xcassets/DebugAdjustable.imageset/DebugAdjustable.png b/Example/DebugAdjustableDemo/Assets.xcassets/DebugAdjustable.imageset/DebugAdjustable.png deleted file mode 100644 index 647d44c..0000000 Binary files a/Example/DebugAdjustableDemo/Assets.xcassets/DebugAdjustable.imageset/DebugAdjustable.png and /dev/null differ diff --git a/Package.swift b/Package.swift index 01a17ee..bbb4dac 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( - name: "DebugAdjustable", + name: "Adjustable", platforms: [ .iOS(.v17), .tvOS(.v17), @@ -12,15 +12,15 @@ let package = Package( ], products: [ .library( - name: "DebugAdjustable", - targets: ["DebugAdjustable"]), + name: "Adjustable", + targets: ["Adjustable"]), ], dependencies: [ .package(url: "https://github.com/b3ll/Motion", .upToNextMajor(from: "0.1.5")), ], targets: [ .target( - name: "DebugAdjustable", + name: "Adjustable", dependencies: ["Motion"]), ], swiftLanguageVersions: [.v5] diff --git a/README.md b/README.md index 4dd4d65..ff29890 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -![DebugAdjustable-Logo](https://github.com/b3ll/DebugAdjustable/blob/main/Resources/DebugAdjustableLogo.png?raw=true) +![Adjustable-Logo](https://github.com/b3ll/Adjustable/blob/main/Resources/AdjustableLogo.png?raw=true)

-This package provides property wrappers that can be used on properties for any value conforming to `ClosedRange` to allow for super fast iteration of UIs without the need to recompile an application. It does so by automatically an interactive slider for any property that you annotate with `@DebugAdjustable` that sits on top of your app's window so you can dynamically adjust properties and see them update live. It's powered by a lot of the stuff I experimented with to make [SetNeedsDisplay](https://github.com/b3ll/SetNeedsDisplay). +This package provides property wrappers that can be used on properties for any value conforming to `ClosedRange` to allow for super fast iteration of UIs and interactions without the need to wait to recompile an application. It does so by automatically adding an interactive slider for any property that you annotate with `@Adjustable` that sits on top of your app's window so you can dynamically adjust properties and see them update live. It's powered by a lot of the stuff I experimented with to make [SetNeedsDisplay](https://github.com/b3ll/SetNeedsDisplay). + +This is *perfect* for refining animation parameters, tweaking constants, or adjusting things until they feel just right without needing to constantly recompile your app and allowing you to focus on making things feel great. It uses a lot of neat runtime tricks to pull out the name of the variable so it can appropriately name the relevant slider and also features a collapsible menu that you can tuck away when you don't need it (powered by [Motion](https://www.github.com/b3ll/Motion)!). @@ -14,7 +16,6 @@ It uses a lot of neat runtime tricks to pull out the name of the variable so it > [!Warning] > This code contains some private Swift API stuff that powers `@Published` so there's a strong likelihood this will break in the future. I'd like to figure out ways to make the API a lot nicer in general, so if you have any ideas, let me know! -- [DebugAdjustable](#debugadjustable) - [Usage](#usage) - [Installation](#installation) - [Requirements](#requirements) @@ -31,17 +32,17 @@ Annotate your property of a type that conforms to `ClosedRange` like so: class MyView: UIView { // A slider from `0.0` to `100.0` starting at `20.0` will be created. - // Anytime the slider is changed, `invalidateForDebugAdjustable()` is called on the enclosing class. - @DebugAdjustable(0.0...100.0) var someCustomProperty: Double = 20.0 + // Anytime the slider is changed, `invalidateForAdjustable()` is called on the enclosing class. + @Adjustable(0.0...100.0) var someCustomProperty: Double = 20.0 // A slider from `0.0` to `100.0` starting at `20.0` will be created. // Anytime the slider is changed, the `valueChanged` block is called with an instance of `self` that you can reference as well as the new value. - @DebugAdjustable(0.0...100.0, valueChanged: { enclosingSelf, newValue in + @Adjustable(0.0...100.0, valueChanged: { enclosingSelf, newValue in // access `self` via `enclosingSelf` // do what you want with `newValue }) var someOtherCustomProperty: Double = 20.0 - override func invalidateForDebugAdjustable() { + override func invalidateForAdjustable() { print("someCustomProperty: \(someCustomProperty)") print("someOtherCustomProperty: \(someOtherCustomProperty)") } @@ -54,7 +55,7 @@ You can also use `@Published`! ```swift class MyCoolClass { - @DebugAdjustable(0.0...100.0) var somePublishedProperty: Double = 20.0 + @Adjustable(0.0...100.0) var somePublishedProperty: Double = 20.0 var publishedCancellable: AnyCancellable? @@ -72,7 +73,7 @@ This even works in SwiftUI! ```swift class Model: ObservableObject { - @DebugAdjustable(0.0...255.0) var somePublishedProperty: Double = 20.0 + @Adjustable(0.0...255.0) var somePublishedProperty: Double = 20.0 } @@ -88,7 +89,7 @@ struct MyView: View { } ``` -Anytime any slider is adjusted, `invalidateForDebugAdjustable` will be called on the enclosing class. This by default calls `setNeedsLayout` on `UIView` and `UIViewController`'s view, but this can be overridden and used to update the view's state or perform any action, really. There's also an inline block that can be supplied that contains an instance of the enclosing class (`enclosingSelf`) as well as the new value from the slider. +Anytime any slider is adjusted, `invalidateForAdjustable` will be called on the enclosing class. This by default calls `setNeedsLayout` on `UIView` and `UIViewController`'s view, but this can be overridden and used to update the view's state or perform any action, really. There's also an inline block that can be supplied that contains an instance of the enclosing class (`enclosingSelf`) as well as the new value from the slider. One thing I use it for is layout constants that are referenced in `layoutSubviews`. Adjusting the slider will change the value, invalidate layout, and call `layoutSubviews` which makes iteration really easy. @@ -99,19 +100,19 @@ One thing I use it for is layout constants that are referenced in `layoutSubview - iOS 17+ - Swift 5.9 or higher -Currently DebugAdjustable supports Swift Package Manager (or manually adding `DebugAdjustable.swift` to your project). +Currently Adjustable supports Swift Package Manager (or manually adding `Adjustable.swift` to your project). ## Swift Package Manager Add the following to your `Package.swift` (or add it via Xcode's GUI): ```swift -.package(url: "https://github.com/b3ll/DebugAdjustable", from: "0.0.1") +.package(url: "https://github.com/b3ll/Adjustable", from: "0.0.1") ``` # License -DebugAdjustable is licensed under the [BSD 2-clause license](https://github.com/b3ll/DebugAdjustable/blob/master/LICENSE). +Adjustable is licensed under the [BSD 2-clause license](https://github.com/b3ll/Adjustable/blob/master/LICENSE). # Thanks diff --git a/Resources/AdjustableLogo.png b/Resources/AdjustableLogo.png new file mode 100644 index 0000000..13b94b9 Binary files /dev/null and b/Resources/AdjustableLogo.png differ diff --git a/Resources/DebugAdjustableLogo.png b/Resources/DebugAdjustableLogo.png deleted file mode 100644 index 647d44c..0000000 Binary files a/Resources/DebugAdjustableLogo.png and /dev/null differ diff --git a/Resources/DemoVideo-50.mp4 b/Resources/DemoVideo-50.mp4 new file mode 100644 index 0000000..895b5f4 Binary files /dev/null and b/Resources/DemoVideo-50.mp4 differ diff --git a/Resources/DemoVideo.gif b/Resources/DemoVideo.gif index e5192d6..6ce60b2 100644 Binary files a/Resources/DemoVideo.gif and b/Resources/DemoVideo.gif differ diff --git a/Resources/DemoVideo.mov b/Resources/DemoVideo.mov deleted file mode 100644 index d3ffad3..0000000 Binary files a/Resources/DemoVideo.mov and /dev/null differ diff --git a/Resources/DemoVideo.mp4 b/Resources/DemoVideo.mp4 new file mode 100644 index 0000000..337d6c7 Binary files /dev/null and b/Resources/DemoVideo.mp4 differ diff --git a/Resources/gifenc.sh b/Resources/gifenc.sh deleted file mode 100755 index 27a3d25..0000000 --- a/Resources/gifenc.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -# Thank you http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html#usage - -palette="/tmp/palette.png" -filters="fps=50,scale=320:-1:flags=lanczos" - -ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette -ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2 diff --git a/Resources/render_files.sh b/Resources/render_files.sh new file mode 100755 index 0000000..e7dc2fc --- /dev/null +++ b/Resources/render_files.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +rm -f DemoVideo.gif || true +rm -f DemoVideo-50.mp4 || true + +ffmpeg -i DemoVideo.mp4 -filter:v fps=50 DemoVideo-50.mp4 + +gifski --fps 50 --width 1178 --height 2556 --extra --quality 100 --motion-quality 100 --lossy-quality 100 --repeat 0 -o DemoVideo.gif DemoVideo-50.mp4 diff --git a/Sources/DebugAdjustable/DebugAdjustable.swift b/Sources/Adjustable/Adjustable.swift similarity index 68% rename from Sources/DebugAdjustable/DebugAdjustable.swift rename to Sources/Adjustable/Adjustable.swift index aa898ee..38a26cb 100644 --- a/Sources/DebugAdjustable/DebugAdjustable.swift +++ b/Sources/Adjustable/Adjustable.swift @@ -1,5 +1,5 @@ // -// DebugAdjustable.swift +// Adjustable.swift // // // Created by Adam Bell on 4/1/24. @@ -13,54 +13,54 @@ import UIKit /** A property wrapper for `UIView` that will adjust a given value by use of a `UISlider`. - - Note: This relies on `DebugAdjustableInvalidation` to be implemented on the owning class. Defaults are provided for `UIView` and `UIViewController`. + - Note: This relies on `AdjustableInvalidation` to be implemented on the owning class. Defaults are provided for `UIView` and `UIViewController`. ``` class SomeView: UIView { - @DebugAdjustable(in: 0.0...100.0) var subviewPadding: CGFloat = 0.0 + @Adjustable(in: 0.0...100.0) var subviewPadding: CGFloat = 0.0 } ``` */ -public protocol DebugAdjustableInvalidation { +public protocol AdjustableInvalidation { - func invalidateForDebugAdjustable() + func invalidateForAdjustable() } -extension UIView: DebugAdjustableInvalidation { +extension UIView: AdjustableInvalidation { - @objc open func invalidateForDebugAdjustable() { + @objc open func invalidateForAdjustable() { setNeedsLayout() } } -extension UIViewController: DebugAdjustableInvalidation { +extension UIViewController: AdjustableInvalidation { - @objc open func invalidateForDebugAdjustable() { + @objc open func invalidateForAdjustable() { viewIfLoaded?.setNeedsLayout() } } -public protocol DebugAdjustableSupportedValue: BinaryFloatingPoint {} +public protocol AdjustableSupportedValue: BinaryFloatingPoint {} -extension Float: DebugAdjustableSupportedValue {} -extension Double: DebugAdjustableSupportedValue {} +extension Float: AdjustableSupportedValue {} +extension Double: AdjustableSupportedValue {} @propertyWrapper -public final class DebugAdjustable where Value: DebugAdjustableSupportedValue { +public final class Adjustable where Value: AdjustableSupportedValue { - // Would like to make this just `DebugAdjustableInvalidation`, but that makes things tricky with supporting ObservableObject. + // Would like to make this just `AdjustableInvalidation`, but that makes things tricky with supporting ObservableObject. public typealias ViewType = AnyObject - public typealias ValueChanged = (_ enclosingSelf: DebugAdjustableInvalidation, _ value: Value) -> Void + public typealias ValueChanged = (_ enclosingSelf: AdjustableInvalidation, _ value: Value) -> Void @Published private var value: Value - private var debugSlider: DebugAdjustableSlider + private var debugSlider: AdjustableSlider private var targetToInvalidate: AnyObject? private var title: String? @@ -70,7 +70,7 @@ public final class DebugAdjustable where Value: DebugAdjustableSupportedV public static subscript( _enclosingInstance instance: EnclosingSelf, wrapped wrappedKeyPath: ReferenceWritableKeyPath, - storage storageKeyPath: ReferenceWritableKeyPath + storage storageKeyPath: ReferenceWritableKeyPath ) -> Value where EnclosingSelf: ViewType { get { // Configure on the getter since it's called anytime the value is accessed (including initially) @@ -107,11 +107,11 @@ public final class DebugAdjustable where Value: DebugAdjustableSupportedV public init(wrappedValue: Value, _ valueRange: ClosedRange = 0.0...100.0, title: String? = nil, valueChanged: ValueChanged? = nil) { self.value = wrappedValue self.valueChanged = valueChanged - self.debugSlider = DebugAdjustableSlider(frame: .zero, minimumValue: Float(valueRange.lowerBound), maximumValue: Float(valueRange.upperBound)) + self.debugSlider = AdjustableSlider(frame: .zero, minimumValue: Float(valueRange.lowerBound), maximumValue: Float(valueRange.upperBound)) debugSlider.title = title debugSlider.onValueChanged = { [weak self] value in self?.value = Value(value) - (self?.targetToInvalidate as? DebugAdjustableInvalidation)?.invalidateForDebugAdjustable() + (self?.targetToInvalidate as? AdjustableInvalidation)?.invalidateForAdjustable() if let observableObject = self?.targetToInvalidate as? (any ObservableObject) { if let objectWillChange = (observableObject.objectWillChange as any Publisher) as? ObservableObjectPublisher { @@ -119,7 +119,7 @@ public final class DebugAdjustable where Value: DebugAdjustableSupportedV } } - if let targetToInvalidate = self?.targetToInvalidate, let valueChanged = self?.valueChanged, let targetToInvalidate = targetToInvalidate as? DebugAdjustableInvalidation { + if let targetToInvalidate = self?.targetToInvalidate, let valueChanged = self?.valueChanged, let targetToInvalidate = targetToInvalidate as? AdjustableInvalidation { valueChanged(targetToInvalidate, Value(value)) } } diff --git a/Sources/DebugAdjustable/DebugAdjustableSlider.swift b/Sources/Adjustable/AdjustableSlider.swift similarity index 96% rename from Sources/DebugAdjustable/DebugAdjustableSlider.swift rename to Sources/Adjustable/AdjustableSlider.swift index aa412d9..1122938 100644 --- a/Sources/DebugAdjustable/DebugAdjustableSlider.swift +++ b/Sources/Adjustable/AdjustableSlider.swift @@ -1,5 +1,5 @@ // -// DebugAdjustableSlider.swift +// AdjustableSlider.swift // // // Created by Adam Bell on 4/1/24. @@ -13,7 +13,7 @@ import UIKit private let MotionBlue = UIColor(red: 0.0, green: 212.0/255.0, blue: 1.0, alpha: 1.0) -public class DebugAdjustableSlider: UIView, UIGestureRecognizerDelegate { +public class AdjustableSlider: UIView, UIGestureRecognizerDelegate { enum DockedCorner: CaseIterable { case topLeading @@ -24,7 +24,7 @@ public class DebugAdjustableSlider: UIView, UIGestureRecognizerDelegate { private static var dockedCornerPoints: [DockedCorner: CGPoint] = [:] - private static var sliders: [DebugAdjustableSlider] = [] + private static var sliders: [AdjustableSlider] = [] internal static var sliderScrollView = { let sliderScrollView = UIScrollView(frame: .zero) sliderScrollView.isDirectionalLockEnabled = true @@ -368,10 +368,10 @@ fileprivate extension CGPoint { internal final class GestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate { public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { - guard let panGestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer, DebugAdjustableSlider.sliderContainerVisible else { return true } + guard let panGestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer, AdjustableSlider.sliderContainerVisible else { return true } - let velocity = panGestureRecognizer.velocity(in: DebugAdjustableSlider.sliderContainer) - return DebugAdjustableSlider.sliderScrollView.contentOffset.y <= DebugAdjustableSlider.sliderScrollView.contentInset.top && velocity.y > 0.0 + let velocity = panGestureRecognizer.velocity(in: AdjustableSlider.sliderContainer) + return AdjustableSlider.sliderScrollView.contentOffset.y <= AdjustableSlider.sliderScrollView.contentInset.top && velocity.y > 0.0 } }