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
e1fd6014
Unverified
Commit
e1fd6014
authored
Aug 28, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated base SnackbarController
parent
cdc171a1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
189 additions
and
6 deletions
+189
-6
Material.xcodeproj/project.pbxproj
+4
-0
Sources/iOS/PageTabBarController.swift
+2
-2
Sources/iOS/RootController.swift
+2
-1
Sources/iOS/SearchBarController.swift
+1
-1
Sources/iOS/Snackbar.swift
+60
-1
Sources/iOS/SnackbarController.swift
+119
-0
Sources/iOS/ToolbarController.swift
+1
-1
No files found.
Material.xcodeproj/project.pbxproj
View file @
e1fd6014
...
...
@@ -7,6 +7,7 @@
objects
=
{
/* Begin PBXBuildFile section */
961EFC581D738FF600E84652
/* SnackbarController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961EFC571D738FF600E84652
/* SnackbarController.swift */
;
};
961F18E81CD93E3E008927C5
/* ErrorTextField.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961F18E71CD93E3E008927C5
/* ErrorTextField.swift */
;
};
96230AB81D6A520C00AF47DC
/* Divider.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96230AB71D6A520C00AF47DC
/* Divider.swift */
;
};
9628645A1D53FE3E00690B69
/* Material+UIWindow.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
962864591D53FE3E00690B69
/* Material+UIWindow.swift */
;
};
...
...
@@ -199,6 +200,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
961EFC571D738FF600E84652
/* SnackbarController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SnackbarController.swift
;
sourceTree
=
"<group>"
;
};
961F18E71CD93E3E008927C5
/* ErrorTextField.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ErrorTextField.swift
;
sourceTree
=
"<group>"
;
};
96230AB71D6A520C00AF47DC
/* Divider.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Divider.swift
;
sourceTree
=
"<group>"
;
};
962864591D53FE3E00690B69
/* Material+UIWindow.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIWindow.swift"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -407,6 +409,7 @@
isa
=
PBXGroup
;
children
=
(
963FBEFC1D669510008F8512
/* Snackbar.swift */
,
961EFC571D738FF600E84652
/* SnackbarController.swift */
,
);
name
=
Snackbar
;
sourceTree
=
"<group>"
;
...
...
@@ -1096,6 +1099,7 @@
96BCB7DB1CB40DC500C806FE
/* NavigationItem.swift in Sources */
,
96BCB7E01CB40DC500C806FE
/* NavigationDrawerController.swift in Sources */
,
9628645F1D540AF300690B69
/* DynamicFontType.swift in Sources */
,
961EFC581D738FF600E84652
/* SnackbarController.swift in Sources */
,
96BCB7AD1CB40DC500C806FE
/* Material+String.swift in Sources */
,
96BCB7A51CB40DC500C806FE
/* Capture.swift in Sources */
,
96BCB7B91CB40DC500C806FE
/* Button.swift in Sources */
,
...
...
Sources/iOS/PageTabBarController.swift
View file @
e1fd6014
...
...
@@ -113,7 +113,7 @@ open class PageTabBarController: RootController {
open
internal(set)
var
pageTabBar
:
PageTabBar
!
/// Delegation handler.
public
weak
var
delegate
:
PageTabBarControllerDelegate
?
open
weak
var
delegate
:
PageTabBarControllerDelegate
?
/// A reference to the instance when it is a UIPageViewController.
open
var
pageViewController
:
UIPageViewController
?
{
...
...
@@ -151,8 +151,8 @@ open class PageTabBarController: RootController {
return
}
let
h
=
view
.
height
let
w
=
view
.
width
let
h
=
view
.
height
let
p
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layoutEdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
let
y
=
h
-
p
...
...
Sources/iOS/RootController.swift
View file @
e1fd6014
...
...
@@ -153,7 +153,8 @@ open class RootController: UIViewController {
open
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
Device
.
scale
prepareRootViewController
()
edgesForExtendedLayout
=
[]
prepareRootViewController
()
}
/// A method that prepares the rootViewController.
...
...
Sources/iOS/SearchBarController.swift
View file @
e1fd6014
...
...
@@ -65,8 +65,8 @@ open class SearchBarController: RootController {
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
let
h
=
view
.
height
let
w
=
view
.
width
let
h
=
view
.
height
let
p
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layoutEdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
v
.
width
=
w
+
v
.
grid
.
layoutEdgeInsets
.
left
+
v
.
grid
.
layoutEdgeInsets
.
right
...
...
Sources/iOS/Snackbar.swift
View file @
e1fd6014
...
...
@@ -30,6 +30,65 @@
import
UIKit
public
class
Snackbar
:
BarView
{
@objc(SnackbarDelegate)
public
protocol
SnackbarDelegate
{
/**
A delegation method that is executed when a Snackbar will show.
- Parameter snackbar: A Snackbar.
*/
@objc
optional
func
snackbarWillShow
(
snackbar
:
Snackbar
)
/**
A delegation method that is executed when a Snackbar did show.
- Parameter snackbar: A Snackbar.
*/
@objc
optional
func
snackbarDidShow
(
snackbar
:
Snackbar
)
/**
A delegation method that is executed when a Snackbar will hide.
- Parameter snackbar: A Snackbar.
*/
@objc
optional
func
snackbarWillHide
(
snackbar
:
Snackbar
)
/**
A delegation method that is executed when a Snackbar did hide.
- Parameter snackbar: A Snackbar.
*/
@objc
optional
func
snackbarDidHide
(
snackbar
:
Snackbar
)
}
@objc(SnackbarStatus)
public
enum
SnackbarStatus
:
Int
{
case
visible
case
notVisible
case
animating
}
@objc(Snackbar)
open
class
Snackbar
:
BarView
{
/// Delegation handler.
open
weak
var
delegate
:
SnackbarDelegate
?
open
override
var
intrinsicContentSize
:
CGSize
{
return
CGSize
(
width
:
width
,
height
:
48
)
}
/// The status of the snackbar.
open
internal(set)
var
status
=
SnackbarStatus
.
visible
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
open
override
func
prepareView
()
{
super
.
prepareView
()
backgroundColor
=
Color
.
grey
.
darken4
}
}
Sources/iOS/SnackbarController.swift
0 → 100644
View file @
e1fd6014
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
extension
UIViewController
{
/**
A convenience property that provides access to the SnackbarController.
This is the recommended method of accessing the SnackbarController
through child UIViewControllers.
*/
public
var
snackbarController
:
SnackbarController
?
{
var
viewController
:
UIViewController
?
=
self
while
nil
!=
viewController
{
if
viewController
is
SnackbarController
{
return
viewController
as?
SnackbarController
}
viewController
=
viewController
?
.
parent
}
return
nil
}
}
open
class
SnackbarController
:
RootController
{
/**
A boolean that indicates whether to move the view controller
when the Snackbar animates.
*/
open
var
isSnackbarAttachedToController
=
false
/// Reference to the Snackbar.
open
internal(set)
var
snackbar
:
Snackbar
!
/**
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
have a certain need.
*/
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
guard
let
v
=
snackbar
else
{
return
}
let
w
=
view
.
width
let
h
=
view
.
height
let
p
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layoutEdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
v
.
width
=
w
v
.
height
=
p
rootViewController
.
view
.
x
=
0
rootViewController
.
view
.
y
=
0
rootViewController
.
view
.
width
=
w
switch
v
.
status
{
case
.
visible
:
let
y
=
h
-
p
v
.
y
=
y
v
.
isHidden
=
false
rootViewController
.
view
.
height
=
y
case
.
notVisible
:
v
.
y
=
h
v
.
isHidden
=
true
rootViewController
.
view
.
height
=
h
case
.
animating
:
break
}
v
.
divider
.
reload
()
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
open
override
func
prepareView
()
{
super
.
prepareView
()
prepareSnackbar
()
}
/// Prepares the snackbar.
private
func
prepareSnackbar
()
{
if
nil
==
snackbar
{
snackbar
=
Snackbar
()
snackbar
.
zPosition
=
10000
view
.
addSubview
(
snackbar
)
}
}
}
Sources/iOS/ToolbarController.swift
View file @
e1fd6014
...
...
@@ -168,8 +168,8 @@ open class ToolbarController: RootController {
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
let
h
=
view
.
height
let
w
=
view
.
width
let
h
=
view
.
height
let
p
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layoutEdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
v
.
width
=
w
+
v
.
grid
.
layoutEdgeInsets
.
left
+
v
.
grid
.
layoutEdgeInsets
.
right
...
...
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