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
3ff98d5a
Unverified
Commit
3ff98d5a
authored
Sep 03, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: reducing code complexity with BarViews
parent
39e54828
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
22 additions
and
82 deletions
+22
-82
Sources/iOS/BarView.swift
+7
-0
Sources/iOS/ControlView.swift
+0
-2
Sources/iOS/Grid.swift
+0
-2
Sources/iOS/Layout.swift
+1
-1
Sources/iOS/PageTabBarController.swift
+0
-2
Sources/iOS/SearchBarController.swift
+0
-2
Sources/iOS/Snackbar.swift
+10
-3
Sources/iOS/SnackbarController.swift
+3
-18
Sources/iOS/TabBar.swift
+1
-50
Sources/iOS/ToolbarController.swift
+0
-2
No files found.
Sources/iOS/BarView.swift
View file @
3ff98d5a
...
...
@@ -61,6 +61,13 @@ open class BarView: ControlView {
super
.
init
(
leftControls
:
leftControls
,
rightControls
:
rightControls
)
}
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
willRenderView
{
divider
.
reload
()
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
...
...
Sources/iOS/ControlView.swift
View file @
3ff98d5a
...
...
@@ -162,8 +162,6 @@ open class ControlView: View {
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
willRenderView
{
layoutIfNeeded
()
var
lc
=
0
var
rc
=
0
let
l
=
(
CGFloat
(
leftControls
.
count
)
*
interimSpace
)
...
...
Sources/iOS/Grid.swift
View file @
3ff98d5a
...
...
@@ -222,8 +222,6 @@ public class Grid {
return
}
canvas
.
layoutIfNeeded
()
if
canvas
!=
child
.
superview
{
child
.
removeFromSuperview
()
canvas
.
addSubview
(
child
)
...
...
Sources/iOS/Layout.swift
View file @
3ff98d5a
...
...
@@ -854,7 +854,7 @@ extension Layout {
- Parameter views: A Dictionary<String, Any> of view key / value pairs.
- Returns: The Array<NSLayoutConstraint> instance.
*/
public
class
func
constraint
(
format
:
String
,
options
:
NSLayoutFormatOptions
,
metrics
:
Dictionary
<
String
,
Any
>
?,
views
:
Dictionary
<
String
,
Any
>
)
->
[
NSLayoutConstraint
]
{
public
class
func
constraint
(
format
:
String
,
options
:
NSLayoutFormatOptions
,
metrics
:
[
String
:
Any
]?,
views
:
[
String
:
Any
]
)
->
[
NSLayoutConstraint
]
{
for
(
_
,
a
)
in
views
{
if
let
v
=
a
as?
UIView
{
v
.
translatesAutoresizingMaskIntoConstraints
=
false
...
...
Sources/iOS/PageTabBarController.swift
View file @
3ff98d5a
...
...
@@ -164,8 +164,6 @@ open class PageTabBarController: RootController {
pageTabBar
.
y
=
y
rootViewController
.
view
.
y
=
0
}
pageTabBar
.
divider
.
reload
()
}
/**
...
...
Sources/iOS/SearchBarController.swift
View file @
3ff98d5a
...
...
@@ -69,8 +69,6 @@ open class SearchBarController: RootController {
rootViewController
.
view
.
y
=
p
rootViewController
.
view
.
height
=
view
.
height
-
p
searchBar
.
divider
.
reload
()
}
/**
...
...
Sources/iOS/Snackbar.swift
View file @
3ff98d5a
...
...
@@ -77,6 +77,14 @@ open class Snackbar: BarView {
return
super
.
hitTest
(
point
,
with
:
event
)
}
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
willRenderView
{
print
(
"RENDING"
,
contentView
)
textLabel
.
frame
=
contentView
.
bounds
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
...
...
@@ -103,8 +111,7 @@ open class Snackbar: BarView {
textLabel
.
textColor
=
Color
.
white
textLabel
.
numberOfLines
=
0
contentView
.
grid
.
deferred
=
true
contentView
.
grid
.
views
.
append
(
textLabel
)
contentView
.
grid
.
deferred
=
false
contentView
.
backgroundColor
=
Color
.
green
.
base
contentView
.
addSubview
(
textLabel
)
}
}
Sources/iOS/SnackbarController.swift
View file @
3ff98d5a
...
...
@@ -156,8 +156,9 @@ open class SnackbarController: RootController {
return
}
snackbar
.
width
=
view
.
width
snackbar
.
height
=
snackbar
.
intrinsicContentSize
.
height
+
snackbar
.
grid
.
layoutEdgeInsets
.
top
+
snackbar
.
grid
.
layoutEdgeInsets
.
bottom
layoutSnackbar
(
status
:
snackbar
.
status
)
layoutRootViewController
(
status
:
snackbar
.
status
)
}
/**
...
...
@@ -183,26 +184,10 @@ open class SnackbarController: RootController {
- Parameter status: A SnackbarStatus enum value.
*/
private
func
layoutSnackbar
(
status
:
SnackbarStatus
)
{
let
p
=
snackbar
.
intrinsicContentSize
.
height
+
snackbar
.
grid
.
layoutEdgeInsets
.
top
+
snackbar
.
grid
.
layoutEdgeInsets
.
bottom
snackbar
.
width
=
view
.
width
snackbar
.
height
=
p
if
.
bottom
==
snackbarAlignment
{
snackbar
.
y
=
.
visible
==
status
?
view
.
height
-
p
:
view
.
height
snackbar
.
y
=
.
visible
==
status
?
view
.
height
-
snackbar
.
height
:
view
.
height
}
else
{
snackbar
.
y
=
.
visible
==
status
?
0
:
-
snackbar
.
height
}
snackbar
.
divider
.
reload
()
}
/**
Lays out the rootViewController.
- Parameter status: A SnackbarStatus enum value.
*/
private
func
layoutRootViewController
(
status
:
SnackbarStatus
)
{
guard
let
vc
=
rootViewController
else
{
return
}
vc
.
view
.
frame
=
view
.
bounds
}
}
Sources/iOS/TabBar.swift
View file @
3ff98d5a
...
...
@@ -57,54 +57,10 @@ public protocol TabBarDelegate {
optional
func
tabBarDidSelectButton
(
tabBar
:
TabBar
,
button
:
UIButton
)
}
open
class
TabBar
:
View
{
open
class
TabBar
:
Bar
View
{
/// A boolean indicating if the TabBar line is in an animation state.
open
internal(set)
var
isAnimating
=
false
/// Will render the view.
open
var
willRenderView
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
}
/// A preset wrapper around contentInset.
open
var
contentEdgeInsetsPreset
:
EdgeInsetsPreset
{
get
{
return
grid
.
contentEdgeInsetsPreset
}
set
(
value
)
{
grid
.
contentEdgeInsetsPreset
=
value
}
}
/// A wrapper around grid.contentInset.
@IBInspectable
open
var
contentInset
:
EdgeInsets
{
get
{
return
grid
.
contentEdgeInsets
}
set
(
value
)
{
grid
.
contentEdgeInsets
=
value
}
}
/// A preset wrapper around interimSpace.
open
var
interimSpacePreset
=
InterimSpacePreset
.
none
{
didSet
{
interimSpace
=
InterimSpacePresetToValue
(
preset
:
interimSpacePreset
)
}
}
/// A wrapper around grid.interimSpace.
@IBInspectable
open
var
interimSpace
:
InterimSpace
{
get
{
return
grid
.
interimSpace
}
set
(
value
)
{
grid
.
interimSpace
=
value
}
}
/// A delegation reference.
open
weak
var
delegate
:
TabBarDelegate
?
...
...
@@ -171,9 +127,6 @@ open class TabBar: View {
}
}
/// Layer Reference.
open
internal(set)
var
divider
:
Divider
!
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
willRenderView
{
...
...
@@ -195,7 +148,6 @@ open class TabBar: View {
line
.
frame
=
CGRect
(
x
:
selected
!.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
:
0
,
width
:
selected
!.
width
,
height
:
lineHeight
)
}
divider
.
reload
()
}
}
...
...
@@ -268,7 +220,6 @@ open class TabBar: View {
/// Prepares the divider.
private
func
prepareDivider
()
{
divider
=
Divider
(
view
:
self
)
divider
.
alignment
=
.
top
}
...
...
Sources/iOS/ToolbarController.swift
View file @
3ff98d5a
...
...
@@ -172,8 +172,6 @@ open class ToolbarController: RootController {
rootViewController
.
view
.
y
=
p
rootViewController
.
view
.
height
=
view
.
height
-
p
toolbar
.
divider
.
reload
()
}
/**
...
...
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