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
112992a8
Commit
112992a8
authored
Aug 16, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated ToolbarController and SearchBarController to accept alignment properties
parent
6fe0628b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
105 additions
and
63 deletions
+105
-63
Material.xcodeproj/project.pbxproj
+0
-0
README.md
+0
-2
Sources/iOS/ImageCard.swift
+0
-6
Sources/iOS/SearchBar.swift
+16
-11
Sources/iOS/SearchBarController.swift
+43
-26
Sources/iOS/StatusBarController.swift
+9
-2
Sources/iOS/ToolbarController.swift
+37
-16
No files found.
Material.xcodeproj/project.pbxproj
View file @
112992a8
This diff is collapsed.
Click to expand it.
README.md
View file @
112992a8
...
@@ -18,8 +18,6 @@ Take a look at a sample [Photos](https://github.com/CosmicMind/Samples/tree/mast
...
@@ -18,8 +18,6 @@ Take a look at a sample [Photos](https://github.com/CosmicMind/Samples/tree/mast


*
[
Photos Sample
](
https://github.com/CosmicMind/Samples/tree/master/Projects/Programmatic/Photos
)
## Sample Projects
## Sample Projects
Take a look at
[
Sample Projects
](
https://github.com/CosmicMind/Samples
)
to get your projects started.
Take a look at
[
Sample Projects
](
https://github.com/CosmicMind/Samples
)
to get your projects started.
...
...
Sources/iOS/ImageCard.swift
View file @
112992a8
...
@@ -30,12 +30,6 @@
...
@@ -30,12 +30,6 @@
import
UIKit
import
UIKit
@objc(ToolbarAlignment)
public
enum
ToolbarAlignment
:
Int
{
case
top
case
bottom
}
open
class
ImageCard
:
Card
{
open
class
ImageCard
:
Card
{
/**
/**
A Display value to indicate whether or not to
A Display value to indicate whether or not to
...
...
Sources/iOS/SearchBar.swift
View file @
112992a8
...
@@ -148,7 +148,7 @@ open class SearchBar: Bar {
...
@@ -148,7 +148,7 @@ open class SearchBar: Bar {
return
return
}
}
textField
.
frame
=
contentView
.
bounds
layoutTextField
()
layoutLeftView
()
layoutLeftView
()
layoutClearButton
()
layoutClearButton
()
}
}
...
@@ -161,10 +161,9 @@ open class SearchBar: Bar {
...
@@ -161,10 +161,9 @@ open class SearchBar: Bar {
}
}
extension
SearchBar
{
extension
SearchBar
{
/// Layout the clearButton.
/// Layout the textField.
open
func
layoutClearButton
()
{
open
func
layoutTextField
()
{
let
h
=
textField
.
frame
.
height
textField
.
frame
=
contentView
.
bounds
clearButton
.
frame
=
CGRect
(
x
:
textField
.
frame
.
width
-
h
-
4
,
y
:
4
,
width
:
h
,
height
:
h
-
8
)
}
}
/// Layout the leftView.
/// Layout the leftView.
...
@@ -178,12 +177,18 @@ extension SearchBar {
...
@@ -178,12 +177,18 @@ extension SearchBar {
(
v
as?
UIImageView
)?
.
contentMode
=
.
scaleAspectFit
(
v
as?
UIImageView
)?
.
contentMode
=
.
scaleAspectFit
}
}
/// Layout the clearButton.
open
func
layoutClearButton
()
{
let
h
=
textField
.
frame
.
height
clearButton
.
frame
=
CGRect
(
x
:
textField
.
frame
.
width
-
h
-
4
,
y
:
4
,
width
:
h
,
height
:
h
-
8
)
}
}
}
extension
SearchBar
{
fileprivate
extension
SearchBar
{
/// Clears the textField text.
/// Clears the textField text.
@objc
@objc
f
ileprivate
f
unc
handleClearButton
()
{
func
handleClearButton
()
{
guard
nil
==
textField
.
delegate
?
.
textFieldShouldClear
||
true
==
textField
.
delegate
?
.
textFieldShouldClear
?(
textField
)
else
{
guard
nil
==
textField
.
delegate
?
.
textFieldShouldClear
||
true
==
textField
.
delegate
?
.
textFieldShouldClear
?(
textField
)
else
{
return
return
}
}
...
@@ -199,14 +204,14 @@ extension SearchBar {
...
@@ -199,14 +204,14 @@ extension SearchBar {
// Live updates the search results.
// Live updates the search results.
@objc
@objc
f
ileprivate
f
unc
handleEditingChanged
(
textField
:
UITextField
)
{
func
handleEditingChanged
(
textField
:
UITextField
)
{
delegate
?
.
searchBar
?(
searchBar
:
self
,
didChange
:
textField
,
with
:
textField
.
text
)
delegate
?
.
searchBar
?(
searchBar
:
self
,
didChange
:
textField
,
with
:
textField
.
text
)
}
}
}
}
extension
SearchBar
{
fileprivate
extension
SearchBar
{
/// Prepares the textField.
/// Prepares the textField.
f
ileprivate
f
unc
prepareTextField
()
{
func
prepareTextField
()
{
textField
.
contentScaleFactor
=
Screen
.
scale
textField
.
contentScaleFactor
=
Screen
.
scale
textField
.
font
=
RobotoFont
.
regular
(
with
:
17
)
textField
.
font
=
RobotoFont
.
regular
(
with
:
17
)
textField
.
backgroundColor
=
Color
.
clear
textField
.
backgroundColor
=
Color
.
clear
...
@@ -219,7 +224,7 @@ extension SearchBar {
...
@@ -219,7 +224,7 @@ extension SearchBar {
}
}
/// Prepares the clearButton.
/// Prepares the clearButton.
f
ileprivate
f
unc
prepareClearButton
()
{
func
prepareClearButton
()
{
clearButton
=
IconButton
(
image
:
Icon
.
cm
.
close
,
tintColor
:
placeholderColor
)
clearButton
=
IconButton
(
image
:
Icon
.
cm
.
close
,
tintColor
:
placeholderColor
)
clearButton
.
contentEdgeInsets
=
.
zero
clearButton
.
contentEdgeInsets
=
.
zero
isClearButtonAutoHandleEnabled
=
true
isClearButtonAutoHandleEnabled
=
true
...
...
Sources/iOS/SearchBarController.swift
View file @
112992a8
...
@@ -61,45 +61,62 @@ open class SearchBarController: StatusBarController {
...
@@ -61,45 +61,62 @@ open class SearchBarController: StatusBarController {
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
layoutSearchBar
()
let
y
=
Application
.
shouldStatusBarBeHidden
||
statusBar
.
isHidden
?
0
:
statusBar
.
height
layoutContainer
()
layoutRootViewController
()
searchBar
.
y
=
y
searchBar
.
width
=
view
.
width
switch
displayStyle
{
case
.
partial
:
let
h
=
y
+
searchBar
.
height
container
.
y
=
h
container
.
height
=
view
.
height
-
h
case
.
full
:
container
.
frame
=
view
.
bounds
}
rootViewController
.
view
.
frame
=
container
.
bounds
}
}
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
displayStyle
=
.
partial
displayStyle
=
.
partial
prepareStatusBar
()
prepareSearchBar
()
prepareSearchBar
()
}
}
}
}
fileprivate
extension
SearchBarController
{
fileprivate
extension
SearchBarController
{
/// Prepares the statusBar.
func
prepareStatusBar
()
{
shouldHideStatusBarOnRotation
=
false
}
/// Prepares the searchBar.
/// Prepares the searchBar.
func
prepareSearchBar
()
{
func
prepareSearchBar
()
{
searchBar
.
depthPreset
=
.
depth1
searchBar
.
zPosition
=
1000
searchBar
.
zPosition
=
1000
searchBar
.
depthPreset
=
.
depth1
view
.
addSubview
(
searchBar
)
view
.
addSubview
(
searchBar
)
}
}
}
}
fileprivate
extension
SearchBarController
{
/// Layout the container.
func
layoutContainer
()
{
switch
displayStyle
{
case
.
partial
:
let
p
=
searchBar
.
height
let
q
=
statusBarOffsetAdjustment
let
h
=
view
.
height
-
p
-
q
switch
searchBarAlignment
{
case
.
top
:
container
.
y
=
q
+
p
container
.
height
=
h
case
.
bottom
:
container
.
y
=
q
container
.
height
=
h
}
container
.
width
=
view
.
width
case
.
full
:
container
.
frame
=
view
.
bounds
}
}
/// Layout the searchBar.
func
layoutSearchBar
()
{
searchBar
.
x
=
0
searchBar
.
y
=
.
top
==
searchBarAlignment
?
statusBarOffsetAdjustment
:
view
.
height
-
searchBar
.
height
searchBar
.
width
=
view
.
width
}
/// Layout the rootViewController.
func
layoutRootViewController
()
{
rootViewController
.
view
.
frame
=
container
.
bounds
}
}
Sources/iOS/StatusBarController.swift
View file @
112992a8
...
@@ -74,8 +74,13 @@ open class StatusBarController: TransitionController {
...
@@ -74,8 +74,13 @@ open class StatusBarController: TransitionController {
}
}
}
}
/// An adjustment based on the rules for displaying the statusBar.
open
var
statusBarOffsetAdjustment
:
CGFloat
{
return
Application
.
shouldStatusBarBeHidden
||
statusBar
.
isHidden
?
0
:
statusBar
.
height
}
/// A boolean that indicates to hide the statusBar on rotation.
/// A boolean that indicates to hide the statusBar on rotation.
open
var
shouldHideStatusBarOnRotation
=
tru
e
open
var
shouldHideStatusBarOnRotation
=
fals
e
/// A reference to the statusBar.
/// A reference to the statusBar.
open
let
statusBar
=
UIView
()
open
let
statusBar
=
UIView
()
...
@@ -99,7 +104,9 @@ open class StatusBarController: TransitionController {
...
@@ -99,7 +104,9 @@ open class StatusBarController: TransitionController {
}
}
rootViewController
.
view
.
frame
=
container
.
bounds
rootViewController
.
view
.
frame
=
container
.
bounds
}
container
.
zPosition
=
statusBar
.
zPosition
+
(
Application
.
shouldStatusBarBeHidden
?
1
:
-
1
)
}
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
...
...
Sources/iOS/ToolbarController.swift
View file @
112992a8
...
@@ -30,6 +30,12 @@
...
@@ -30,6 +30,12 @@
import
UIKit
import
UIKit
@objc(ToolbarAlignment)
public
enum
ToolbarAlignment
:
Int
{
case
top
case
bottom
}
public
extension
UIViewController
{
public
extension
UIViewController
{
/**
/**
A convenience property that provides access to the ToolbarController.
A convenience property that provides access to the ToolbarController.
...
@@ -47,6 +53,13 @@ open class ToolbarController: StatusBarController {
...
@@ -47,6 +53,13 @@ open class ToolbarController: StatusBarController {
@IBInspectable
@IBInspectable
open
let
toolbar
=
Toolbar
()
open
let
toolbar
=
Toolbar
()
/// The toolbar alignment.
open
var
toolbarAlignment
=
ToolbarAlignment
.
top
{
didSet
{
layoutSubviews
()
}
}
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
layoutToolbar
()
layoutToolbar
()
...
@@ -57,44 +70,52 @@ open class ToolbarController: StatusBarController {
...
@@ -57,44 +70,52 @@ open class ToolbarController: StatusBarController {
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
displayStyle
=
.
partial
displayStyle
=
.
partial
prepareStatusBar
()
prepareToolbar
()
prepareToolbar
()
}
}
}
}
fileprivate
extension
ToolbarController
{
fileprivate
extension
ToolbarController
{
/// Prepares the statusBar.
func
prepareStatusBar
()
{
shouldHideStatusBarOnRotation
=
false
}
/// Prepares the toolbar.
/// Prepares the toolbar.
func
prepareToolbar
()
{
func
prepareToolbar
()
{
toolbar
.
zPosition
=
1000
toolbar
.
depthPreset
=
.
depth1
toolbar
.
depthPreset
=
.
depth1
view
.
addSubview
(
toolbar
)
view
.
addSubview
(
toolbar
)
}
}
}
}
fileprivate
extension
ToolbarController
{
fileprivate
extension
ToolbarController
{
/// Layout the toolbar.
func
layoutToolbar
()
{
toolbar
.
y
=
Application
.
shouldStatusBarBeHidden
||
statusBar
.
isHidden
?
0
:
statusBar
.
height
toolbar
.
width
=
view
.
width
}
/// Layout the container.
/// Layout the container.
func
layoutContainer
()
{
func
layoutContainer
()
{
switch
displayStyle
{
switch
displayStyle
{
case
.
partial
:
case
.
partial
:
let
h
=
toolbar
.
y
+
toolbar
.
height
let
p
=
toolbar
.
height
container
.
y
=
h
let
q
=
statusBarOffsetAdjustment
container
.
height
=
view
.
height
-
h
let
h
=
view
.
height
-
p
-
q
switch
toolbarAlignment
{
case
.
top
:
container
.
y
=
q
+
p
container
.
height
=
h
case
.
bottom
:
container
.
y
=
q
container
.
height
=
h
}
container
.
width
=
view
.
width
case
.
full
:
case
.
full
:
container
.
frame
=
view
.
bounds
container
.
frame
=
view
.
bounds
}
}
}
}
/// Layout the toolbar.
func
layoutToolbar
()
{
toolbar
.
x
=
0
toolbar
.
y
=
.
top
==
toolbarAlignment
?
statusBarOffsetAdjustment
:
view
.
height
-
toolbar
.
height
toolbar
.
width
=
view
.
width
}
/// Layout the rootViewController.
/// Layout the rootViewController.
func
layoutRootViewController
()
{
func
layoutRootViewController
()
{
rootViewController
.
view
.
frame
=
container
.
bounds
rootViewController
.
view
.
frame
=
container
.
bounds
...
...
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