From 20271734691c43404b5e96070f390d64e58589c8 Mon Sep 17 00:00:00 2001 From: Pavel Sharanda Date: Thu, 15 Feb 2024 12:07:36 +0000 Subject: [PATCH] Rename Grow -> Fill --- .../Stories/FixFlexStories.swift | 46 +++++++------- README.md | 62 +++++++++---------- Readme/src/templates/README.md | 16 ++--- Sources/FixFlex.swift | 18 +++--- 4 files changed, 71 insertions(+), 71 deletions(-) diff --git a/FixFlexSamples/FixFlexSamples/Stories/FixFlexStories.swift b/FixFlexSamples/FixFlexSamples/Stories/FixFlexStories.swift index 79e430c..594896a 100644 --- a/FixFlexSamples/FixFlexSamples/Stories/FixFlexStories.swift +++ b/FixFlexSamples/FixFlexSamples/Stories/FixFlexStories.swift @@ -65,13 +65,13 @@ class FixFlexStories: DynamicComponentStories { parent.widthAnchor.constraint(equalToConstant: 200).isActive = true parent.heightAnchor.constraint(equalToConstant: 100).isActive = true - parent.fx.hstack(Grow(), + parent.fx.hstack(Fill(), Fix(child, 100), - Grow()) + Fill()) - parent.fx.vstack(Grow(), + parent.fx.vstack(Fill(), Fix(child, 50), - Grow()) + Fill()) return parent } @@ -91,13 +91,13 @@ class FixFlexStories: DynamicComponentStories { parent.widthAnchor.constraint(equalToConstant: 200).isActive = true parent.heightAnchor.constraint(equalToConstant: 200).isActive = true - parent.fx.hstack(Grow(), + parent.fx.hstack(Fill(), Flex(label), - Grow()) + Fill()) - parent.fx.vstack(Grow(), + parent.fx.vstack(Fill(), Flex(label), - Grow()) + Fill()) return parent } @@ -126,11 +126,11 @@ class FixFlexStories: DynamicComponentStories { parent.fx.hstack(Flex([topLabel, bottomLabel])) - parent.fx.vstack(Grow(), + parent.fx.vstack(Fill(), Flex(topLabel), Fix(5), Flex(bottomLabel), - Grow()) + Fill()) return parent } @@ -182,9 +182,9 @@ class FixFlexStories: DynamicComponentStories { Flex(subtitleLabel), Fix(15)) - parent.fx.vstack(Grow(), + parent.fx.vstack(Fill(), Fix(chevron, 30), - Grow()) + Fill()) return parent } @@ -294,11 +294,11 @@ class FixFlexStories: DynamicComponentStories { Fix(5)) parent.fx.hstack(Fix(5), - Grow(label1, weight: 2), + Fill(label1, weight: 2), Fix(5), - Grow(label2), + Fill(label2), Fix(5), - Grow(label3), + Fill(label3), Fix(5)) return parent @@ -380,9 +380,9 @@ class FixFlexStories: DynamicComponentStories { parent.fx.vstack(Flex([label, leadingView, trailingView])) - parent.fx.hstack(Grow(), + parent.fx.hstack(Fill(), Flex(label), - Grow()) + Fill()) parent.fx.hstack(startAnchor: label.leadingAnchor, endAnchor: label.trailingAnchor, @@ -417,9 +417,9 @@ class FixFlexStories: DynamicComponentStories { parent.fx.vstack(Flex([label, leadingView, trailingView])) - parent.fx.hstack(Grow(), + parent.fx.hstack(Fill(), Flex(label), - Grow()) + Fill()) parent.fx.hstack(startAnchor: label.leftAnchor, endAnchor: label.rightAnchor, @@ -451,13 +451,13 @@ class FixFlexStories: DynamicComponentStories { parent.widthAnchor.constraint(equalToConstant: 200).isActive = true parent.heightAnchor.constraint(equalToConstant: 200).isActive = true - parent.fx.vstack(Grow(), + parent.fx.vstack(Fill(), Flex(label), - Grow()) + Fill()) - parent.fx.hstack(Grow(), + parent.fx.hstack(Fill(), Flex(label), - Grow()) + Fill()) parent.fx.vstack(startAnchor: label.topAnchor, Fix(10), diff --git a/README.md b/README.md index eac755b..73322c4 100644 --- a/README.md +++ b/README.md @@ -77,12 +77,12 @@ parent.fx.vstack(Fix(15), width="400" /> -To center the chevron, we ensure the top spacing is equal to the bottom spacing using `Grow`: +To center the chevron, we ensure the top spacing is equal to the bottom spacing using `Fill`: ```swift -parent.fx.vstack(Grow(), +parent.fx.vstack(Fill(), Fix(chevron, 30), - Grow()) + Fill()) ``` That's it! The best part is how easy it is to modify FixFlex layout code, inserting extra padding or views effortlessly, without the need to rewire constraints. @@ -150,16 +150,16 @@ func Flex(_ view: _View, min: CGFloat? = nil, max: CGFloat? = nil, huggingPriori func Flex(_ views: [_View], min: CGFloat? = nil, max: CGFloat? = nil, huggingPriority: _LayoutPriority? = nil, compressionResistancePriority: _LayoutPriority? = nil) -> SizingIntent ``` -### Grow +### Fill -`Grow` allows a view/spacer to proportionally occupy the available free space based on its weight. It's particularly useful for achieving equal spacing, centering elements, or for designing symmetrical layouts like tables or grids. +`Fill` allows a view/spacer to proportionally occupy the available free space based on its weight. It's particularly useful for achieving equal spacing, centering elements, or for designing symmetrical layouts like tables or grids. ```swift -func Grow(weight: CGFloat = 1.0) -> SizingIntent +func Fill(weight: CGFloat = 1.0) -> SizingIntent -func Grow(_ view: _View, weight: CGFloat = 1.0) -> SizingIntent +func Fill(_ view: _View, weight: CGFloat = 1.0) -> SizingIntent -func Grow(_ views: [_View], weight: CGFloat = 1.0) -> SizingIntent +func Fill(_ views: [_View], weight: CGFloat = 1.0) -> SizingIntent ``` ### Match @@ -257,13 +257,13 @@ parent.addSubview(child) parent.widthAnchor.constraint(equalToConstant: 200).isActive = true parent.heightAnchor.constraint(equalToConstant: 100).isActive = true -parent.fx.hstack(Grow(), +parent.fx.hstack(Fill(), Fix(child, 100), - Grow()) + Fill()) -parent.fx.vstack(Grow(), +parent.fx.vstack(Fill(), Fix(child, 50), - Grow()) + Fill()) ``` @@ -290,13 +290,13 @@ parent.addSubview(label) parent.widthAnchor.constraint(equalToConstant: 200).isActive = true parent.heightAnchor.constraint(equalToConstant: 200).isActive = true -parent.fx.hstack(Grow(), +parent.fx.hstack(Fill(), Flex(label), - Grow()) + Fill()) -parent.fx.vstack(Grow(), +parent.fx.vstack(Fill(), Flex(label), - Grow()) + Fill()) ``` @@ -332,11 +332,11 @@ parent.heightAnchor.constraint(equalToConstant: 200).isActive = true parent.fx.hstack(Flex([topLabel, bottomLabel])) -parent.fx.vstack(Grow(), +parent.fx.vstack(Fill(), Flex(topLabel), Fix(5), Flex(bottomLabel), - Grow()) + Fill()) ``` @@ -395,9 +395,9 @@ parent.fx.vstack(Fix(15), Flex(subtitleLabel), Fix(15)) -parent.fx.vstack(Grow(), +parent.fx.vstack(Fill(), Fix(chevron, 30), - Grow()) + Fill()) ``` @@ -528,11 +528,11 @@ parent.fx.vstack(Fix(5), Fix(5)) parent.fx.hstack(Fix(5), - Grow(label1, weight: 2), + Fill(label1, weight: 2), Fix(5), - Grow(label2), + Fill(label2), Fix(5), - Grow(label3), + Fill(label3), Fix(5)) ``` @@ -628,9 +628,9 @@ parent.widthAnchor.constraint(equalToConstant: 200).isActive = true parent.fx.vstack(Flex([label, leadingView, trailingView])) -parent.fx.hstack(Grow(), +parent.fx.hstack(Fill(), Flex(label), - Grow()) + Fill()) parent.fx.hstack(startAnchor: label.leadingAnchor, endAnchor: label.trailingAnchor, @@ -672,9 +672,9 @@ parent.widthAnchor.constraint(equalToConstant: 200).isActive = true parent.fx.vstack(Flex([label, leadingView, trailingView])) -parent.fx.hstack(Grow(), +parent.fx.hstack(Fill(), Flex(label), - Grow()) + Fill()) parent.fx.hstack(startAnchor: label.leftAnchor, endAnchor: label.rightAnchor, @@ -713,13 +713,13 @@ parent.addSubview(label) parent.widthAnchor.constraint(equalToConstant: 200).isActive = true parent.heightAnchor.constraint(equalToConstant: 200).isActive = true -parent.fx.vstack(Grow(), +parent.fx.vstack(Fill(), Flex(label), - Grow()) + Fill()) -parent.fx.hstack(Grow(), +parent.fx.hstack(Fill(), Flex(label), - Grow()) + Fill()) parent.fx.vstack(startAnchor: label.topAnchor, Fix(10), diff --git a/Readme/src/templates/README.md b/Readme/src/templates/README.md index 69c1a8b..3ce6641 100644 --- a/Readme/src/templates/README.md +++ b/Readme/src/templates/README.md @@ -77,12 +77,12 @@ parent.fx.vstack(Fix(15), width="400" /> -To center the chevron, we ensure the top spacing is equal to the bottom spacing using `Grow`: +To center the chevron, we ensure the top spacing is equal to the bottom spacing using `Fill`: ```swift -parent.fx.vstack(Grow(), +parent.fx.vstack(Fill(), Fix(chevron, 30), - Grow()) + Fill()) ``` That's it! The best part is how easy it is to modify FixFlex layout code, inserting extra padding or views effortlessly, without the need to rewire constraints. @@ -150,16 +150,16 @@ func Flex(_ view: _View, min: CGFloat? = nil, max: CGFloat? = nil, huggingPriori func Flex(_ views: [_View], min: CGFloat? = nil, max: CGFloat? = nil, huggingPriority: _LayoutPriority? = nil, compressionResistancePriority: _LayoutPriority? = nil) -> SizingIntent ``` -### Grow +### Fill -`Grow` allows a view/spacer to proportionally occupy the available free space based on its weight. It's particularly useful for achieving equal spacing, centering elements, or for designing symmetrical layouts like tables or grids. +`Fill` allows a view/spacer to proportionally occupy the available free space based on its weight. It's particularly useful for achieving equal spacing, centering elements, or for designing symmetrical layouts like tables or grids. ```swift -func Grow(weight: CGFloat = 1.0) -> SizingIntent +func Fill(weight: CGFloat = 1.0) -> SizingIntent -func Grow(_ view: _View, weight: CGFloat = 1.0) -> SizingIntent +func Fill(_ view: _View, weight: CGFloat = 1.0) -> SizingIntent -func Grow(_ views: [_View], weight: CGFloat = 1.0) -> SizingIntent +func Fill(_ views: [_View], weight: CGFloat = 1.0) -> SizingIntent ``` ### Match diff --git a/Sources/FixFlex.swift b/Sources/FixFlex.swift index b93ec54..c0dd4b0 100644 --- a/Sources/FixFlex.swift +++ b/Sources/FixFlex.swift @@ -30,7 +30,7 @@ public struct SizingIntent { case fix(value: CGFloat) case flex(min: CGFloat?, max: CGFloat?, huggingPriority: _LayoutPriority?, compressionResistancePriority: _LayoutPriority?) case match(dimension: NSLayoutDimension, multiplier: CGFloat?, offset: CGFloat?) - case grow(weight: CGFloat) + case fill(weight: CGFloat) } let sizing: Sizing @@ -86,18 +86,18 @@ public func Match(_ views: [_View], dimension: NSLayoutDimension, multiplier: CG return SizingIntent(views: views, sizing: .match(dimension: dimension, multiplier: multiplier, offset: offset)) } -/// Grow shorthands +/// Fill shorthands -public func Grow(weight: CGFloat = 1.0) -> SizingIntent { - return SizingIntent(views: nil, sizing: .grow(weight: weight)) +public func Fill(weight: CGFloat = 1.0) -> SizingIntent { + return SizingIntent(views: nil, sizing: .fill(weight: weight)) } -public func Grow(_ view: _View, weight: CGFloat = 1.0) -> SizingIntent { - return Grow([view], weight: weight) +public func Fill(_ view: _View, weight: CGFloat = 1.0) -> SizingIntent { + return Fill([view], weight: weight) } -public func Grow(_ views: [_View], weight: CGFloat = 1.0) -> SizingIntent { - return SizingIntent(views: views, sizing: .grow(weight: weight)) +public func Fill(_ views: [_View], weight: CGFloat = 1.0) -> SizingIntent { + return SizingIntent(views: views, sizing: .fill(weight: weight)) } /// Axis anchors abstraction @@ -242,7 +242,7 @@ public extension FixFlexing { } case let .match(dimension, multiplier, offset): handleSizingConstraint(aa.dimensionAnchor.constraint(equalTo: dimension, multiplier: multiplier ?? 1, constant: offset ?? 0)) - case let .grow(weight): + case let .fill(weight): if let weightsInfo { handleSizingConstraint(aa.dimensionAnchor.constraint(equalTo: weightsInfo.dimensionAnchor, multiplier: weight / weightsInfo.weight))