diff --git a/Demo/Demo.xcodeproj/project.pbxproj b/Demo/Demo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..def8715 --- /dev/null +++ b/Demo/Demo.xcodeproj/project.pbxproj @@ -0,0 +1,419 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 55; + objects = { + +/* Begin PBXBuildFile section */ + 08020CCC28A838DC00255795 /* TableTestController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08020CCB28A838DC00255795 /* TableTestController.swift */; }; + 08E16CD9289ABA1C0019D7CB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08E16CD8289ABA1C0019D7CB /* AppDelegate.swift */; }; + 08E16CDB289ABA1C0019D7CB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08E16CDA289ABA1C0019D7CB /* SceneDelegate.swift */; }; + 08E16CDD289ABA1C0019D7CB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08E16CDC289ABA1C0019D7CB /* ViewController.swift */; }; + 08E16CE0289ABA1C0019D7CB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 08E16CDE289ABA1C0019D7CB /* Main.storyboard */; }; + 08E16CE2289ABA1D0019D7CB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 08E16CE1289ABA1D0019D7CB /* Assets.xcassets */; }; + 08E16CE5289ABA1D0019D7CB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 08E16CE3289ABA1D0019D7CB /* LaunchScreen.storyboard */; }; + 08F2594C28BD060D0098174B /* StackKit in Frameworks */ = {isa = PBXBuildFile; productRef = 08F2594B28BD060D0098174B /* StackKit */; }; + 08F2594E28BD06150098174B /* PinLayout in Frameworks */ = {isa = PBXBuildFile; productRef = 08F2594D28BD06150098174B /* PinLayout */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 08020CCB28A838DC00255795 /* TableTestController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableTestController.swift; sourceTree = ""; }; + 08E16CD5289ABA1C0019D7CB /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 08E16CD8289ABA1C0019D7CB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 08E16CDA289ABA1C0019D7CB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 08E16CDC289ABA1C0019D7CB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 08E16CDF289ABA1C0019D7CB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 08E16CE1289ABA1D0019D7CB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 08E16CE4289ABA1D0019D7CB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 08E16CE6289ABA1D0019D7CB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 08F2594A28BD05FA0098174B /* StackKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = StackKit; path = ..; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 08E16CD2289ABA1C0019D7CB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 08F2594E28BD06150098174B /* PinLayout in Frameworks */, + 08F2594C28BD060D0098174B /* StackKit in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08E16CCC289ABA1C0019D7CB = { + isa = PBXGroup; + children = ( + 08E58065289ABC6200625E0D /* Packages */, + 08E16CD7289ABA1C0019D7CB /* Demo */, + 08E16CD6289ABA1C0019D7CB /* Products */, + 08E58067289ABC9F00625E0D /* Frameworks */, + ); + sourceTree = ""; + }; + 08E16CD6289ABA1C0019D7CB /* Products */ = { + isa = PBXGroup; + children = ( + 08E16CD5289ABA1C0019D7CB /* Demo.app */, + ); + name = Products; + sourceTree = ""; + }; + 08E16CD7289ABA1C0019D7CB /* Demo */ = { + isa = PBXGroup; + children = ( + 08E16CD8289ABA1C0019D7CB /* AppDelegate.swift */, + 08E16CDA289ABA1C0019D7CB /* SceneDelegate.swift */, + 08E16CDC289ABA1C0019D7CB /* ViewController.swift */, + 08E16CDE289ABA1C0019D7CB /* Main.storyboard */, + 08E16CE1289ABA1D0019D7CB /* Assets.xcassets */, + 08E16CE3289ABA1D0019D7CB /* LaunchScreen.storyboard */, + 08E16CE6289ABA1D0019D7CB /* Info.plist */, + 08020CCB28A838DC00255795 /* TableTestController.swift */, + ); + path = Demo; + sourceTree = ""; + }; + 08E58065289ABC6200625E0D /* Packages */ = { + isa = PBXGroup; + children = ( + 08F2594A28BD05FA0098174B /* StackKit */, + ); + name = Packages; + sourceTree = ""; + }; + 08E58067289ABC9F00625E0D /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 08E16CD4289ABA1C0019D7CB /* Demo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 08E16CE9289ABA1D0019D7CB /* Build configuration list for PBXNativeTarget "Demo" */; + buildPhases = ( + 08E16CD1289ABA1C0019D7CB /* Sources */, + 08E16CD2289ABA1C0019D7CB /* Frameworks */, + 08E16CD3289ABA1C0019D7CB /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Demo; + packageProductDependencies = ( + 08F2594B28BD060D0098174B /* StackKit */, + 08F2594D28BD06150098174B /* PinLayout */, + ); + productName = TestStackKit; + productReference = 08E16CD5289ABA1C0019D7CB /* Demo.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 08E16CCD289ABA1C0019D7CB /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1340; + LastUpgradeCheck = 1340; + TargetAttributes = { + 08E16CD4289ABA1C0019D7CB = { + CreatedOnToolsVersion = 13.4.1; + }; + }; + }; + buildConfigurationList = 08E16CD0289ABA1C0019D7CB /* Build configuration list for PBXProject "Demo" */; + compatibilityVersion = "Xcode 13.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 08E16CCC289ABA1C0019D7CB; + packageReferences = ( + 085CA41F28BD0521000E74CD /* XCRemoteSwiftPackageReference "pinlayout" */, + ); + productRefGroup = 08E16CD6289ABA1C0019D7CB /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 08E16CD4289ABA1C0019D7CB /* Demo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 08E16CD3289ABA1C0019D7CB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 08E16CE5289ABA1D0019D7CB /* LaunchScreen.storyboard in Resources */, + 08E16CE2289ABA1D0019D7CB /* Assets.xcassets in Resources */, + 08E16CE0289ABA1C0019D7CB /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 08E16CD1289ABA1C0019D7CB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 08E16CDD289ABA1C0019D7CB /* ViewController.swift in Sources */, + 08E16CD9289ABA1C0019D7CB /* AppDelegate.swift in Sources */, + 08E16CDB289ABA1C0019D7CB /* SceneDelegate.swift in Sources */, + 08020CCC28A838DC00255795 /* TableTestController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 08E16CDE289ABA1C0019D7CB /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 08E16CDF289ABA1C0019D7CB /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 08E16CE3289ABA1D0019D7CB /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 08E16CE4289ABA1D0019D7CB /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 08E16CE7289ABA1D0019D7CB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = 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; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + 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; + IPHONEOS_DEPLOYMENT_TARGET = 15.5; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 08E16CE8289ABA1D0019D7CB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = 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; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + 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; + IPHONEOS_DEPLOYMENT_TARGET = 15.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 08E16CEA289ABA1D0019D7CB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 58CW6R4WKN; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Demo/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = in.iiiam.TestStackKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 08E16CEB289ABA1D0019D7CB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 58CW6R4WKN; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Demo/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = in.iiiam.TestStackKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 08E16CD0289ABA1C0019D7CB /* Build configuration list for PBXProject "Demo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 08E16CE7289ABA1D0019D7CB /* Debug */, + 08E16CE8289ABA1D0019D7CB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 08E16CE9289ABA1D0019D7CB /* Build configuration list for PBXNativeTarget "Demo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 08E16CEA289ABA1D0019D7CB /* Debug */, + 08E16CEB289ABA1D0019D7CB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 085CA41F28BD0521000E74CD /* XCRemoteSwiftPackageReference "pinlayout" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/layoutbox/pinlayout"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 08F2594B28BD060D0098174B /* StackKit */ = { + isa = XCSwiftPackageProductDependency; + productName = StackKit; + }; + 08F2594D28BD06150098174B /* PinLayout */ = { + isa = XCSwiftPackageProductDependency; + package = 085CA41F28BD0521000E74CD /* XCRemoteSwiftPackageReference "pinlayout" */; + productName = PinLayout; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 08E16CCD289ABA1C0019D7CB /* Project object */; +} diff --git a/Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..0bff115 --- /dev/null +++ b/Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "pinlayout", + "kind" : "remoteSourceControl", + "location" : "https://github.com/layoutbox/pinlayout", + "state" : { + "revision" : "75c88c5c374c7bc78a154ffdf963cd362f38258a", + "version" : "1.10.3" + } + } + ], + "version" : 2 +} diff --git a/Demo/Demo/AppDelegate.swift b/Demo/Demo/AppDelegate.swift new file mode 100644 index 0000000..4ea36dd --- /dev/null +++ b/Demo/Demo/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// TestStackKit +// +// Created by i on 2022/8/3. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/Demo/Demo/Assets.xcassets/AccentColor.colorset/Contents.json b/Demo/Demo/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Demo/Demo/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Demo/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json b/Demo/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..5a3257a --- /dev/null +++ b/Demo/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,93 @@ +{ + "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" : "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/Demo/Demo/Assets.xcassets/Contents.json b/Demo/Demo/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Demo/Demo/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Demo/Demo/Base.lproj/LaunchScreen.storyboard b/Demo/Demo/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Demo/Demo/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/Demo/Base.lproj/Main.storyboard b/Demo/Demo/Base.lproj/Main.storyboard new file mode 100644 index 0000000..9656e64 --- /dev/null +++ b/Demo/Demo/Base.lproj/Main.storyboard @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/Demo/Info.plist b/Demo/Demo/Info.plist new file mode 100644 index 0000000..dd3c9af --- /dev/null +++ b/Demo/Demo/Info.plist @@ -0,0 +1,25 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/Demo/Demo/SceneDelegate.swift b/Demo/Demo/SceneDelegate.swift new file mode 100644 index 0000000..3d9b31a --- /dev/null +++ b/Demo/Demo/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// TestStackKit +// +// Created by i on 2022/8/3. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/Demo/Demo/TableTestController.swift b/Demo/Demo/TableTestController.swift new file mode 100644 index 0000000..529ec6b --- /dev/null +++ b/Demo/Demo/TableTestController.swift @@ -0,0 +1,112 @@ +// +// TableTestController.swift +// TestStackKit +// +// Created by i on 2022/8/14. +// + +import UIKit +import StackKit + +struct User { + var name: String + var brief: String +} + +final class TableTestController: UIViewController { + + @IBOutlet weak var tableView: UITableView! + + var users: [User] = [] + + override func viewDidLoad() { + super.viewDidLoad() + + tableView.delegate = self + tableView.dataSource = self + tableView.register(Cell.self, forCellReuseIdentifier: "Cell") + + let names = "梦琪、 忆柳、 之桃、 慕青、 问兰、 尔岚、 元香、 初夏、 沛菡、 傲珊、曼文、 乐菱、 痴珊、 恨玉、 惜文、 香寒、 新柔、 语蓉".components(separatedBy: "、 ") + let briefs = ["本人性格内外结合,适应能力强,为人诚实,有良好的人际交往能力,具备相关的专业知识和认真。细心、耐心的工作态度及良好的职业道德修养。相信团体精...", + "我的理念是:在年轻的季节我甘愿吃苦受累,只愿通过自己富有激情、积极主动的努力实现自身价值并在工作中做出的贡献:作为初学者,我具备出色的学习能...", + "如果有幸能进入贵公司,我会保持“一荣俱荣,永争第一”的企业精神,全身心的工作,为企业创造利益,希望领导考虑我,谢谢!", + "自我介绍文案精选我是一名应届师范毕业生,在校是一名优秀学生,我是一个乐观向上拥有梦想的青年,性格活泼开朗,稳重成熟的外表下,充溢着内心的细心..."] + + var randomGenerator = SystemRandomNumberGenerator() + for _ in (0 ... 9) { + let name = names.randomElement(using: &randomGenerator) ?? "????" + let brief = briefs.randomElement(using: &randomGenerator) ?? "----" + users.append(User(name: name, brief: brief)) + } + } +} + +extension TableTestController: UITableViewDelegate, UITableViewDataSource { + + func numberOfSections(in tableView: UITableView) -> Int { + 1 + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + users.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as? Cell else { + fatalError() + } + let user = users[indexPath.row] + cell.bind(user: user) + return cell + } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + 220 + } +} + +final class Cell: UITableViewCell { + + let nameLabel = UILabel() + let briefLabel = UILabel() + let container = VStackView(alignment: .left, distribution: .spacing(8)) + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + + nameLabel.font = .systemFont(ofSize: 18, weight: .medium) + nameLabel.textColor = .darkText + + briefLabel.font = .systemFont(ofSize: 14, weight: .regular) + briefLabel.textColor = .darkGray + briefLabel.numberOfLines = 0 + + container.addContent { + nameLabel.stack.maxWidth(80).sizeToFit(.height) + briefLabel.stack.maxWidth(300).sizeToFit(.height) + } + + contentView.addSubview(container) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func layoutSubviews() { + super.layoutSubviews() + + container.pin.left(16).vCenter().sizeToFit() + } + + func bind(user: User) { + defer { + setNeedsLayout() + layoutIfNeeded() + + print(self.nameLabel.text!, ":", self.contentView.center.y, container.center.y) + } + self.nameLabel.text = user.name + self.briefLabel.text = user.brief + } +} diff --git a/Demo/Demo/ViewController.swift b/Demo/Demo/ViewController.swift new file mode 100644 index 0000000..076ac51 --- /dev/null +++ b/Demo/Demo/ViewController.swift @@ -0,0 +1,219 @@ +// +// ViewController.swift +// TestStackKit +// +// Created by i on 2022/8/3. +// + +import UIKit +import StackKit +import PinLayout + +/// Designed for `iPhone 12` +class ViewController: UIViewController { + + let content = HStackView { + Spacer(length: 12) + + UIImageView().stack.size(80).then { + $0.backgroundColor = .red + $0.layer.cornerRadius = 8 + $0.clipsToBounds = true + } + + // Support Spacer (Inspired by SwiftUI) + Spacer() + + VStackView { + UILabel().stack.then { label in + label.font = .systemFont(ofSize: 14, weight: .semibold) + label.textColor = .systemGreen + label.text = "H/VStack in UIKit" + } + Spacer(length: 4) + Divider(color: UIColor.blue) + Spacer(length: 12) + UILabel().stack.then { label in + label.font = .systemFont(ofSize: 12, weight: .regular) + label.textColor = .gray + label.text = "May be the best ~" + } + } + + Spacer() + + VStackView { + + // view.stack.then (Inspired by Then [ https://github.com/devxoul/Then ]) + UILabel().stack.then { label in + label.text = "StackKit" + label.font = UIFont.systemFont(ofSize: 18, weight: .semibold) + label.textColor = .red + } + + Spacer(length: 6) + // Support Divider (Inspired by SwiftUI) + Divider(color: UIColor.orange) + + Spacer(length: 6) + + UILabel().stack.then { label in + label.text = "Version: 1" + label.font = UIFont.systemFont(ofSize: 14, weight: .medium) + label.textColor = .gray + } + } + + Spacer(length: 12) + } + + let vContent = VStackView(alignment: .left, distribution: .spacing(14)) { + Spacer(length: 12) + + HStackView(alignment: .top) { + Spacer(length: 12) + + VStackView { + Spacer(length: 6) + UIView().stack.size(6).then { + $0.backgroundColor = .systemBlue + $0.layer.cornerRadius = 3 + $0.clipsToBounds = true + } + } + + Spacer(length: 4) + UILabel().stack.then { + $0.textColor = .darkText + $0.numberOfLines = 0 + $0.text = "Simple grammar\n简单的语法\n一看就懂 一用就会,与 SwiftUI 保持一致" + $0.font = .systemFont(ofSize: 16, weight: .semibold) + } + } + + HStackView(alignment: .top, distribution: .spacing(14)) { + Spacer(length: 12) + + VStackView { + Spacer(length: 6) + UIView().stack.size(6).then { + $0.backgroundColor = .systemBlue + $0.layer.cornerRadius = 3 + $0.clipsToBounds = true + } + } + + Spacer(length: 4) + UILabel().stack.then { + $0.textColor = .darkText + $0.font = .systemFont(ofSize: 16, weight: .semibold) + $0.numberOfLines = 0 + $0.text = "Support `Spacer` and `Divider`\n支持 Spacer 与 Divider,与 SwiftUI 保持一致" + } + } + + HStackView(alignment: .top, distribution: .spacing(14)) { + Spacer(length: 12) + + VStackView { + Spacer(length: 6) + UIView().stack.size(6).then { + $0.backgroundColor = .systemBlue + $0.layer.cornerRadius = 3 + $0.clipsToBounds = true + } + } + + Spacer(length: 4) + UILabel().stack.then { + $0.textColor = .darkText + $0.font = .systemFont(ofSize: 16, weight: .semibold) + $0.numberOfLines = 0 + $0.text = "Support AutoLayout\n支持 Auto layout" + } + } + + HStackView(alignment: .top, distribution: .spacing(14)) { + Spacer(length: 12) + + VStackView { + Spacer(length: 6) + UIView().stack.size(6).then { + $0.backgroundColor = .systemBlue + $0.layer.cornerRadius = 3 + $0.clipsToBounds = true + } + } + + Spacer(length: 4) + UILabel().stack.then { + $0.textColor = .darkText + $0.font = .systemFont(ofSize: 16, weight: .semibold) + $0.numberOfLines = 0 + $0.text = "⚠️ In development: Relative layout\n相对布局暂不支持,正在开发中" + } + } + + Spacer(length: 12) + } + + let descriptionContent = VStackView { + Spacer(length: 12) + HStackView { + Spacer(length: 12) + + VStackView(alignment: .left, distribution: .spacing(24)) { + UILabel().stack.then { + $0.font = .systemFont(ofSize: 20, weight: .semibold) + $0.text = "⚠️ Important" + } + UILabel().stack.maxWidth(UIScreen.main.bounds.width - 48).then { + $0.textColor = .systemPink + $0.font = .systemFont(ofSize: 14, weight: .medium) + $0.numberOfLines = 0 + $0.text = "`Spacer` will ignore the given spacing in H/VStack\nSpacer 会忽略在 H/VStack 中给定的 spacing, 也就是说可以使用 Spacer 自由调整 spacing" + } + + UILabel().stack.then { + $0.textColor = .systemPink + $0.font = .systemFont(ofSize: 14, weight: .medium) + $0.numberOfLines = 0 + $0.text = "Do not support relative layout for the time being\n暂不支持相对布局(正在开发中)" + } + + // specify `.maxWidth` + UILabel().stack.maxWidth(UIScreen.main.bounds.width - 48).then { + $0.textColor = .systemPink + $0.font = .systemFont(ofSize: 14, weight: .medium) + $0.numberOfLines = 0 + $0.text = "The subview may exceed the width/height of the parent view, and you need to specify the maximum width/height manually, add .maxWidth/.maxHeight after `.stack`\n子视图可能超过父视图的宽高,此时需要你手动设定最大宽度或最大高度" + } + } + } + Spacer(length: 12) + } + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = .systemGray5 + + vContent.backgroundColor = .white + vContent.layer.cornerRadius = 6 + + descriptionContent.backgroundColor = .white + descriptionContent.layer.cornerRadius = 6 + + view.addSubview(content) + view.addSubview(vContent) + view.addSubview(descriptionContent) + } + + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + + content.pin.top(120).horizontally().sizeToFit(.width) + vContent.pin.below(of: content).horizontally(12).marginTop(20).sizeToFit(.width) + descriptionContent.pin.below(of: vContent).horizontally(12).marginTop(20).sizeToFit(.width) + } +} diff --git a/Demo/preview.png b/Demo/preview.png new file mode 100644 index 0000000..e268415 Binary files /dev/null and b/Demo/preview.png differ diff --git a/README.md b/README.md index f46fcf8..4a6861e 100644 --- a/README.md +++ b/README.md @@ -6,57 +6,232 @@ --- +# Demo -先看个例子: +#### Preview +![Demo](Demo/preview.png) -// SwiftUI -```swift -HStack(alignment: .leading) { - Image(named: "") - Spacer() - VStack { - Text("SwiftUI") - Divider() - Text("Version: 3") - } -} -``` +#### Demo Codes +``` +import UIKit +import StackKit -// StackKit -```swift -HStackView(alignment: .left, distribution: .spacing(14)) { - UIImageView(image: UIImage(named: "")) - - Spacer() // 支持 Spacer, 可指定 length 或 min/max +// 演示代码使用的 PinLayout 而非 SnapKit +// StackKit 内部使用 `view.sizeToFit()` 计算大小, 也是支持 `SnapKit` (AutoLayout) +import PinLayout - VStackView { - // 便捷初始化 需要通过 extension UILabel 自己添加 - UILabel(text: "StackKit", font: .semibold(18), color: .red).stack.maxWidth(120).sizeToFit(.height) - Divider() // 支持 Divider - UILabel(text: "Version: 1", font: .medium(14), color: .gray).stack.maxWidth(80).sizeToFit(.height) +class ViewController: UIViewController { + + let content = HStackView { + Spacer(length: 12) + + UIImageView().stack.size(80).then { + $0.backgroundColor = .red + $0.layer.cornerRadius = 8 + $0.clipsToBounds = true + } + + // Support Spacer (Inspired by SwiftUI) + Spacer() + + VStackView { + UILabel().stack.then { label in + label.font = .systemFont(ofSize: 14, weight: .semibold) + label.textColor = .systemGreen + label.text = "H/VStack in UIKit" + } + Spacer(length: 4) + Divider(color: UIColor.blue) + Spacer(length: 12) + UILabel().stack.then { label in + label.font = .systemFont(ofSize: 12, weight: .regular) + label.textColor = .gray + label.text = "May be the best ~" + } + } + + Spacer() + + VStackView { + + // view.stack.then (Inspired by Then [ https://github.com/devxoul/Then ]) + UILabel().stack.then { label in + label.text = "StackKit" + label.font = UIFont.systemFont(ofSize: 18, weight: .semibold) + label.textColor = .red + } + + Spacer(length: 6) + // Support Divider (Inspired by SwiftUI) + Divider(color: UIColor.orange) + + Spacer(length: 6) + + UILabel().stack.then { label in + label.text = "Version: 1" + label.font = UIFont.systemFont(ofSize: 14, weight: .medium) + label.textColor = .gray + } + } + + Spacer(length: 12) + } + + let vContent = VStackView(alignment: .left, distribution: .spacing(14)) { + Spacer(length: 12) + + HStackView(alignment: .top) { + Spacer(length: 12) + + VStackView { + Spacer(length: 6) + UIView().stack.size(6).then { + $0.backgroundColor = .systemBlue + $0.layer.cornerRadius = 3 + $0.clipsToBounds = true + } + } + + Spacer(length: 4) + UILabel().stack.then { + $0.textColor = .darkText + $0.numberOfLines = 0 + $0.text = "Simple grammar\n简单的语法\n一看就懂 一用就会,与 SwiftUI 保持一致" + $0.font = .systemFont(ofSize: 16, weight: .semibold) + } + } + + HStackView(alignment: .top, distribution: .spacing(14)) { + Spacer(length: 12) + + VStackView { + Spacer(length: 6) + UIView().stack.size(6).then { + $0.backgroundColor = .systemBlue + $0.layer.cornerRadius = 3 + $0.clipsToBounds = true + } + } + + Spacer(length: 4) + UILabel().stack.then { + $0.textColor = .darkText + $0.font = .systemFont(ofSize: 16, weight: .semibold) + $0.numberOfLines = 0 + $0.text = "Support `Spacer` and `Divider`\n支持 Spacer 与 Divider,与 SwiftUI 保持一致" + } + } + + HStackView(alignment: .top, distribution: .spacing(14)) { + Spacer(length: 12) + + VStackView { + Spacer(length: 6) + UIView().stack.size(6).then { + $0.backgroundColor = .systemBlue + $0.layer.cornerRadius = 3 + $0.clipsToBounds = true + } + } + + Spacer(length: 4) + UILabel().stack.then { + $0.textColor = .darkText + $0.font = .systemFont(ofSize: 16, weight: .semibold) + $0.numberOfLines = 0 + $0.text = "Support AutoLayout\n支持 Auto layout" + } + } + + HStackView(alignment: .top, distribution: .spacing(14)) { + Spacer(length: 12) + + VStackView { + Spacer(length: 6) + UIView().stack.size(6).then { + $0.backgroundColor = .systemBlue + $0.layer.cornerRadius = 3 + $0.clipsToBounds = true + } + } + + Spacer(length: 4) + UILabel().stack.then { + $0.textColor = .darkText + $0.font = .systemFont(ofSize: 16, weight: .semibold) + $0.numberOfLines = 0 + $0.text = "⚠️ In development: Relative layout\n相对布局暂不支持,正在开发中" + } + } + + Spacer(length: 12) } + let descriptionContent = VStackView { + Spacer(length: 12) + HStackView { + Spacer(length: 12) + + VStackView(alignment: .left, distribution: .spacing(24)) { + UILabel().stack.then { + $0.font = .systemFont(ofSize: 20, weight: .semibold) + $0.text = "⚠️ Important" + } + UILabel().stack.maxWidth(UIScreen.main.bounds.width - 48).then { + $0.textColor = .systemPink + $0.font = .systemFont(ofSize: 14, weight: .medium) + $0.numberOfLines = 0 + $0.text = "`Spacer` will ignore the given spacing in H/VStack\nSpacer 会忽略在 H/VStack 中给定的 spacing, 也就是说可以使用 Spacer 自由调整 spacing" + } + + UILabel().stack.then { + $0.textColor = .systemPink + $0.font = .systemFont(ofSize: 14, weight: .medium) + $0.numberOfLines = 0 + $0.text = "Do not support relative layout for the time being\n暂不支持相对布局(正在开发中)" + } + + // specify `.maxWidth` + UILabel().stack.maxWidth(UIScreen.main.bounds.width - 48).then { + $0.textColor = .systemPink + $0.font = .systemFont(ofSize: 14, weight: .medium) + $0.numberOfLines = 0 + $0.text = "The subview may exceed the width/height of the parent view, and you need to specify the maximum width/height manually, add .maxWidth/.maxHeight after `.stack`\n子视图可能超过父视图的宽高,此时需要你手动设定最大宽度或最大高度" + } + } + } + Spacer(length: 12) + } + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = .systemGray5 + + vContent.backgroundColor = .white + vContent.layer.cornerRadius = 6 + + descriptionContent.backgroundColor = .white + descriptionContent.layer.cornerRadius = 6 + + view.addSubview(content) + view.addSubview(vContent) + view.addSubview(descriptionContent) + } + + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + + content.pin.top(120).horizontally().sizeToFit(.width) + vContent.pin.below(of: content).horizontally(12).marginTop(20).sizeToFit(.width) + descriptionContent.pin.below(of: vContent).horizontally(12).marginTop(20).sizeToFit(.width) + } } - - -// 视图看起来是这样的 -// 😂 懒得写 demo 了,将就看一下就行 ------------------------------------------------ -| |-------| | -| | | | -| | | StackKit | -| | Image | ...Spacer...... ---------- | -| | | Version: 1 | -| | | | -| |-------| | ------------------------------------------------ ``` -`VStackView` / `HStackView` 可以互相嵌套,尾随闭包使用 `@resultBuilder` 与 `SwiftUI` 保持一致。 - ##### 一些特殊说明 -`isHidden || alpha <= 0 || (frame.size == .zero && clipsToBounds == true)` 这样的 UIView 不会被显示也不会占用位置。(在 CALayer 中基本一致) +`isHidden || alpha <= 0 || (frame.size == .zero && clipsToBounds == true)` 这样的 UIView 不会被显示也不会占用位置。(在 CALayer 中一致) # 类说明 diff --git a/Sources/StackKit/Divider.swift b/Sources/StackKit/Divider.swift index b1489a7..65e6c13 100644 --- a/Sources/StackKit/Divider.swift +++ b/Sources/StackKit/Divider.swift @@ -28,12 +28,12 @@ public struct Divider: _Divider { public init( thickness: CGFloat = 1, maxLength: CGFloat = CGFloat.greatestFiniteMagnitude, - backgroundColor: UIColor = .gray, + color: UIColor = .gray, cornerRadius: CGFloat = 0 ) { self.thickness = thickness self.maxLength = maxLength - self.color = backgroundColor + self.color = color self.cornerRadius = cornerRadius } } diff --git a/Sources/StackKit/HStackLayer.swift b/Sources/StackKit/HStackLayer.swift index 427bc91..2657983 100644 --- a/Sources/StackKit/HStackLayer.swift +++ b/Sources/StackKit/HStackLayer.swift @@ -82,12 +82,14 @@ open class HStackLayer: CALayer { switch distribution { case .spacing(let spacing): fillDivider() + fillSpecifySpacer() fillSpacer() makeSpacing(spacing) case .autoSpacing: fillDivider() + fillSpecifySpacer() fillSpacer() let spacing = autoSpacing() @@ -95,6 +97,7 @@ open class HStackLayer: CALayer { case .fillHeight: // autoSpacing and fill height fillDivider() + fillSpecifySpacer() fillSpacer() let spacing = autoSpacing() @@ -135,6 +138,9 @@ extension HStackLayer { private func spacerLayers() -> [SpacerLayer] { effectiveSublayers.compactMap({ $0 as? SpacerLayer }) } + private func dynamicSpacerLayers() -> [SpacerLayer] { + effectiveSublayers.compactMap({ $0 as? SpacerLayer }).filter({ $0.length == .greatestFiniteMagnitude }) + } private func dividerLayers() -> [DividerLayer] { effectiveSublayers.compactMap({ $0 as? DividerLayer }) } @@ -152,7 +158,8 @@ extension HStackLayer { private func autoSpacing() -> CGFloat { let unspacerViews = viewsWithoutSpacer() let spacersCount = spacerLayers().map({ isSpacerBetweenViews($0) }).filter({ $0 }).count - return (frame.width - viewsWidth() - spacerSpecifyLength()) / CGFloat(unspacerViews.count - spacersCount - 1) + let number = unspacerViews.count - spacersCount - 1 + return (frame.width - viewsWidth() - spacerSpecifyLength()) / CGFloat(max(1, number)) } private func viewsWidth() -> CGFloat { @@ -286,8 +293,8 @@ extension HStackLayer { // 非 spacerView 的所有宽度 let unspacerViewsMaxWidth = unspacerViewsWidth + unspacerViewsSpacing - let spacersWidth = (frame.width - unspacerViewsMaxWidth) - let spacerWidth = spacersWidth / CGFloat(self.spacerLayers().count) + let spacersWidth = (frame.width - unspacerViewsMaxWidth - self.spacerSpecifyLength()) + let spacerWidth = spacersWidth / CGFloat(self.dynamicSpacerLayers().count) let spacerViews = self.spacerLayers() for spacer in spacerViews { diff --git a/Sources/StackKit/HStackView.swift b/Sources/StackKit/HStackView.swift index cd65158..fd3d3ca 100644 --- a/Sources/StackKit/HStackView.swift +++ b/Sources/StackKit/HStackView.swift @@ -101,12 +101,14 @@ open class HStackView: UIView { switch distribution { case .spacing(let spacing): fillDivider() + fillSpecifySpacer() fillSpacer() makeSpacing(spacing) case .autoSpacing: fillDivider() + fillSpecifySpacer() fillSpacer() let spacing = autoSpacing() @@ -114,6 +116,7 @@ open class HStackView: UIView { case .fillHeight: fillDivider() + fillSpecifySpacer() fillSpacer() let spacing = autoSpacing() @@ -151,6 +154,9 @@ extension HStackView { private func spacerViews() -> [SpacerView] { effectiveSubviews.compactMap({ $0 as? SpacerView }) } + private func dynamicSpacerViews() -> [SpacerView] { + effectiveSubviews.compactMap({ $0 as? SpacerView }).filter({ $0.length == .greatestFiniteMagnitude }) + } private func dividerViews() -> [DividerView] { effectiveSubviews.compactMap({ $0 as? DividerView }) } @@ -177,10 +183,7 @@ extension HStackView { let unspacerViews = viewsWithoutSpacer() let spacersCount = spacerViews().map({ isSpacerBetweenViews($0) }).filter({ $0 }).count let number = unspacerViews.count - spacersCount - 1 - if number <= 0 { - return 0 - } - return (frame.width - viewsWidth() - spacerSpecifyLength()) / CGFloat(number) + return (frame.width - viewsWidth() - spacerSpecifyLength()) / CGFloat(max(1, number)) } private func viewsWidth() -> CGFloat { @@ -308,8 +311,8 @@ extension HStackView { // 非 spacerView 的所有宽度 let unspacerViewsMaxWidth = unspacerViewsWidth + unspacerViewsSpacing - let spacersWidth = (frame.width - unspacerViewsMaxWidth) - let spacerWidth = spacersWidth / CGFloat(self.spacerViews().count) + let spacersWidth = (frame.width - unspacerViewsMaxWidth - self.spacerSpecifyLength()) + let spacerWidth = spacersWidth / CGFloat(self.dynamicSpacerViews().count) let spacerViews = self.spacerViews() for spacer in spacerViews { diff --git a/Sources/StackKit/VStackLayer.swift b/Sources/StackKit/VStackLayer.swift index 45b75c8..deb00f1 100644 --- a/Sources/StackKit/VStackLayer.swift +++ b/Sources/StackKit/VStackLayer.swift @@ -88,12 +88,14 @@ open class VStackLayer: CALayer { switch distribution { case .spacing(let spacing): fillDivider() + fillSpecifySpacer() fillSpacer() makeSpacing(spacing) case .autoSpacing: fillDivider() + fillSpecifySpacer() fillSpacer() let spacing = autoSpacing() @@ -101,6 +103,7 @@ open class VStackLayer: CALayer { case .fillWidth: fillDivider() + fillSpecifySpacer() fillSpacer() let spacing = autoSpacing() @@ -141,6 +144,9 @@ extension VStackLayer { private func spacerLayers() -> [SpacerLayer] { effectiveSublayers.compactMap({ $0 as? SpacerLayer }) } + private func dynamicSpacerLayers() -> [SpacerLayer] { + effectiveSublayers.compactMap({ $0 as? SpacerLayer }).filter({ $0.length == .greatestFiniteMagnitude }) + } private func dividerLayers() -> [DividerLayer] { effectiveSublayers.compactMap({ $0 as? DividerLayer }) } @@ -158,7 +164,8 @@ extension VStackLayer { private func autoSpacing() -> CGFloat { let unspacerViews = viewsWithoutSpacer() let spacersCount = spacerLayers().map({ isSpacerBetweenViews($0) }).filter({ $0 }).count - return (frame.height - viewsHeight() - spacerSpecifyLength()) / CGFloat(unspacerViews.count - spacersCount - 1) + let number = unspacerViews.count - spacersCount - 1 + return (frame.height - viewsHeight() - spacerSpecifyLength()) / CGFloat(max(1, number)) } private func viewsHeight() -> CGFloat { @@ -288,8 +295,8 @@ extension VStackLayer { } let unspacerViewsMaxHeight = unspacerViewsHeight + unspacerViewsSpacing - let spacersHeight = (frame.height - unspacerViewsMaxHeight) - let spacerWidth = spacersHeight / CGFloat(self.spacerLayers().count) + let spacersHeight = (frame.height - unspacerViewsMaxHeight - self.spacerSpecifyLength()) + let spacerWidth = spacersHeight / CGFloat(self.dynamicSpacerLayers().count) let spacerViews = self.spacerLayers() for spacer in spacerViews { diff --git a/Sources/StackKit/VStackView.swift b/Sources/StackKit/VStackView.swift index c15db1e..9013799 100644 --- a/Sources/StackKit/VStackView.swift +++ b/Sources/StackKit/VStackView.swift @@ -101,12 +101,14 @@ open class VStackView: UIView { switch distribution { case .spacing(let spacing): fillDivider() + fillSpecifySpacer() fillSpacer() makeSpacing(spacing) case .autoSpacing: fillDivider() + fillSpecifySpacer() fillSpacer() let spacing = autoSpacing() @@ -114,6 +116,7 @@ open class VStackView: UIView { case .fillWidth: fillDivider() + fillSpecifySpacer() fillSpacer() let spacing = autoSpacing() @@ -151,6 +154,9 @@ extension VStackView { private func spacerViews() -> [SpacerView] { effectiveSubviews.compactMap({ $0 as? SpacerView }) } + private func dynamicSpacerViews() -> [SpacerView] { + effectiveSubviews.compactMap({ $0 as? SpacerView }).filter({ $0.length == .greatestFiniteMagnitude }) + } private func dividerViews() -> [DividerView] { effectiveSubviews.compactMap({ $0 as? DividerView }) } @@ -177,10 +183,7 @@ extension VStackView { let unspacerViews = viewsWithoutSpacer() let spacersCount = spacerViews().map({ isSpacerBetweenViews($0) }).filter({ $0 }).count let number = unspacerViews.count - spacersCount - 1 - if number <= 0 { - return 0 - } - return (frame.height - viewsHeight() - spacerSpecifyLength()) / CGFloat( number) + return (frame.height - viewsHeight() - spacerSpecifyLength()) / CGFloat(max(1, number)) } private func viewsHeight() -> CGFloat { @@ -308,8 +311,8 @@ extension VStackView { // 非 spacerView 的所有宽度 let unspacerViewsMaxHeight = unspacerViewsHeight + unspacerViewsSpacing - let spacersHeight = (frame.height - unspacerViewsMaxHeight) - let spacerHeight = spacersHeight / CGFloat(self.spacerViews().count) + let spacersHeight = (frame.height - unspacerViewsMaxHeight - self.spacerSpecifyLength()) + let spacerHeight = spacersHeight / CGFloat(self.dynamicSpacerViews().count) let spacerViews = self.spacerViews() for spacer in spacerViews {