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
a921f765
Commit
a921f765
authored
Aug 02, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added ChipItemStyle to layout chip style
parent
57b9f836
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
3 deletions
+63
-3
Sources/iOS/ChipBar.swift
+58
-2
Sources/iOS/TabBar.swift
+5
-1
No files found.
Sources/iOS/ChipBar.swift
View file @
a921f765
...
@@ -30,7 +30,59 @@
...
@@ -30,7 +30,59 @@
import
UIKit
import
UIKit
open
class
ChipItem
:
FlatButton
{}
@objc(ChipItemStyle)
public
enum
ChipItemStyle
:
Int
{
case
pill
}
open
class
ChipItem
:
FlatButton
{
/// Configures the visual display of the chip.
var
chipItemStyle
:
ChipItemStyle
{
get
{
return
associatedInstance
.
chipItemStyle
}
set
(
value
)
{
associatedInstance
.
chipItemStyle
=
value
layoutSubviews
()
}
}
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
layoutChipItemStyle
()
}
}
fileprivate
extension
ChipItem
{
/// Lays out the chipItem based on its style.
func
layoutChipItemStyle
()
{
if
.
pill
==
chipItemStyle
{
cornerRadius
=
height
/
2
}
}
}
fileprivate
struct
AssociatedInstance
{
/// A ChipItemStyle value.
var
chipItemStyle
:
ChipItemStyle
}
/// A memory reference to the ChipItemStyle instance for ChipItem extensions.
fileprivate
var
ChipKey
:
UInt8
=
0
fileprivate
extension
ChipItem
{
/// AssociatedInstance reference.
var
associatedInstance
:
AssociatedInstance
{
get
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
ChipKey
)
{
return
AssociatedInstance
(
chipItemStyle
:
.
pill
)
}
}
set
(
value
)
{
AssociatedObject
.
set
(
base
:
self
,
key
:
&
ChipKey
,
value
:
value
)
}
}
}
@objc(ChipBarDelegate)
@objc(ChipBarDelegate)
public
protocol
ChipBarDelegate
{
public
protocol
ChipBarDelegate
{
...
@@ -194,11 +246,15 @@ open class ChipBar: Bar {
...
@@ -194,11 +246,15 @@ open class ChipBar: Bar {
var
w
:
CGFloat
=
0
var
w
:
CGFloat
=
0
for
v
in
chipItems
{
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
:
contentView
.
height
))
.
width
+
interimSpace
scrollView
.
addSubview
(
v
)
v
.
height
=
scrollView
.
height
v
.
height
=
scrollView
.
height
v
.
width
=
x
v
.
width
=
x
v
.
x
=
w
v
.
x
=
w
w
+=
x
w
+=
x
if
scrollView
!=
v
.
superview
{
v
.
removeFromSuperview
()
scrollView
.
addSubview
(
v
)
}
}
}
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
...
...
Sources/iOS/TabBar.swift
View file @
a921f765
...
@@ -249,11 +249,15 @@ open class TabBar: Bar {
...
@@ -249,11 +249,15 @@ open class TabBar: Bar {
var
w
:
CGFloat
=
0
var
w
:
CGFloat
=
0
for
v
in
tabItems
{
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
:
contentView
.
height
))
.
width
+
interimSpace
scrollView
.
addSubview
(
v
)
v
.
height
=
scrollView
.
height
v
.
height
=
scrollView
.
height
v
.
width
=
x
v
.
width
=
x
v
.
x
=
w
v
.
x
=
w
w
+=
x
w
+=
x
if
scrollView
!=
v
.
superview
{
v
.
removeFromSuperview
()
scrollView
.
addSubview
(
v
)
}
}
}
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
...
...
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