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
5d6f18d7
Commit
5d6f18d7
authored
Aug 02, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated calculations for TabBar and Chips scroll view content
parent
a921f765
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
151 additions
and
38 deletions
+151
-38
Material.xcodeproj/project.pbxproj
+4
-4
Sources/Frameworks/Motion
+1
-1
Sources/iOS/Chips.swift
+83
-21
Sources/iOS/TabBar.swift
+63
-12
No files found.
Material.xcodeproj/project.pbxproj
View file @
5d6f18d7
...
...
@@ -7,7 +7,7 @@
objects
=
{
/* Begin PBXBuildFile section */
961154CC1F32A7B100A78D74
/* Chip
Bar.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961154CB1F32A7B100A78D74
/* ChipBar
.swift */
;
};
961154CC1F32A7B100A78D74
/* Chip
s.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961154CB1F32A7B100A78D74
/* Chips
.swift */
;
};
961409B11E43D15C00E7BA99
/* FABMenu.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96A183621E0C6CE200083C30
/* FABMenu.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
961409B21E43D15C00E7BA99
/* FABMenuController.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96A183641E0C6DD400083C30
/* FABMenuController.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9617B07D1DFCA8CF00410F8F
/* Application.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961E6BDE1DDA2A95004E6C93
/* Application.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
...
@@ -207,7 +207,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
961154CB1F32A7B100A78D74
/* Chip
Bar.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ChipBar
.swift
;
sourceTree
=
"<group>"
;
};
961154CB1F32A7B100A78D74
/* Chip
s.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Chips
.swift
;
sourceTree
=
"<group>"
;
};
961276621DCD8B1800A7D920
/* CharacterAttribute.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CharacterAttribute.swift
;
sourceTree
=
"<group>"
;
};
961E6BDE1DDA2A95004E6C93
/* Application.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Application.swift
;
sourceTree
=
"<group>"
;
};
961E6BE11DDA2AF3004E6C93
/* Screen.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Screen.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -359,7 +359,7 @@
961154CA1F32999000A78D74
/* Chip */
=
{
isa
=
PBXGroup
;
children
=
(
961154CB1F32A7B100A78D74
/* Chip
Bar
.swift */
,
961154CB1F32A7B100A78D74
/* Chip
s
.swift */
,
);
name
=
Chip
;
sourceTree
=
"<group>"
;
...
...
@@ -1069,7 +1069,7 @@
96A1808B1F2E2B6E006BD69D
/* Motion+UIView.swift in Sources */
,
96A180971F2E2B6E006BD69D
/* MotionCoordinateSpace.swift in Sources */
,
96E09DC81F2287E50000B121
/* TabsController.swift in Sources */
,
961154CC1F32A7B100A78D74
/* Chip
Bar
.swift in Sources */
,
961154CC1F32A7B100A78D74
/* Chip
s
.swift in Sources */
,
965689611F002F4C001C656D
/* CardCollectionViewController.swift in Sources */
,
96A180951F2E2B6E006BD69D
/* MotionContext.swift in Sources */
,
965E80CC1DD4C50600D61E4B
/* Bar.swift in Sources */
,
...
...
Motion
@
978902d9
Subproject commit
c23972be3063b528465540282d7b5dcb6d0dcc2d
Subproject commit
978902d9dd00b123794cf1b939790aafc04c4e5f
Sources/iOS/Chip
Bar
.swift
→
Sources/iOS/Chip
s
.swift
View file @
5d6f18d7
...
...
@@ -84,36 +84,36 @@ fileprivate extension ChipItem {
}
}
@objc(Chip
Bar
Delegate)
public
protocol
Chip
Bar
Delegate
{
@objc(Chip
s
Delegate)
public
protocol
Chip
s
Delegate
{
/**
A delegation method that is executed when the chipItem will trigger the
animation to the next chip.
- Parameter chipBar: A Chip
Bar
.
- Parameter chipBar: A Chip
s
.
- Parameter chipItem: A ChipItem.
*/
@objc
optional
func
chipBar
(
chipBar
:
Chip
Bar
,
willSelect
chipItem
:
ChipItem
)
optional
func
chipBar
(
chipBar
:
Chip
s
,
willSelect
chipItem
:
ChipItem
)
/**
A delegation method that is executed when the chipItem did complete the
animation to the next chip.
- Parameter chipBar: A Chip
Bar
.
- Parameter chipBar: A Chip
s
.
- Parameter chipItem: A ChipItem.
*/
@objc
optional
func
chipBar
(
chipBar
:
Chip
Bar
,
didSelect
chipItem
:
ChipItem
)
optional
func
chipBar
(
chipBar
:
Chip
s
,
didSelect
chipItem
:
ChipItem
)
}
@objc(Chip
Bar
Style)
public
enum
Chip
Bar
Style
:
Int
{
@objc(Chip
s
Style)
public
enum
Chip
s
Style
:
Int
{
case
auto
case
nonScrollable
case
scrollable
}
open
class
Chip
Bar
:
Bar
{
/// A boolean indicating if the Chip
Bar
line is in an animation state.
open
class
Chip
s
:
Bar
{
/// A boolean indicating if the Chip
s
line is in an animation state.
open
fileprivate
(
set
)
var
isAnimating
=
false
/// The total width of the chipItems.
...
...
@@ -128,7 +128,7 @@ open class ChipBar: Bar {
}
/// An enum that determines the chip bar style.
open
var
chipBarStyle
=
Chip
Bar
Style
.
auto
{
open
var
chipBarStyle
=
Chip
s
Style
.
auto
{
didSet
{
layoutSubviews
()
}
...
...
@@ -148,11 +148,53 @@ open class ChipBar: Bar {
}
/// A delegation reference.
open
weak
var
delegate
:
Chip
Bar
Delegate
?
open
weak
var
delegate
:
Chip
s
Delegate
?
/// The currently selected chipItem.
open
fileprivate
(
set
)
var
selected
:
ChipItem
?
/// A preset wrapper around chipItems contentEdgeInsets.
open
var
chipItemsContentEdgeInsetsPreset
:
EdgeInsetsPreset
{
get
{
return
scrollView
.
grid
.
contentEdgeInsetsPreset
}
set
(
value
)
{
scrollView
.
grid
.
contentEdgeInsetsPreset
=
value
}
}
/// A reference to EdgeInsets.
@IBInspectable
open
var
chipItemsContentEdgeInsets
:
EdgeInsets
{
get
{
return
scrollView
.
grid
.
contentEdgeInsets
}
set
(
value
)
{
scrollView
.
grid
.
contentEdgeInsets
=
value
}
}
/// A preset wrapper around chipItems interimSpace.
open
var
chipItemsInterimSpacePreset
:
InterimSpacePreset
{
get
{
return
scrollView
.
grid
.
interimSpacePreset
}
set
(
value
)
{
scrollView
.
grid
.
interimSpacePreset
=
value
}
}
/// A wrapper around chipItems interimSpace.
@IBInspectable
open
var
chipItemsInterimSpace
:
InterimSpace
{
get
{
return
scrollView
.
grid
.
interimSpace
}
set
(
value
)
{
scrollView
.
grid
.
interimSpace
=
value
}
}
/// Buttons.
open
var
chipItems
=
[
ChipItem
]()
{
didSet
{
...
...
@@ -243,13 +285,17 @@ open class ChipBar: Bar {
grid
.
axis
.
columns
=
columns
if
.
scrollable
==
chipBarStyle
||
(
.
auto
==
chipBarStyle
&&
chipItemsTotalWidth
>
bounds
.
width
)
{
var
w
:
CGFloat
=
0
var
w
:
CGFloat
=
chipItemsContentEdgeInsets
.
left
let
q
=
2
*
chipItemsInterimSpace
let
p
=
q
+
chipItemsInterimSpace
for
v
in
chipItems
{
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
v
.
height
=
scrollView
.
height
v
.
width
=
x
v
.
width
=
x
+
q
v
.
x
=
w
w
+=
x
w
+=
p
if
scrollView
!=
v
.
superview
{
v
.
removeFromSuperview
()
...
...
@@ -257,11 +303,13 @@ open class ChipBar: Bar {
}
}
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
w
+=
chipItemsContentEdgeInsets
.
right
-
chipItemsInterimSpace
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
scrollView
.
height
-
chipItemsContentEdgeInsets
.
top
-
chipItemsContentEdgeInsets
.
bottom
)
}
else
{
scrollView
.
grid
.
views
=
chipItems
scrollView
.
grid
.
axis
.
columns
=
chipItems
.
count
scrollView
.
contentSize
=
CGSize
(
width
:
scrollView
.
width
,
height
:
height
)
scrollView
.
contentSize
=
CGSize
(
width
:
scrollView
.
width
,
height
:
scrollView
.
height
-
chipItemsContentEdgeInsets
.
top
-
chipItemsContentEdgeInsets
.
bottom
)
}
grid
.
commit
()
...
...
@@ -272,8 +320,9 @@ open class ChipBar: Bar {
open
override
func
prepare
()
{
super
.
prepare
()
contentEdgeInsetsPreset
=
.
none
contentEdgeInsetsPreset
=
.
square2
interimSpacePreset
=
.
interimSpace6
chipItemsInterimSpacePreset
=
.
interimSpace4
prepareContentView
()
prepareScrollView
()
...
...
@@ -281,7 +330,7 @@ open class ChipBar: Bar {
}
}
fileprivate
extension
Chip
Bar
{
fileprivate
extension
Chip
s
{
/// Prepares the divider.
func
prepareDivider
()
{
dividerColor
=
Color
.
grey
.
lighten3
...
...
@@ -293,6 +342,9 @@ fileprivate extension ChipBar {
v
.
grid
.
columns
=
0
v
.
cornerRadius
=
0
v
.
contentEdgeInsets
=
.
zero
v
.
removeTarget
(
self
,
action
:
#selector(
handle(chipItem:)
)
,
for
:
.
touchUpInside
)
v
.
addTarget
(
self
,
action
:
#selector(
handle(chipItem:)
)
,
for
:
.
touchUpInside
)
}
}
...
...
@@ -310,7 +362,15 @@ fileprivate extension ChipBar {
}
}
extension
ChipBar
{
fileprivate
extension
Chips
{
/// Handles the chipItem touch event.
@objc
func
handle
(
chipItem
:
ChipItem
)
{
animate
(
to
:
chipItem
,
isTriggeredByUserInteraction
:
true
)
}
}
extension
Chips
{
/**
Selects a given index from the chipItems array.
- Parameter at index: An Int.
...
...
@@ -331,7 +391,9 @@ extension ChipBar {
open
func
animate
(
to
chipItem
:
ChipItem
,
completion
:
((
ChipItem
)
->
Void
)?
=
nil
)
{
animate
(
to
:
chipItem
,
isTriggeredByUserInteraction
:
false
,
completion
:
completion
)
}
}
fileprivate
extension
Chips
{
/**
Animates to a given chipItem.
- Parameter to chipItem: A ChipItem.
...
...
Sources/iOS/TabBar.swift
View file @
5d6f18d7
...
...
@@ -111,7 +111,49 @@ open class TabBar: Bar {
/// The currently selected tabItem.
open
fileprivate
(
set
)
var
selected
:
TabItem
?
/// A preset wrapper around tabItems contentEdgeInsets.
open
var
tabItemsContentEdgeInsetsPreset
:
EdgeInsetsPreset
{
get
{
return
scrollView
.
grid
.
contentEdgeInsetsPreset
}
set
(
value
)
{
scrollView
.
grid
.
contentEdgeInsetsPreset
=
value
}
}
/// A reference to EdgeInsets.
@IBInspectable
open
var
tabItemsContentEdgeInsets
:
EdgeInsets
{
get
{
return
scrollView
.
grid
.
contentEdgeInsets
}
set
(
value
)
{
scrollView
.
grid
.
contentEdgeInsets
=
value
}
}
/// A preset wrapper around tabItems interimSpace.
open
var
tabItemsInterimSpacePreset
:
InterimSpacePreset
{
get
{
return
scrollView
.
grid
.
interimSpacePreset
}
set
(
value
)
{
scrollView
.
grid
.
interimSpacePreset
=
value
}
}
/// A wrapper around tabItems interimSpace.
@IBInspectable
open
var
tabItemsInterimSpace
:
InterimSpace
{
get
{
return
scrollView
.
grid
.
interimSpace
}
set
(
value
)
{
scrollView
.
grid
.
interimSpace
=
value
}
}
/// TabItems.
open
var
tabItems
=
[
TabItem
]()
{
didSet
{
...
...
@@ -246,13 +288,17 @@ open class TabBar: Bar {
grid
.
axis
.
columns
=
columns
if
.
scrollable
==
tabBarStyle
||
(
.
auto
==
tabBarStyle
&&
tabItemsTotalWidth
>
bounds
.
width
)
{
var
w
:
CGFloat
=
0
var
w
:
CGFloat
=
tabItemsContentEdgeInsets
.
left
let
q
=
scrollView
.
height
/
2
let
p
=
q
+
tabItemsInterimSpace
for
v
in
tabItems
{
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
v
.
height
=
scrollView
.
height
v
.
width
=
x
v
.
width
=
x
+
q
v
.
x
=
w
w
+=
x
w
+=
p
if
scrollView
!=
v
.
superview
{
v
.
removeFromSuperview
()
...
...
@@ -260,11 +306,13 @@ open class TabBar: Bar {
}
}
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
w
+=
tabItemsContentEdgeInsets
.
right
-
tabItemsInterimSpace
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
scrollView
.
height
-
tabItemsContentEdgeInsets
.
top
-
tabItemsContentEdgeInsets
.
bottom
)
}
else
{
scrollView
.
grid
.
views
=
tabItems
scrollView
.
grid
.
axis
.
columns
=
tabItems
.
count
scrollView
.
contentSize
=
CGSize
(
width
:
scrollView
.
width
,
height
:
height
)
scrollView
.
contentSize
=
CGSize
(
width
:
scrollView
.
width
,
height
:
scrollView
.
height
-
tabItemsContentEdgeInsets
.
top
-
tabItemsContentEdgeInsets
.
bottom
)
}
grid
.
commit
()
...
...
@@ -278,6 +326,7 @@ open class TabBar: Bar {
super
.
prepare
()
contentEdgeInsetsPreset
=
.
none
interimSpacePreset
=
.
interimSpace6
tabItemsInterimSpacePreset
=
.
none
prepareContentView
()
prepareScrollView
()
...
...
@@ -354,20 +403,20 @@ fileprivate extension TabBar {
}
}
extension
TabBar
{
fileprivate
extension
TabBar
{
/**
Removes the line animation handlers.
- Parameter tabItem: A TabItem.
*/
f
ileprivate
f
unc
removeLineAnimationHandler
(
tabItem
:
TabItem
)
{
func
removeLineAnimationHandler
(
tabItem
:
TabItem
)
{
tabItem
.
removeTarget
(
self
,
action
:
#selector(
handleLineAnimation(tabItem:)
)
,
for
:
.
touchUpInside
)
}
}
extension
TabBar
{
fileprivate
extension
TabBar
{
/// Handles the tabItem touch event.
@objc
f
ileprivate
f
unc
handleLineAnimation
(
tabItem
:
TabItem
)
{
func
handleLineAnimation
(
tabItem
:
TabItem
)
{
animate
(
to
:
tabItem
,
isTriggeredByUserInteraction
:
true
)
}
}
...
...
@@ -393,7 +442,9 @@ extension TabBar {
open
func
animate
(
to
tabItem
:
TabItem
,
completion
:
((
TabItem
)
->
Void
)?
=
nil
)
{
animate
(
to
:
tabItem
,
isTriggeredByUserInteraction
:
false
,
completion
:
completion
)
}
}
fileprivate
extension
TabBar
{
/**
Animates to a given tabItem.
- Parameter to tabItem: A TabItem.
...
...
@@ -424,7 +475,7 @@ extension TabBar {
}
completion
?(
tabItem
)
})
})
if
!
scrollView
.
bounds
.
contains
(
tabItem
.
frame
)
{
let
contentOffsetX
=
(
tabItem
.
x
<
scrollView
.
bounds
.
minX
)
?
tabItem
.
x
:
tabItem
.
frame
.
maxX
-
scrollView
.
bounds
.
width
...
...
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