Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
4e746a65
Commit
4e746a65
authored
Oct 30, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added leading and trailing support
parent
e9006d9e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
217 additions
and
0 deletions
+217
-0
Sources/iOS/Layout.swift
+157
-0
Sources/iOS/LayoutAnchor.swift
+35
-0
Sources/iOS/LayoutAttribute.swift
+25
-0
No files found.
Sources/iOS/Layout.swift
View file @
4e746a65
...
@@ -124,6 +124,26 @@ public extension Layout {
...
@@ -124,6 +124,26 @@ public extension Layout {
}
}
/**
/**
Constraints leading of the view to its parent's.
- Parameter _ offset: A CGFloat offset.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
leading
(
_
offset
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
leading
,
constant
:
offset
)
}
/**
Constraints trailing of the view to its parent.
- Parameter _ offset: A CGFloat offset.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
trailing
(
_
offset
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
trailing
,
constant
:
-
offset
)
}
/**
Constraints bottom of the view to its parent's.
Constraints bottom of the view to its parent's.
- Parameter _ offset: A CGFloat offset.
- Parameter _ offset: A CGFloat offset.
- Returns: A Layout instance to allow chaining.
- Returns: A Layout instance to allow chaining.
...
@@ -189,6 +209,61 @@ public extension Layout {
...
@@ -189,6 +209,61 @@ public extension Layout {
}
}
/**
/**
Constraints top-leading of the view to its parent's.
- Parameter top: A CGFloat offset for top.
- Parameter leading: A CGFloat offset for leading.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
topLeading
(
top
:
CGFloat
=
0
,
leading
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
topLeading
,
constants
:
top
,
leading
)
}
/**
Constraints top-trailing of the view to its parent's.
- Parameter top: A CGFloat offset for top.
- Parameter trailing: A CGFloat offset for trailing.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
topTrailing
(
top
:
CGFloat
=
0
,
trailing
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
topTrailing
,
constants
:
top
,
-
trailing
)
}
/**
Constraints bottom-leading of the view to its parent's.
- Parameter bottom: A CGFloat offset for bottom.
- Parameter leading: A CGFloat offset for leading.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
bottomLeading
(
bottom
:
CGFloat
=
0
,
leading
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
bottomLeading
,
constants
:
-
bottom
,
leading
)
}
/**
Constraints bottom-trailing of the view to its parent's.
- Parameter bottom: A CGFloat offset for bottom.
- Parameter trailing: A CGFloat offset for trailing.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
bottomTrailing
(
bottom
:
CGFloat
=
0
,
trailing
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
bottomTrailing
,
constants
:
-
bottom
,
-
trailing
)
}
/**
Constraints leading and trailing of the view to its parent's.
- Parameter leading: A CGFloat offset for leading.
- Parameter trailing: A CGFloat offset for trailing.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
leadingTrailing
(
leading
:
CGFloat
=
0
,
trailing
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
leadingTrailing
,
constants
:
leading
,
-
trailing
)
}
/**
Constraints top and bottom of the view to its parent's.
Constraints top and bottom of the view to its parent's.
- Parameter top: A CGFloat offset for top.
- Parameter top: A CGFloat offset for top.
- Parameter bottom: A CGFloat offset for bottom.
- Parameter bottom: A CGFloat offset for bottom.
...
@@ -321,6 +396,28 @@ public extension Layout {
...
@@ -321,6 +396,28 @@ public extension Layout {
}
}
/**
/**
Constraints leading of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
leading
(
_
anchor
:
LayoutAnchorable
,
_
offset
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
leading
,
to
:
anchor
,
constant
:
offset
)
}
/**
Constraints trailing of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
trailing
(
_
anchor
:
LayoutAnchorable
,
_
offset
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
trailing
,
to
:
anchor
,
constant
:
-
offset
)
}
/**
Constraints bottom of the view to the given anchor.
Constraints bottom of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ offset: A CGFloat offset.
- Parameter _ offset: A CGFloat offset.
...
@@ -332,6 +429,66 @@ public extension Layout {
...
@@ -332,6 +429,66 @@ public extension Layout {
}
}
/**
/**
Constraints top-leading of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter top: A CGFloat offset for top.
- Parameter leading: A CGFloat offset for leading.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
topLeading
(
_
anchor
:
LayoutAnchorable
,
top
:
CGFloat
=
0
,
leading
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
topLeading
,
to
:
anchor
,
constants
:
top
,
leading
)
}
/**
Constraints top-trailing of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter top: A CGFloat offset for top.
- Parameter trailing: A CGFloat offset for trailing.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
topTrailing
(
_
anchor
:
LayoutAnchorable
,
top
:
CGFloat
=
0
,
trailing
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
topTrailing
,
to
:
anchor
,
constants
:
top
,
-
trailing
)
}
/**
Constraints bottom-leading of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter bottom: A CGFloat offset for bottom.
- Parameter leading: A CGFloat offset for leading.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
bottomLeading
(
_
anchor
:
LayoutAnchorable
,
bottom
:
CGFloat
=
0
,
leading
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
bottomLeading
,
to
:
anchor
,
constants
:
-
bottom
,
leading
)
}
/**
Constraints bottom-trailing of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter bottom: A CGFloat offset for bottom.
- Parameter trailing: A CGFloat offset for trailing.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
bottomTrailing
(
_
anchor
:
LayoutAnchorable
,
bottom
:
CGFloat
=
0
,
trailing
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
bottomTrailing
,
to
:
anchor
,
constants
:
-
bottom
,
-
trailing
)
}
/**
Constraints leading and trailing of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter leading: A CGFloat offset for leading.
- Parameter trailing: A CGFloat offset for trailing.
- Returns: A Layout instance to allow chaining.
*/
@discardableResult
func
leadingTrailing
(
_
anchor
:
LayoutAnchorable
,
leading
:
CGFloat
=
0
,
trailing
:
CGFloat
=
0
)
->
Layout
{
return
constraint
(
.
leadingTrailing
,
to
:
anchor
,
constants
:
leading
,
-
trailing
)
}
/**
Constraints top-left of the view to the given anchor.
Constraints top-left of the view to the given anchor.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter _ anchor: A LayoutAnchorable.
- Parameter top: A CGFloat offset for top.
- Parameter top: A CGFloat offset for top.
...
...
Sources/iOS/LayoutAnchor.swift
View file @
4e746a65
...
@@ -76,6 +76,16 @@ public extension LayoutAnchor {
...
@@ -76,6 +76,16 @@ public extension LayoutAnchor {
return
anchor
(
.
right
)
return
anchor
(
.
right
)
}
}
/// A layout anchor representing leading of the view.
var
leading
:
LayoutAnchor
{
return
anchor
(
.
leading
)
}
/// A layout anchor representing trailing of the view.
var
trailing
:
LayoutAnchor
{
return
anchor
(
.
trailing
)
}
/// A layout anchor representing top-left of the view.
/// A layout anchor representing top-left of the view.
var
topLeft
:
LayoutAnchor
{
var
topLeft
:
LayoutAnchor
{
return
acnhor
(
.
topLeft
)
return
acnhor
(
.
topLeft
)
...
@@ -96,6 +106,26 @@ public extension LayoutAnchor {
...
@@ -96,6 +106,26 @@ public extension LayoutAnchor {
return
acnhor
(
.
bottomRight
)
return
acnhor
(
.
bottomRight
)
}
}
/// A layout anchor representing top-leading of the view.
var
topLeading
:
LayoutAnchor
{
return
acnhor
(
.
topLeading
)
}
/// A layout anchor representing top-trailing of the view.
var
topTrailing
:
LayoutAnchor
{
return
acnhor
(
.
topTrailing
)
}
/// A layout anchor representing bottom-leading of the view.
var
bottomLeading
:
LayoutAnchor
{
return
acnhor
(
.
bottomLeading
)
}
/// A layout anchor representing bottom-trailing of the view.
var
bottomTrailing
:
LayoutAnchor
{
return
acnhor
(
.
bottomTrailing
)
}
/// A layout anchor representing top and bottom of the view.
/// A layout anchor representing top and bottom of the view.
var
topBottom
:
LayoutAnchor
{
var
topBottom
:
LayoutAnchor
{
return
acnhor
(
.
topBottom
)
return
acnhor
(
.
topBottom
)
...
@@ -106,6 +136,11 @@ public extension LayoutAnchor {
...
@@ -106,6 +136,11 @@ public extension LayoutAnchor {
return
acnhor
(
.
leftRight
)
return
acnhor
(
.
leftRight
)
}
}
/// A layout anchor representing leading and trailing of the view.
var
leadingTrailing
:
LayoutAnchor
{
return
acnhor
(
.
leadingTrailing
)
}
/// A layout anchor representing center of the view.
/// A layout anchor representing center of the view.
var
center
:
LayoutAnchor
{
var
center
:
LayoutAnchor
{
return
acnhor
(
.
center
)
return
acnhor
(
.
center
)
...
...
Sources/iOS/LayoutAttribute.swift
View file @
4e746a65
...
@@ -59,6 +59,31 @@ internal extension Array where Element == LayoutAttribute {
...
@@ -59,6 +59,31 @@ internal extension Array where Element == LayoutAttribute {
return
[
.
left
,
.
right
]
return
[
.
left
,
.
right
]
}
}
/// A LayoutAttribute array containing top and leading.
static
var
topLeading
:
[
LayoutAttribute
]
{
return
[
.
top
,
.
leading
]
}
/// A LayoutAttribute array containing top and trailing.
static
var
topTrailing
:
[
LayoutAttribute
]
{
return
[
.
top
,
.
trailing
]
}
/// A LayoutAttribute array containing bottom and leading.
static
var
bottomLeading
:
[
LayoutAttribute
]
{
return
[
.
bottom
,
.
leading
]
}
/// A LayoutAttribute array containing bottom and trailing.
static
var
bottomTrailing
:
[
LayoutAttribute
]
{
return
[
.
bottom
,
.
trailing
]
}
/// A LayoutAttribute array containing left and trailing.
static
var
leadingTrailing
:
[
LayoutAttribute
]
{
return
[
.
leading
,
.
trailing
]
}
/// A LayoutAttribute array containing top and bottom.
/// A LayoutAttribute array containing top and bottom.
static
var
topBottom
:
[
LayoutAttribute
]
{
static
var
topBottom
:
[
LayoutAttribute
]
{
return
[
.
top
,
.
bottom
]
return
[
.
top
,
.
bottom
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment