### FrameLayoutKit CocoaPods Example Podfile Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Sets up an example project to use the FrameLayoutKit library via CocoaPods, specifying a local path dependency. ```Ruby use_frameworks! target 'FrameLayoutKit_Example' do pod 'FrameLayoutKit', :path => '../' end ``` -------------------------------- ### NumberPadView Example with GridFrameLayout Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Demonstrates creating a number pad UI using GridFrameLayout. This example shows how to configure a grid layout with specific columns, rows, spacing, and minimum row height to arrange UIButton elements programmatically. It highlights the setup of the layout and its integration within a UIView. ```Swift // // NumberPadView.swift // FrameLayoutKit_Example // // Created by Nam Kennic on 5/8/20. // Copyright © 2020 CocoaPods. All rights reserved. // import UIKit import FrameLayoutKit class NumberPadView: UIView { let frameLayout = GridFrameLayout(axis: .horizontal, column: 3, rows: 4) let titleMap = "1 2 3 4 5 6 7 8 9 * 0 #" let colors: [UIColor] = [.red, .green, .blue, .brown, .gray, .yellow, .magenta, .black, .orange, .purple] fileprivate func color(index: Int? = nil) -> UIColor { let finalIndex = (index ?? Int(arc4random())) % colors.count return colors[finalIndex].withAlphaComponent(0.4) } init() { super.init(frame: .zero) backgroundColor = UIColor.black.withAlphaComponent(0.1) let titles = titleMap.components(separatedBy: " ") var i = 0 let buttons = titles.map { (title) -> UIButton in let button = UIButton() button.setTitle(title, for: .normal) button.backgroundColor = color(index: i) button.showsTouchWhenHighlighted = true button.titleLabel?.font = .systemFont(ofSize: 24, weight: .medium) i += 1 return button } frameLayout.edgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) frameLayout.horizontalSpacing = 5 frameLayout.verticalSpacing = 5 // frameLayout.minColumnWidth = 150 frameLayout.minRowHeight = 100 frameLayout.isAutoSize = false frameLayout.views = buttons frameLayout.isUserInteractionEnabled = true subview(frameLayout) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func sizeThatFits(_ size: CGSize) -> CGSize { return frameLayout.sizeThatFits(size) } override func layoutSubviews() { super.layoutSubviews() frameLayout.frame = bounds } } ``` -------------------------------- ### FrameLayoutKit Example: HStack with Nested VStack Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Shows a practical example of building a layout with FrameLayoutKit, combining an HStackLayout with a nested VStackLayout. It demonstrates flexible spacing, alignment, and padding for complex arrangements. ```swift let frameLayout = HStackLayout() frameLayout + VStackLayout { ($0 + earthImageView).alignment = (.top, .center) ($0 + 0).flexible() // add a flexible space ($0 + rocketImageView).alignment = (.center, .center) } frameLayout + VStackLayout { $0 + [nameLabel, dateLabel] // add an array of views $0 + 10 // add a space with a minimum of 10 pixels $0 + messageLabel // add a single view }.spacing(5.0) frameLayout .spacing(15) .padding(top: 15, left: 15, bottom: 15, right: 15) .debug(true) // show dashed lines to visualize the layout ``` -------------------------------- ### FrameLayoutKit Example: ZStack with Nested Layouts Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Illustrates creating a ZStackLayout with nested VStack and HStack layouts. This example highlights fixed sizing for images, flexible content, and padding for precise element positioning. ```swift let posterSize = CGSize(width: 100, height: 150) let frameLayout = ZStackLayout() frameLayout + backdropImageView frameLayout + VStackLayout { $0 + HStackLayout { ($0 + posterImageView).fixedSize(posterSize) $0 + VStackLayout { $0 + titleLabel $0 + subtitleLabel }.padding(bottom: 5).flexible().distribution(.bottom) }.spacing(12).padding(top: 0, left: 12, bottom: 12, right: 12) }.distribution(.bottom) ``` -------------------------------- ### FrameLayoutKit Example: VStack with Flexible Item and Distribution Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Demonstrates a VStackLayout example featuring a flexible item, nested layout, padding, distribution, and spacing for vertical arrangement. This showcases how to control item behavior and overall layout properties. ```swift let frameLayout = VStackLayout { ($0 + imageView).flexible() $0 + VStackLayout { $0 + titleLabel $0 + ratingLabel } }.padding(top: 12, left: 12, bottom: 12, right: 12) .distribution(.bottom) .spacing(5) ``` -------------------------------- ### FrameLayoutKit Standard Syntax Example Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Demonstrates the traditional, non-DSL approach to configuring FrameLayoutKit layouts. Shows how to use layout objects, properties like alignment, spacing, and distribution. ```swift frameLayout + VStackLayout { ($0 + earthImageView).alignment = (.top, .center) ($0 + 0).flexible() ($0 + rocketImageView).align(vertical: .center, horizontal: .center).bindFrame(to: redView) $0.bindFrame(to: blueView) } frameLayout + VStackLayout { $0 + HStackLayout { ($0 + nameLabel) ($0 + titleLabel).extends(size: CGSize(width: 10, height: 0)) ($0 + 0).flexible() $0 + expandButton $0.spacing(10) } $0 + dateLabel messageFrameLayout = ($0 + messageLabel) ($0 + 0.0).flexible() $0 + HStackLayout { $0.distribution = .split(ratio: [0.5, -1, -1, 0.3]) $0.spacing = 10 ($0 + [Label(.yellow), Label(.green), Label(.brown), Label(.systemPink), Label(.blue)]).forEach { $0.didLayoutSubviewsBlock = { sender in if let label = sender.targetView as? UILabel { let size = sender.frame.size label.text = "\(size.width) x \(size.height)" } } } } $0.flexible() .spacing(5) } ``` -------------------------------- ### TagListView Example with FlowFrameLayout and StackLayouts Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Illustrates the creation of a TagListView using FlowFrameLayout for arranging tags and StackLayouts (VStackLayout, HStackLayout) for overall structure. This example demonstrates configuring flow layout properties like interitem spacing, line spacing, padding, and distribution, along with button actions for adding/removing items. ```Swift // // TagListView.swift // FrameLayoutKit_Example // // Created by Nam Kennic on 11/18/20. // Copyright © 2020 CocoaPods. All rights reserved. // import UIKit import FrameLayoutKit class TagListView: UIView { let flowLayout = FlowFrameLayout(axis: .horizontal) let addButton = UIButton() let removeButton = UIButton() let frameLayout = VStackLayout().spacing(4.0) let colors: [UIColor] = [.red, .green, .blue, .brown, .yellow, .magenta, .black, .orange, .purple, .systemPink] var onChanged: ((TagListView) -> Void)? init() { super.init(frame: .zero) backgroundColor = .gray flowLayout .interitemSpacing(4) .lineSpacing(4) .padding(top: 4, left: 4, bottom: 4, right: 4) .distribution(.left) addButton.setTitle("Add Item", for: .normal) addButton.backgroundColor = .systemBlue addButton.addTarget(self, action: #selector(addItem), for: .touchUpInside) addButton.showsTouchWhenHighlighted = true removeButton.setTitle("Remove Item", for: .normal) removeButton.backgroundColor = .systemPink removeButton.addTarget(self, action: #selector(removeLastItem), for: .touchUpInside) removeButton.showsTouchWhenHighlighted = true subview(flowLayout) subview(addButton) subview(removeButton) subview(frameLayout) // Disable justified last stack flowLayout.onNewStackBlock = { (sender, layout) in sender.stacks.forEach { $0.isJustified = $0 != sender.lastStack } } frameLayout + flowLayout frameLayout + HStackLayout { $0 + [removeButton, addButton] $0.distribution(.equal) .fixedSize(CGSize(width: 0, height: 50)) } } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func sizeThatFits(_ size: CGSize) -> CGSize { return frameLayout.sizeThatFits(size) } override func layoutSubviews() { super.layoutSubviews() frameLayout.frame = bounds } } ``` -------------------------------- ### Import FrameLayoutKit Source: https://github.com/kennic/framelayoutkit/blob/master/README.md How to import the FrameLayoutKit framework into your Swift source files after installation. ```swift import FrameLayoutKit ``` -------------------------------- ### Install FrameLayoutKit with CocoaPods Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Instructions for installing FrameLayoutKit as a dependency in your project's Podfile. ```ruby pod "FrameLayoutKit" ``` -------------------------------- ### FrameLayoutKit DSL Syntax Example Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Illustrates the Domain Specific Language (DSL) for arranging UI elements within a FrameLayout. Shows VStackView, HStackView, StackItem, FlexibleSpace, alignment, and frame binding. ```swift frameLayout + VStackView { StackItem(earthImageView).align(vertical: .top, horizontal: .center) FlexibleSpace(10) StackItem(rocketImageView).align(vertical: .center, horizontal: .center).bindFrame(to: redView) }.bindFrame(to: blueView) frameLayout + VStackView { HStackView { StackItem(nameLabel) StackItem(titleLabel) FlexibleSpace() StackItem(expandButton) }.spacing(10) dateLabel StackItem(messageLabel).assign(to: &messageFrameLayout) FlexibleSpace() HStackView { Label(.yellow) Label(.green) Label(.brown) Label(.systemPink) Label(.blue) }.each { layout, _, _ in layout.didLayoutSubviewsBlock = { guard let label = $0.targetView as? UILabel else { return } let size = $0.frame.size label.text = "\(size.width) x \(size.height)" } }.distribution(.split(ratio: [0.5, -1, -1, 0.3])).spacing(10) }.flexible().spacing(5) ``` -------------------------------- ### Basic HStack and VStack Layout Example Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Demonstrates creating an HStackLayout and adding nested VStackLayouts. It shows how to set alignment, add flexible spaces, group views, and apply spacing and padding. The `debug(true)` option is used to visualize layout boundaries. ```swift let frameLayout = HStackLayout() frameLayout + VStackLayout { ($0 + earthImageView).alignment = (.top, .center) ($0 + 0).flexible() // add a flexible space ($0 + rocketImageView).alignment = (.center, .center) } frameLayout + VStackLayout { $0 + [nameLabel, dateLabel] // add an array of views $0 + 10 // add a space with a minimum of 10 pixels $0 + messageLabel // add a single view }.spacing(5.0) frameLayout .spacing(15) .padding(top: 15, left: 15, bottom: 15, right: 15) .debug(true) // show dashed lines to visualize the layout ``` -------------------------------- ### Install FrameLayoutKit via CocoaPods Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Instructions for adding the FrameLayoutKit library to your project using CocoaPods by adding the pod to your Podfile. ```ruby pod "FrameLayoutKit" ``` -------------------------------- ### FrameLayoutKit Example: CardView with Dynamic Items Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Demonstrates building a card-like view using VStackLayout with various properties like spacing and padding. It shows how to add individual items, apply fixed heights, and use `forEach` to style multiple buttons. ```swift let buttonSize = CGSize(width: 45, height: 45) let cardView = VStackLayout() .spacing(10) .padding(top: 24, left: 24, bottom: 24, right: 24) cardView + titleLabel (cardView + emailField).minHeight = 50 (cardView + passwordField).minHeight = 50 (cardView + nextButton).fixedHeight = 45 (cardView + separateLine) .fixedContentHeight(1) .padding(top: 4, left: 0, bottom: 4, right: 40) cardView + HStackLayout { ($0 + [facebookButton, googleButton, appleButton]) .forEach { $0.fixedContentSize(buttonSize) } }.distribution(.center).spacing(10) ``` -------------------------------- ### FrameLayoutKit DSL Syntax Example Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Demonstrates the intuitive operand syntax of FrameLayoutKit for creating complex layouts, contrasting with traditional autolayout. This syntax allows for chaining and nesting of layout elements. ```Swift let view = FrameLayout() .add(subview: UIView()) .add(subview: UIView()) .center() .width(100) .height(100) ``` -------------------------------- ### Install FrameLayoutKit Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Instructions for importing the FrameLayoutKit framework into your Swift project, compatible with Swift Package Manager and CocoaPods. ```Swift import FrameLayoutKit ``` -------------------------------- ### Install FrameLayoutKit with Swift Package Manager Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Instructions for adding FrameLayoutKit to your project using Swift Package Manager by providing the Git repository URL. ```swift https://github.com/kennic/FrameLayoutKit.git ``` -------------------------------- ### Install FrameLayoutKit via Swift Package Manager Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Instructions for adding the FrameLayoutKit library to your Xcode project using Swift Package Manager. ```swift https://github.com/kennic/FrameLayoutKit.git ``` -------------------------------- ### FrameLayoutKit ViewController Setup Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Configures a UIViewController using FrameLayoutKit components. It demonstrates adding CardView and TagListView instances to a ScrollStackView and setting layout properties. ```swift // // ViewController.swift // FrameLayoutKit // // Created by Nam Kennic on 07/12/2018. // Copyright (c) 2018 Nam Kennic. All rights reserved. // import UIKit import FrameLayoutKit class ViewController: UIViewController { let scrollStackView = ScrollStackView() let tagListView = TagListView() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .lightGray var cardViews = [UIView]() for _ in 0..<5 { let cardView = CardView() cardView.onSizeChanged = { [weak self] sender in self?.scrollStackView.relayoutSubviews(animateDuration: 0.35) } cardViews.append(cardView) } tagListView.onChanged = { [weak self] sender in self?.scrollStackView.relayoutSubviews(animateDuration: 0.35) } scrollStackView + cardViews scrollStackView + NumberPadView() scrollStackView + tagListView scrollStackView .spacing(20) .padding(top: 50, left: 50, bottom: 50, right: 50) .distribution(.center) view.addSubview(scrollStackView) } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() scrollStackView.frame = view.bounds } } ``` -------------------------------- ### StackLayout Initialization and Configuration Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Defines a StackLayout class that inherits from StackFrameLayout, providing a convenient initializer that accepts a closure for configuring the layout. This allows for declarative setup of stack-based layouts. ```swift open class StackLayout: StackFrameLayout { @discardableResult public init(_ block: (StackLayout) throws -> Void) rethrows { super.init() try block(self) } required public init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } public required init() { fatalError("init() has not been implemented") } } ``` -------------------------------- ### FrameLayoutKit: Initializer with Axis, Distribution, and Views Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Initializes a FrameLayout with a specified axis and distribution, optionally adding an array of views. This convenience initializer simplifies the setup of a layout container with predefined orientation and content. ```swift convenience public init(axis: NKLayoutAxis, distribution: NKLayoutDistribution = .top, views: [UIView]? = nil) { self.init() self.axis = axis self.distribution = distribution if let views { add(views) } } ``` -------------------------------- ### Helper Function for Creating Labels Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt A utility function to create UILabel instances with specified background color and default text. Used within layout examples. ```swift func Label(_ color: UIColor, _ text: String = " ") -> UILabel { let label = UILabel() label.textColor = .black label.backgroundColor = color label.text = text return label } ``` -------------------------------- ### FrameLayoutKit Example CardView Implementation Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Demonstrates the usage of FrameLayoutKit within a custom UIView subclass (CardView) for arranging UI elements like images, labels, and buttons. ```Swift // // CardView.swift // FrameLayoutKit_Example // // Created by Nam Kennic on 5/8/20. // Copyright © 2020 CocoaPods. All rights reserved. // import UIKit import FrameLayoutKit class CardView: UIView { let earthImageView = UIImageView(image: UIImage(named: "earth_48x48")) let rocketImageView = UIImageView(image: UIImage(named: "rocket_32x32")) let nameLabel = UILabel() let titleLabel = UILabel() let dateLabel = UILabel() let messageLabel = UILabel() let expandButton = UIButton() let frameLayout = HStackLayout { $0.spacing = 15.0 $0.padding(15) } let blueView = UIView() let redView = UIView() var messageFrameLayout: FrameLayout! var onSizeChanged: ((CardView) -> Void)? init() { super.init(frame: .zero) layer.backgroundColor = UIColor.white.cgColor layer.shadowColor = UIColor.black.withAlphaComponent(0.5).cgColor layer.shadowOffset = .zero layer.shadowRadius = 5 layer.shadowOpacity = 0.6 layer.masksToBounds = false blueView.backgroundColor = .systemBlue redView.backgroundColor = .systemRed expandButton.setImage(UIImage(named: "collapse_24x24"), for: .normal) expandButton.setImage(UIImage(named: "expand_24x24"), for: .selected) expandButton.addTarget(self, action: #selector(onButtonTap), for: .touchUpInside) nameLabel.font = .systemFont(ofSize: 18, weight: .bold) nameLabel.text = "John Appleseed" titleLabel.textAlignment = .center titleLabel.font = .systemFont(ofSize: 14, weight: .regular) titleLabel.text = "Admin" titleLabel.textColor = .white titleLabel.backgroundColor = .purple titleLabel.layer.cornerRadius = 4.0 titleLabel.layer.masksToBounds = true ``` -------------------------------- ### Card View Layout with Input Fields and Buttons Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt This example constructs a card-like UI using VStackLayout. It includes labels, input fields with minimum height constraints, a separator line with fixed height, and a horizontal stack of buttons with fixed sizes, demonstrating layout composition and constraints. ```swift let buttonSize = CGSize(width: 45, height: 45) let cardView = VStackLayout() .spacing(10) .padding(top: 24, left: 24, bottom: 24, right: 24) cardView + titleLabel (cardView + emailField).minHeight = 50 (cardView + passwordField).minHeight = 50 (cardView + nextButton).fixedHeight = 45 (cardView + separateLine) .fixedContentHeight(1) .padding(top: 4, left: 0, bottom: 4, right: 40) cardView + HStackLayout { ($0 + [facebookButton, googleButton, appleButton]) .forEach { $0.fixedContentSize(buttonSize) } }.distribution(.center).spacing(10) ``` -------------------------------- ### Configure GridFrameLayout with Chainable Swift Extensions Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Provides chainable methods for configuring GridFrameLayout properties like axis, row/column dimensions, and spacing. These extensions simplify layout setup in Swift by allowing fluent configuration. ```Swift // // GridFrameLayout+Chainable.swift // FrameLayoutKit // // Created by Nam Kennic on 9/12/21. // import Foundation import UIKit extension GridFrameLayout { @discardableResult public func axis(_ value: NKLayoutAxis) -> Self { axis = value return self } @discardableResult public func minRowHeight(_ value: CGFloat) -> Self { minRowHeight = value return self } @discardableResult public func maxRowHeight(_ value: CGFloat) -> Self { maxRowHeight = value return self } @discardableResult public func minColumnWidth(_ value: CGFloat) -> Self { minColumnWidth = value return self } @discardableResult public func maxColumnWidth(_ value: CGFloat) -> Self { maxColumnWidth = value return self } @discardableResult public func fixedRowHeight(_ value: CGFloat) -> Self { fixedRowHeight = value return self } @discardableResult public func fixedColumnWidth(_ value: CGFloat) -> Self { fixedColumnWidth = value return self } @discardableResult public func interitemSpacing(_ value: CGFloat) -> Self { verticalSpacing = value return self } @discardableResult public func lineSpacing(_ value: CGFloat) -> Self { horizontalSpacing = value return self } } ``` -------------------------------- ### ZStack Layout with Nested Stacks for Poster Details Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Shows a ZStackLayout used to layer views, featuring a backdrop image and a nested VStack/HStack structure. This example demonstrates fixed sizing for elements like posters, flexible content, and specific padding for detail presentation. ```swift let posterSize = CGSize(width: 100, height: 150) let frameLayout = ZStackLayout() frameLayout + backdropImageView frameLayout + VStackLayout { $0 + HStackLayout { ($0 + posterImageView).fixedSize(posterSize) $0 + VStackLayout { $0 + titleLabel $0 + subtitleLabel }.padding(bottom: 5).flexible().distribution(.bottom) }.spacing(12).padding(top: 0, left: 12, bottom: 12, right: 12) }.distribution(.bottom) ``` -------------------------------- ### Xcode Project Configuration Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Core Xcode project settings file (project.pbxproj) for the FrameLayoutKit_Example project. It lists build files, file references, and project structure. ```Xcode Project // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 632A5FA524651ACB008DD793 /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 632A5FA424651ACB008DD793 /* CardView.swift */; }; 632A5FA724651B14008DD793 /* NumberPadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 632A5FA624651B14008DD793 /* NumberPadView.swift */; }; 635B4D7F256530B70006C5B8 /* TagListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 635B4D7E256530B70006C5B8 /* TagListView.swift */; }; B0779CC809BA3EBEA8A7BA24 /* Pods_FrameLayoutKit_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 88079A93676318D377A9E051 /* Pods_FrameLayoutKit_Example.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 23024746510C90D82DBB9804 /* Pods-FrameLayoutKit_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FrameLayoutKit_Example.debug.xcconfig"; path = "Target Support Files/Pods-FrameLayoutKit_Example/Pods-FrameLayoutKit_Example.debug.xcconfig"; sourceTree = ""; }; 56C814E0EDE5EC3DE2FA2FE4 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = "../LICENSE"; sourceTree = ""; }; 5B2624AAEE48DCD02D4F0B67 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = "../README.md"; sourceTree = ""; }; 607FACD01AFB9204008FA782 /* FrameLayoutKit_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FrameLayoutKit_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXGroup section */ 607FACCF1AFB9204008FA782 /* Project */ = { ``` -------------------------------- ### Get Last Row Layout Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Provides access to the last row's StackFrameLayout, if available. ```swift public var lastRowLayout: StackFrameLayout? { return stackLayout.lastFrameLayout as? StackFrameLayout } ``` -------------------------------- ### Create and Configure VStackLayout Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Demonstrates the basic creation of a VStackLayout, setting properties like spacing and padding, adding subviews, and integrating it into a parent view. ```swift // Create a vertical layout let vStackLayout = VStackLayout() vStackLayout.spacing = 10 vStackLayout.distribution = .center vStackLayout.padding(top: 20, left: 20, bottom: 20, right: 20) // Add views to the layout vStackLayout.add(view1) vStackLayout.add(view2) vStackLayout.add(view3) // Add the layout to a parent view parentView.addSubview(vStackLayout) // Update the layout's frame vStackLayout.frame = parentView.bounds ``` -------------------------------- ### Get First Row Layout Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Provides access to the first row's StackFrameLayout, if available. ```swift public var firstRowLayout: StackFrameLayout? { return stackLayout.firstFrameLayout as? StackFrameLayout } ``` -------------------------------- ### Storyboard and XIB Files Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt References to UI definition files, including the main storyboard and launch screen XIB. ```xml Base.lproj/Main.storyboard ``` ```xml Base.lproj/LaunchScreen.xib ``` -------------------------------- ### Get View at Row and Column Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Retrieves a specific UIView from the layout based on its row and column index. ```swift public func viewAt(row: Int, column: Int) -> UIView? { ``` -------------------------------- ### Create and Configure VStackLayout Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Demonstrates creating a vertical stack layout, setting spacing, distribution, and padding, then adding views. ```swift let vStackLayout = VStackLayout() vStackLayout.spacing = 10 vStackLayout.distribution = .center vStackLayout.padding(top: 20, left: 20, bottom: 20, right: 20) // Add views to the layout vStackLayout.add(view1) vStackLayout.add(view2) vStackLayout.add(view3) // Add the layout to a parent view parentView.addSubview(vStackLayout) // Update the layout's frame vStackLayout.frame = parentView.bounds ``` -------------------------------- ### Get FrameLayout by Index - Swift Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Retrieves a FrameLayout object from the collection at a specified index. Returns nil if the index is out of bounds. ```swift public func frameLayout(at index: Int) -> FrameLayout? { guard index >= 0 && index < frameLayouts.count else { return nil } return frameLayouts[index] } ``` -------------------------------- ### Create HStackLayout with DSL Syntax Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Illustrates creating an HStackLayout using FrameLayoutKit's DSL syntax. This shows how to add items, set fixed sizes, nest layouts, and utilize flexible space within the horizontal stack. ```swift let hStackLayout = HStackView { StackItem(imageView).fixedSize(width: 50, height: 50) VStackView { titleLabel subtitleLabel }.spacing(5) FlexibleSpace() // Add flexible space StackItem(button).align(vertical: .center, horizontal: .right) } ``` -------------------------------- ### Get Last FrameLayout (Swift) Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Returns the last FrameLayout in the last StackFrameLayout. Optionally, it can find the last FrameLayout that has a targetView assigned. ```swift public func lastFrameLayout(containsView: Bool = false) -> FrameLayout? { guard let lastStack = lastStack else { return nil } if containsView { return lastStack.frameLayouts.last(where: { $0.targetView != nil }) } else { return lastStack.frameLayouts.last } } ``` -------------------------------- ### Manage Rows Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Gets or sets the number of rows. Manages the count of internal frameLayouts by adding or removing rows, triggering layout updates. ```swift public var rows: Int { get { stackLayout.frameLayouts.count } set { let count = stackLayout.frameLayouts.count if newValue == 0 { removeAllCells() return } if newValue < count { while stackLayout.frameLayouts.count > newValue { removeRow(at: stackLayout.frameLayouts.count - 1) } } else if newValue > count { while stackLayout.frameLayouts.count < newValue { addRow() } } } } ``` -------------------------------- ### Configure Vertical Spacing Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Gets or sets the vertical spacing between elements. Updates the internal stackLayout's spacing and triggers a layout update. ```swift public var verticalSpacing: CGFloat { get { stackLayout.spacing } set { stackLayout.spacing = newValue setNeedsLayout() } } ``` -------------------------------- ### Create VStackLayout with DSL Syntax Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Demonstrates creating a VStackLayout using FrameLayoutKit's DSL syntax. This includes adding views, fixed spacing, and customizing item properties like minimum width. ```swift let vStackLayout = VStackView { titleLabel descriptionLabel SpaceItem(20) // Add a 20pt space Item(actionButton).minWidth(120) // Customize the button's minimum width } ``` -------------------------------- ### Framework Dependencies Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Lists the frameworks that are linked to the project, including Pods-generated frameworks. ```pbxproj Pods_FrameLayoutKit_Example.framework ``` ```pbxproj Pods_FrameLayoutKit_Tests.framework ``` -------------------------------- ### Project Build Settings Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt XML configuration file detailing build location and issue filter settings for the project. ```xml BuildLocationStyle UseAppPreferences CustomBuildLocationType RelativeToDerivedData DerivedDataLocationStyle Default IssueFilterStyle ShowActiveSchemeOnly LiveSourceIssuesEnabled ShowSharedSchemesAutomaticallyEnabled ``` -------------------------------- ### Initialize StackFrameLayout Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Provides multiple initializers for creating StackFrameLayout instances. These allow configuration of the layout axis, distribution, and optionally adding initial views. A convenience initializer also supports block-based configuration. ```swift public let frameLayout = StackFrameLayout(axis: .vertical, distribution: .top) convenience public init(axis: NKLayoutAxis = .vertical, distribution: NKLayoutDistribution = .top, views: [UIView]? = nil) { self.init() self.axis = axis self.distribution = distribution defer { if let views, !views.isEmpty { self.views = views } } } @discardableResult public convenience init(_ block: (ScrollStackView) throws -> Void) rethrows { self.init() try block(self) } public required init() { super.init(frame: .zero) scrollView.bounces = true scrollView.alwaysBounceHorizontal = false scrollView.alwaysBounceVertical = false scrollView.isDirectionalLockEnabled = true scrollView.showsVerticalScrollIndicator = false scrollView.showsHorizontalScrollIndicator = false scrollView.clipsToBounds = false scrollView.delaysContentTouches = false #if os(iOS) if #available(iOS 11.0, *) { scrollView.contentInsetAdjustmentBehavior = .never } if #available(iOS 13.0, *) { scrollView.automaticallyAdjustsScrollIndicatorInsets = false } #endif frameLayout.spacing = 0.0 frameLayout.isIntrinsicSizeEnabled = true frameLayout.shouldCacheSize = false scrollView.addSubview(frameLayout) addSubview(scrollView) } required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } ``` -------------------------------- ### Project Configuration Files Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt References to project configuration files, including entitlements and CocoaPods configuration. ```plist FrameLayoutKit_Example.entitlements ``` ```xcconfig Target Support Files/Pods-FrameLayoutKit_Example/Pods-FrameLayoutKit_Example.debug.xcconfig ``` ```xcconfig Target Support Files/Pods-FrameLayoutKit_Example/Pods-FrameLayoutKit_Example.release.xcconfig ``` ```xcconfig Target Support Files/Pods-FrameLayoutKit_Tests/Pods-FrameLayoutKit_Tests.debug.xcconfig ``` ```xcconfig Target Support Files/Pods-FrameLayoutKit_Tests/Pods-FrameLayoutKit_Tests.release.xcconfig ``` -------------------------------- ### Get FrameLayout by Row and Column (Swift) Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Retrieves a specific FrameLayout from a nested structure based on row and column indices. It performs bounds checking to ensure valid indices. ```swift public func frameLayout(row: Int, column: Int) -> FrameLayout? { guard row > -1, row < stackLayout.frameLayouts.count else { return nil } guard let rowLayout = stackLayout.frameLayouts[row] as? StackFrameLayout else { return nil } return rowLayout.frameLayout(at: column) } ``` -------------------------------- ### Configure Layout Properties with Chained Syntax Source: https://github.com/kennic/framelayoutkit/blob/master/README.md Demonstrates using a fluent, chained syntax to configure various properties of a layout, such as distribution, spacing, flexibility, and padding. ```swift vStackLayout .distribution(.center) .spacing(16) .flexible() .fixedHeight(50) .aligns(.top, .center) .padding(top: 20, left: 20, bottom: 20, right: 20) ``` -------------------------------- ### Configure Layout Properties with Chained Syntax Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Demonstrates using chained method calls to configure layout properties such as distribution, spacing, flexibility, fixed dimensions, alignment, and padding. ```swift vStackLayout .distribution(.center) .spacing(16) .flexible() .fixedHeight(50) .aligns(.top, .center) .padding(top: 20, left: 20, bottom: 20, right: 20) ``` -------------------------------- ### FLSkeletonView Shimmering Animation Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Defines the FLSkeletonView, a custom UIView that implements a shimmering effect using CAGradientLayer and CABasicAnimation. It handles starting and stopping the animation when the view is added or removed from the superview. ```swift // // FLSkeletonView.swift // FrameLayoutKit // // Created by Nam Kennic on 9/3/23. // import UIKit public class FLSkeletonView: UIView { let gradient = CAGradientLayer() let lightLayer = CAShapeLayer() let animation = CABasicAnimation(keyPath: "locations") public override var backgroundColor: UIColor? { didSet { lightLayer.fillColor = UIColor.lightText.cgColor } } init() { super.init(frame: .zero) layer.cornerRadius = 5 layer.masksToBounds = true layer.addSublayer(lightLayer) let light = UIColor.clear.cgColor let dark = UIColor.black.cgColor gradient.colors = [dark, light, dark] gradient.startPoint = CGPoint(x: 0.0, y: 0.5) gradient.endPoint = CGPoint(x: 1.0, y: 0.525) gradient.locations = [0.4, 0.5, 0.6] lightLayer.mask = gradient animation.fromValue = [0.0, 0.1, 0.2] animation.toValue = [0.8, 0.9, 1.0] } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } public override func didMoveToSuperview() { if superview != nil { startShimmering() } else { stopShimmering() } } public func startShimmering(duration: TimeInterval = 1.0, repeatCount: Float = HUGE, repeatDuration: TimeInterval = 0) { animation.duration = duration animation.repeatCount = repeatCount animation.repeatDuration = repeatDuration gradient.add(animation, forKey: "shimmer") } public func stopShimmering() { layer.mask?.removeAllAnimations() layer.mask = nil } public override func layoutSubviews() { super.layoutSubviews() lightLayer.path = UIBezierPath(roundedRect: bounds, cornerRadius: layer.cornerRadius).cgPath lightLayer.frame = bounds gradient.frame = CGRect(x: -bounds.size.width, y: 0, width: 3 * bounds.size.width, height: bounds.size.height) } deinit { stopShimmering() } } ``` -------------------------------- ### Create HStackLayout with DSL Syntax Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Demonstrates creating a horizontal stack layout using DSL syntax, including wrapping views with StackItem, adding flexible spacing, and configuring item alignment. ```swift // Create HStackLayout with DSL syntax let hStackLayout = HStackView { StackItem(imageView).fixedSize(width: 50, height: 50) VStackView { titleLabel subtitleLabel }.spacing(5) FlexibleSpace() // Add flexible space StackItem(button).align(vertical: .center, horizontal: .right) } ``` -------------------------------- ### Create VStackLayout with DSL Syntax Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Shows how to create a vertical stack layout using a Domain Specific Language (DSL) syntax, allowing for intuitive addition of views, spacing, and custom item configurations. ```swift // Create VStackLayout with DSL syntax let vStackLayout = VStackView { titleLabel descriptionLabel SpaceItem(20) // Add a 20pt space Item(actionButton).minWidth(120) // Customize the button's minimum width } ``` -------------------------------- ### Initialize with Axis and Dimensions Source: https://github.com/kennic/framelayoutkit/blob/master/llms.txt Convenience initializer to set the layout axis, initial columns, and rows. ```swift public convenience init(axis: NKLayoutAxis, column: Int = 0, rows: Int = 0) { self.init() self.axis = axis defer { self.rows = rows self.columns = column self.initColumns = column } } ```