From 03999cb55518feef695f15ec86e661953e0405c4 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Fri, 28 Jul 2023 00:55:16 +0300 Subject: [PATCH] Initial commit --- .gitignore | 9 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + Package.swift | 16 + README.md | 3 + Sources/YadUI/Extensions/UIEdgeInsets.swift | 20 + Sources/YadUI/Extensions/UIView.swift | 40 ++ Sources/YadUI/Views/VStack.swift | 115 +++++ Sources/YadUI/YadUI.swift | 18 + YadUIDemo/YadUIDemo.xcodeproj/project.pbxproj | 395 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + YadUIDemo/YadUIDemo/AppDelegate.swift | 36 ++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 13 + .../YadUIDemo/Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../YadUIDemo/Base.lproj/Main.storyboard | 24 ++ YadUIDemo/YadUIDemo/Info.plist | 25 ++ YadUIDemo/YadUIDemo/SceneDelegate.swift | 52 +++ YadUIDemo/YadUIDemo/ViewController.swift | 35 ++ 20 files changed, 866 insertions(+) create mode 100644 .gitignore create mode 100644 .swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Package.swift create mode 100644 README.md create mode 100644 Sources/YadUI/Extensions/UIEdgeInsets.swift create mode 100644 Sources/YadUI/Extensions/UIView.swift create mode 100644 Sources/YadUI/Views/VStack.swift create mode 100644 Sources/YadUI/YadUI.swift create mode 100644 YadUIDemo/YadUIDemo.xcodeproj/project.pbxproj create mode 100644 YadUIDemo/YadUIDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 YadUIDemo/YadUIDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 YadUIDemo/YadUIDemo/AppDelegate.swift create mode 100644 YadUIDemo/YadUIDemo/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 YadUIDemo/YadUIDemo/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 YadUIDemo/YadUIDemo/Assets.xcassets/Contents.json create mode 100644 YadUIDemo/YadUIDemo/Base.lproj/LaunchScreen.storyboard create mode 100644 YadUIDemo/YadUIDemo/Base.lproj/Main.storyboard create mode 100644 YadUIDemo/YadUIDemo/Info.plist create mode 100644 YadUIDemo/YadUIDemo/SceneDelegate.swift create mode 100644 YadUIDemo/YadUIDemo/ViewController.swift diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..3bc8a33 --- /dev/null +++ b/Package.swift @@ -0,0 +1,16 @@ +// swift-tools-version: 5.8 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "YadUI", + products: [ + .library(name: "YadUI", targets: ["YadUI"]), + ], + dependencies: [ + ], + targets: [ + .target(name: "YadUI", dependencies: []) + ] +) diff --git a/README.md b/README.md new file mode 100644 index 0000000..78716d9 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# YadUI + +Yet another declarative UI diff --git a/Sources/YadUI/Extensions/UIEdgeInsets.swift b/Sources/YadUI/Extensions/UIEdgeInsets.swift new file mode 100644 index 0000000..a30619a --- /dev/null +++ b/Sources/YadUI/Extensions/UIEdgeInsets.swift @@ -0,0 +1,20 @@ +// +// UIEdgeInsets.swift +// +// +// Created by Мустафаев Селим Мустафаевич on 27.07.2023. +// + +import UIKit + +extension UIEdgeInsets { + + public init(all: CGFloat) { + self.init(top: all, left: all, bottom: all, right: all) + } + + public init(vertical: CGFloat = 0, horizontal: CGFloat = 0) { + self.init(top: vertical, left: horizontal, bottom: vertical, right: horizontal) + } + +} diff --git a/Sources/YadUI/Extensions/UIView.swift b/Sources/YadUI/Extensions/UIView.swift new file mode 100644 index 0000000..3eabf7f --- /dev/null +++ b/Sources/YadUI/Extensions/UIView.swift @@ -0,0 +1,40 @@ +// +// UIView.swift +// +// +// Created by Мустафаев Селим Мустафаевич on 27.07.2023. +// + +import UIKit + +extension UIView { + + public func withoutAutoresizing() -> Self { + translatesAutoresizingMaskIntoConstraints = false + return self + } + + public func pin(to view: UIView, insets: UIEdgeInsets = .zero) { + NSLayoutConstraint.activate([ + leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: insets.left), + trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -insets.right), + topAnchor.constraint(equalTo: view.topAnchor, constant: insets.top), + bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -insets.bottom) + ]) + } + + public func width(_ width: CGFloat) -> Self { + widthAnchor.constraint(equalToConstant: width).isActive = true + return self + } + + public func height(_ height: CGFloat) -> Self { + heightAnchor.constraint(equalToConstant: height).isActive = true + return self + } + + public func background(_ color: UIColor) -> Self { + backgroundColor = color + return self + } +} diff --git a/Sources/YadUI/Views/VStack.swift b/Sources/YadUI/Views/VStack.swift new file mode 100644 index 0000000..c18e89d --- /dev/null +++ b/Sources/YadUI/Views/VStack.swift @@ -0,0 +1,115 @@ +// +// VStack.swift +// +// +// Created by Мустафаев Селим Мустафаевич on 27.07.2023. +// + +import UIKit + +public enum StackAlignment { + + case fill +} + +public enum StackDistribution { + + case fill +} + +public enum StackAxis { + + case horizontal + case vertical +} + +public final class VStack: UIView { + + private var arrangedSubviews: [UIView] + private var alignment: StackAlignment + private var distribution: StackDistribution + private var axis: StackAxis + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + public init(axis: StackAxis = .vertical, + alignment: StackAlignment = .fill, + distribution: StackDistribution = .fill, + @StackViewBuilder _ content: () -> [UIView]) { + + self.axis = axis + self.alignment = alignment + self.distribution = distribution + self.arrangedSubviews = content() + super.init(frame: .zero) + + self.arrangedSubviews.forEach(addSubview) + NSLayoutConstraint.activate(generateAlignmentConstraints()) + NSLayoutConstraint.activate(generateDistributionConstraints()) + } + + func generateAlignmentConstraints() -> [NSLayoutConstraint] { + + switch alignment { + case .fill: + return generateAlignmentFillConstraints() + } + } + + func generateDistributionConstraints() -> [NSLayoutConstraint] { + + switch distribution { + case .fill: + return generateDistributionFillConstraints() + } + } + + func generateAlignmentFillConstraints() -> [NSLayoutConstraint] { + guard let firstView = arrangedSubviews.first else { + return [] + } + + let otherViews = arrangedSubviews.dropFirst() + + var constraints: [NSLayoutConstraint] = [ + firstView.leadingAnchor.constraint(equalTo: leadingAnchor), + firstView.trailingAnchor.constraint(equalTo: trailingAnchor) + ] + + for view in otherViews { + constraints.append(contentsOf: [ + view.leadingAnchor.constraint(equalTo: firstView.leadingAnchor), + view.trailingAnchor.constraint(equalTo: firstView.trailingAnchor) + ]) + } + + return constraints + } + + func generateDistributionFillConstraints() -> [NSLayoutConstraint] { + guard let firstView = arrangedSubviews.first, + let lastView = arrangedSubviews.last + else { + return [] + } + + let middleViews = arrangedSubviews.dropFirst().dropLast() + + var constraints: [NSLayoutConstraint] = [ + firstView.topAnchor.constraint(equalTo: topAnchor), + lastView.bottomAnchor.constraint(equalTo: bottomAnchor) + ] + + var currentView = firstView + for view in middleViews { + constraints.append(view.topAnchor.constraint(equalTo: currentView.bottomAnchor)) + currentView = view + } + + constraints.append(lastView.topAnchor.constraint(equalTo: currentView.bottomAnchor)) + + return constraints + } +} diff --git a/Sources/YadUI/YadUI.swift b/Sources/YadUI/YadUI.swift new file mode 100644 index 0000000..6c2b843 --- /dev/null +++ b/Sources/YadUI/YadUI.swift @@ -0,0 +1,18 @@ +import UIKit + +@resultBuilder +public struct RootViewBuilder { + + public static func buildBlock(_ components: UIView...) -> UIView { + let view = components.first ?? UIView() + return view.withoutAutoresizing() + } +} + +@resultBuilder +public struct StackViewBuilder { + + public static func buildBlock(_ components: UIView...) -> [UIView] { + components.map { $0.withoutAutoresizing() } + } +} diff --git a/YadUIDemo/YadUIDemo.xcodeproj/project.pbxproj b/YadUIDemo/YadUIDemo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c745e9f --- /dev/null +++ b/YadUIDemo/YadUIDemo.xcodeproj/project.pbxproj @@ -0,0 +1,395 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 63D50C192A72425E009E853A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D50C182A72425E009E853A /* AppDelegate.swift */; }; + 63D50C1B2A72425E009E853A /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D50C1A2A72425E009E853A /* SceneDelegate.swift */; }; + 63D50C1D2A72425E009E853A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D50C1C2A72425E009E853A /* ViewController.swift */; }; + 63D50C202A72425E009E853A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 63D50C1E2A72425E009E853A /* Main.storyboard */; }; + 63D50C222A72425F009E853A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 63D50C212A72425F009E853A /* Assets.xcassets */; }; + 63D50C252A72425F009E853A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 63D50C232A72425F009E853A /* LaunchScreen.storyboard */; }; + 63D50C302A7242F3009E853A /* YadUI in Frameworks */ = {isa = PBXBuildFile; productRef = 63D50C2F2A7242F3009E853A /* YadUI */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 63D50C152A72425E009E853A /* YadUIDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YadUIDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 63D50C182A72425E009E853A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 63D50C1A2A72425E009E853A /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 63D50C1C2A72425E009E853A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 63D50C1F2A72425E009E853A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 63D50C212A72425F009E853A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 63D50C242A72425F009E853A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 63D50C262A72425F009E853A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 63D50C2D2A7242DA009E853A /* YadUI */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = YadUI; path = ..; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 63D50C122A72425D009E853A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 63D50C302A7242F3009E853A /* YadUI in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 63D50C0C2A72425D009E853A = { + isa = PBXGroup; + children = ( + 63D50C2C2A7242DA009E853A /* Packages */, + 63D50C172A72425E009E853A /* YadUIDemo */, + 63D50C162A72425E009E853A /* Products */, + 63D50C2E2A7242F3009E853A /* Frameworks */, + ); + sourceTree = ""; + }; + 63D50C162A72425E009E853A /* Products */ = { + isa = PBXGroup; + children = ( + 63D50C152A72425E009E853A /* YadUIDemo.app */, + ); + name = Products; + sourceTree = ""; + }; + 63D50C172A72425E009E853A /* YadUIDemo */ = { + isa = PBXGroup; + children = ( + 63D50C182A72425E009E853A /* AppDelegate.swift */, + 63D50C1A2A72425E009E853A /* SceneDelegate.swift */, + 63D50C1C2A72425E009E853A /* ViewController.swift */, + 63D50C1E2A72425E009E853A /* Main.storyboard */, + 63D50C212A72425F009E853A /* Assets.xcassets */, + 63D50C232A72425F009E853A /* LaunchScreen.storyboard */, + 63D50C262A72425F009E853A /* Info.plist */, + ); + path = YadUIDemo; + sourceTree = ""; + }; + 63D50C2C2A7242DA009E853A /* Packages */ = { + isa = PBXGroup; + children = ( + 63D50C2D2A7242DA009E853A /* YadUI */, + ); + name = Packages; + sourceTree = ""; + }; + 63D50C2E2A7242F3009E853A /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 63D50C142A72425D009E853A /* YadUIDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 63D50C292A72425F009E853A /* Build configuration list for PBXNativeTarget "YadUIDemo" */; + buildPhases = ( + 63D50C112A72425D009E853A /* Sources */, + 63D50C122A72425D009E853A /* Frameworks */, + 63D50C132A72425D009E853A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = YadUIDemo; + packageProductDependencies = ( + 63D50C2F2A7242F3009E853A /* YadUI */, + ); + productName = YadUIDemo; + productReference = 63D50C152A72425E009E853A /* YadUIDemo.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 63D50C0D2A72425D009E853A /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1430; + LastUpgradeCheck = 1430; + TargetAttributes = { + 63D50C142A72425D009E853A = { + CreatedOnToolsVersion = 14.3.1; + }; + }; + }; + buildConfigurationList = 63D50C102A72425D009E853A /* Build configuration list for PBXProject "YadUIDemo" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 63D50C0C2A72425D009E853A; + productRefGroup = 63D50C162A72425E009E853A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 63D50C142A72425D009E853A /* YadUIDemo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 63D50C132A72425D009E853A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 63D50C252A72425F009E853A /* LaunchScreen.storyboard in Resources */, + 63D50C222A72425F009E853A /* Assets.xcassets in Resources */, + 63D50C202A72425E009E853A /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 63D50C112A72425D009E853A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 63D50C1D2A72425E009E853A /* ViewController.swift in Sources */, + 63D50C192A72425E009E853A /* AppDelegate.swift in Sources */, + 63D50C1B2A72425E009E853A /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 63D50C1E2A72425E009E853A /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 63D50C1F2A72425E009E853A /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 63D50C232A72425F009E853A /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 63D50C242A72425F009E853A /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 63D50C272A72425F009E853A /* 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++20"; + 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 = 16.4; + 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; + }; + 63D50C282A72425F009E853A /* 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++20"; + 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 = 16.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 63D50C2A2A72425F009E853A /* 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 = 46DTTB8X4S; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = YadUIDemo/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"; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = pro.aliencat.YadUIDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 63D50C2B2A72425F009E853A /* 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 = 46DTTB8X4S; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = YadUIDemo/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"; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = pro.aliencat.YadUIDemo; + 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 */ + 63D50C102A72425D009E853A /* Build configuration list for PBXProject "YadUIDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 63D50C272A72425F009E853A /* Debug */, + 63D50C282A72425F009E853A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 63D50C292A72425F009E853A /* Build configuration list for PBXNativeTarget "YadUIDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 63D50C2A2A72425F009E853A /* Debug */, + 63D50C2B2A72425F009E853A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + 63D50C2F2A7242F3009E853A /* YadUI */ = { + isa = XCSwiftPackageProductDependency; + productName = YadUI; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 63D50C0D2A72425D009E853A /* Project object */; +} diff --git a/YadUIDemo/YadUIDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/YadUIDemo/YadUIDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/YadUIDemo/YadUIDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/YadUIDemo/YadUIDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/YadUIDemo/YadUIDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/YadUIDemo/YadUIDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/YadUIDemo/YadUIDemo/AppDelegate.swift b/YadUIDemo/YadUIDemo/AppDelegate.swift new file mode 100644 index 0000000..1a2ecc1 --- /dev/null +++ b/YadUIDemo/YadUIDemo/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// YadUIDemo +// +// Created by Мустафаев Селим Мустафаевич on 27.07.2023. +// + +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/YadUIDemo/YadUIDemo/Assets.xcassets/AccentColor.colorset/Contents.json b/YadUIDemo/YadUIDemo/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/YadUIDemo/YadUIDemo/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YadUIDemo/YadUIDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/YadUIDemo/YadUIDemo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/YadUIDemo/YadUIDemo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YadUIDemo/YadUIDemo/Assets.xcassets/Contents.json b/YadUIDemo/YadUIDemo/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/YadUIDemo/YadUIDemo/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YadUIDemo/YadUIDemo/Base.lproj/LaunchScreen.storyboard b/YadUIDemo/YadUIDemo/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/YadUIDemo/YadUIDemo/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YadUIDemo/YadUIDemo/Base.lproj/Main.storyboard b/YadUIDemo/YadUIDemo/Base.lproj/Main.storyboard new file mode 100644 index 0000000..25a7638 --- /dev/null +++ b/YadUIDemo/YadUIDemo/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YadUIDemo/YadUIDemo/Info.plist b/YadUIDemo/YadUIDemo/Info.plist new file mode 100644 index 0000000..dd3c9af --- /dev/null +++ b/YadUIDemo/YadUIDemo/Info.plist @@ -0,0 +1,25 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/YadUIDemo/YadUIDemo/SceneDelegate.swift b/YadUIDemo/YadUIDemo/SceneDelegate.swift new file mode 100644 index 0000000..d586a52 --- /dev/null +++ b/YadUIDemo/YadUIDemo/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// YadUIDemo +// +// Created by Мустафаев Селим Мустафаевич on 27.07.2023. +// + +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/YadUIDemo/YadUIDemo/ViewController.swift b/YadUIDemo/YadUIDemo/ViewController.swift new file mode 100644 index 0000000..abf737c --- /dev/null +++ b/YadUIDemo/YadUIDemo/ViewController.swift @@ -0,0 +1,35 @@ +// +// ViewController.swift +// YadUIDemo +// +// Created by Мустафаев Селим Мустафаевич on 27.07.2023. +// + +import UIKit +import YadUI + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + let child = buildView() + view.addSubview(child) + child.pin(to: view) + } + + @RootViewBuilder func buildView() -> UIView { + VStack { + UIView() + .background(.red) + .height(100) + UIView() + .background(.green) + .height(100) + UIView() + .background(.blue) + //.height(100) + } + } +} +