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
0c77e6eb
Commit
0c77e6eb
authored
Oct 28, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed layoutables to constraintable
parent
c0675fa4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
28 deletions
+28
-28
Sources/iOS/Layout.swift
+18
-18
Sources/iOS/LayoutAnchor.swift
+8
-8
Sources/iOS/LayoutConstraint.swift
+2
-2
No files found.
Sources/iOS/Layout.swift
View file @
0c77e6eb
...
@@ -32,11 +32,11 @@ import UIKit
...
@@ -32,11 +32,11 @@ import UIKit
import
Motion
import
Motion
/// A protocol that's conformed by UIView and UILayoutGuide.
/// A protocol that's conformed by UIView and UILayoutGuide.
public
protocol
Layou
table
:
class
{
}
public
protocol
Constrain
table
:
class
{
}
@available(iOS 9.0, *)
@available(iOS 9.0, *)
extension
UILayoutGuide
:
Layou
table
{
}
extension
UILayoutGuide
:
Constrain
table
{
}
extension
UIView
:
Layou
table
{
}
extension
UIView
:
Constrain
table
{
}
/// Layout extension for UIView.
/// Layout extension for UIView.
public
extension
UIView
{
public
extension
UIView
{
...
@@ -53,7 +53,7 @@ public extension UIView {
...
@@ -53,7 +53,7 @@ public extension UIView {
/// Layout instance for the view.
/// Layout instance for the view.
var
layout
:
Layout
{
var
layout
:
Layout
{
return
Layout
(
view
:
self
)
return
Layout
(
constraintable
:
self
)
}
}
/**
/**
...
@@ -62,7 +62,7 @@ public extension UIView {
...
@@ -62,7 +62,7 @@ public extension UIView {
*/
*/
var
safeLayout
:
Layout
{
var
safeLayout
:
Layout
{
if
#available(iOS 11.0, *)
{
if
#available(iOS 11.0, *)
{
return
Layout
(
view
:
safeAreaLayoutGuide
)
return
Layout
(
constraintable
:
safeAreaLayoutGuide
)
}
else
{
}
else
{
return
layout
return
layout
}
}
...
@@ -70,20 +70,20 @@ public extension UIView {
...
@@ -70,20 +70,20 @@ public extension UIView {
}
}
public
struct
Layout
{
public
struct
Layout
{
/// A weak reference to the
view
.
/// A weak reference to the
constraintable
.
weak
var
view
:
Layou
table
?
weak
var
constraintable
:
Constrain
table
?
/// Parent view of the view.
/// Parent view of the view.
var
parent
:
UIView
?
{
var
parent
:
UIView
?
{
return
(
view
as?
UIView
)?
.
superview
return
(
constraintable
as?
UIView
)?
.
superview
}
}
/**
/**
An initializer taking
UIView
.
An initializer taking
Constraintable
.
- Parameter view: A
UIView
.
- Parameter view: A
Constraintable
.
*/
*/
init
(
view
:
Layou
table
)
{
init
(
constraintable
:
Constrain
table
)
{
self
.
view
=
view
self
.
constraintable
=
constraintable
}
}
}
}
...
@@ -494,9 +494,9 @@ private extension Layout {
...
@@ -494,9 +494,9 @@ private extension Layout {
if
attributes
==
.
constantHeight
||
attributes
==
.
constantWidth
{
if
attributes
==
.
constantHeight
||
attributes
==
.
constantWidth
{
attributes
.
removeLast
()
attributes
.
removeLast
()
anchor
=
LayoutAnchor
(
view
:
nil
,
attributes
:
[
.
notAnAttribute
])
anchor
=
LayoutAnchor
(
constraintable
:
nil
,
attributes
:
[
.
notAnAttribute
])
}
else
{
}
else
{
anchor
=
LayoutAnchor
(
view
:
parent
,
attributes
:
attributes
)
anchor
=
LayoutAnchor
(
constraintable
:
parent
,
attributes
:
attributes
)
}
}
return
constraint
(
attributes
,
to
:
anchor
,
constants
:
constants
)
return
constraint
(
attributes
,
to
:
anchor
,
constants
:
constants
)
}
}
...
@@ -534,13 +534,13 @@ private extension Layout {
...
@@ -534,13 +534,13 @@ private extension Layout {
- Returns: A Layout instance to allow chaining.
- Returns: A Layout instance to allow chaining.
*/
*/
func
constraint
(
_
attributes
:
[
LayoutAttribute
],
to
anchor
:
LayoutAnchorable
,
constants
:
[
CGFloat
])
->
Layout
{
func
constraint
(
_
attributes
:
[
LayoutAttribute
],
to
anchor
:
LayoutAnchorable
,
constants
:
[
CGFloat
])
->
Layout
{
let
from
=
LayoutAnchor
(
view
:
view
,
attributes
:
attributes
)
let
from
=
LayoutAnchor
(
constraintable
:
constraintable
,
attributes
:
attributes
)
let
to
=
anchor
as?
LayoutAnchor
??
LayoutAnchor
(
view
:
(
anchor
as?
UIView
)
??
(
anchor
as?
Layout
)?
.
view
,
attributes
:
attributes
)
let
to
=
anchor
as?
LayoutAnchor
??
LayoutAnchor
(
constraintable
:
(
anchor
as?
UIView
)
??
(
anchor
as?
Layout
)?
.
constraintable
,
attributes
:
attributes
)
let
constraint
=
LayoutConstraint
(
fromAnchor
:
from
,
toAnchor
:
to
,
constants
:
constants
)
let
constraint
=
LayoutConstraint
(
fromAnchor
:
from
,
toAnchor
:
to
,
constants
:
constants
)
var
v
=
view
as?
UIView
var
v
=
constraintable
as?
UIView
if
#available(iOS 9.0, *)
,
v
==
nil
{
if
#available(iOS 9.0, *)
,
v
==
nil
{
v
=
(
view
as?
UILayoutGuide
)?
.
owningView
v
=
(
constraintable
as?
UILayoutGuide
)?
.
owningView
}
}
let
constraints
=
(
v
?
.
constraints
??
[])
+
(
v
?
.
superview
?
.
constraints
??
[])
let
constraints
=
(
v
?
.
constraints
??
[])
+
(
v
?
.
superview
?
.
constraints
??
[])
...
...
Sources/iOS/LayoutAnchor.swift
View file @
0c77e6eb
...
@@ -38,19 +38,19 @@ extension Layout: LayoutAnchorable { }
...
@@ -38,19 +38,19 @@ extension Layout: LayoutAnchorable { }
extension
LayoutAnchor
:
LayoutAnchorable
{
}
extension
LayoutAnchor
:
LayoutAnchorable
{
}
public
struct
LayoutAnchor
{
public
struct
LayoutAnchor
{
/// A weak reference to the
view
.
/// A weak reference to the
constraintable
.
weak
var
view
:
Layou
table
?
weak
var
constraintable
:
Constrain
table
?
/// An array of LayoutAttribute for the view.
/// An array of LayoutAttribute for the view.
let
attributes
:
[
LayoutAttribute
]
let
attributes
:
[
LayoutAttribute
]
/**
/**
An initializer taking
view
and anchor attributes.
An initializer taking
constraintable
and anchor attributes.
- Parameter view: A
UIView
.
- Parameter view: A
Constraintable
.
- Parameter attributes: An array of LayoutAtrribute.
- Parameter attributes: An array of LayoutAtrribute.
*/
*/
init
(
view
:
Layou
table
?,
attributes
:
[
LayoutAttribute
])
{
init
(
constraintable
:
Constrain
table
?,
attributes
:
[
LayoutAttribute
])
{
self
.
view
=
view
self
.
constraintable
=
constraintable
self
.
attributes
=
attributes
self
.
attributes
=
attributes
}
}
}
}
...
@@ -143,7 +143,7 @@ private extension Layout {
...
@@ -143,7 +143,7 @@ private extension Layout {
- Returns: A LayoutAnchor.
- Returns: A LayoutAnchor.
*/
*/
func
anchor
(
_
attribute
:
LayoutAttribute
)
->
LayoutAnchor
{
func
anchor
(
_
attribute
:
LayoutAttribute
)
->
LayoutAnchor
{
return
LayoutAnchor
(
view
:
view
,
attributes
:
[
attribute
])
return
LayoutAnchor
(
constraintable
:
constraintable
,
attributes
:
[
attribute
])
}
}
/**
/**
...
@@ -152,6 +152,6 @@ private extension Layout {
...
@@ -152,6 +152,6 @@ private extension Layout {
- Returns: A LayoutAnchor.
- Returns: A LayoutAnchor.
*/
*/
func
acnhor
(
_
attributes
:
[
LayoutAttribute
])
->
LayoutAnchor
{
func
acnhor
(
_
attributes
:
[
LayoutAttribute
])
->
LayoutAnchor
{
return
LayoutAnchor
(
view
:
view
,
attributes
:
attributes
)
return
LayoutAnchor
(
constraintable
:
constraintable
,
attributes
:
attributes
)
}
}
}
}
Sources/iOS/LayoutConstraint.swift
View file @
0c77e6eb
...
@@ -67,10 +67,10 @@ internal extension LayoutConstraint {
...
@@ -67,10 +67,10 @@ internal extension LayoutConstraint {
var
v
:
[
NSLayoutConstraint
]
=
[]
var
v
:
[
NSLayoutConstraint
]
=
[]
zip
(
zip
(
fromAnchor
.
attributes
,
toAnchor
.
attributes
),
constants
)
.
forEach
{
zip
(
zip
(
fromAnchor
.
attributes
,
toAnchor
.
attributes
),
constants
)
.
forEach
{
v
.
append
(
NSLayoutConstraint
(
item
:
fromAnchor
.
view
as
Any
,
v
.
append
(
NSLayoutConstraint
(
item
:
fromAnchor
.
constraintable
as
Any
,
attribute
:
$0
.
0
,
attribute
:
$0
.
0
,
relatedBy
:
.
equal
,
relatedBy
:
.
equal
,
toItem
:
toAnchor
.
view
,
toItem
:
toAnchor
.
constraintable
,
attribute
:
$0
.
1
,
attribute
:
$0
.
1
,
multiplier
:
1
,
multiplier
:
1
,
constant
:
$1
))
constant
:
$1
))
...
...
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