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
0ae3220c
Commit
0ae3220c
authored
Feb 10, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on GridView, latest additions for Vertical alignment
parent
55d70ff5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
1 deletions
+105
-1
Examples/Programmatic/GridView/GridView/ViewController.swift
+102
-1
Sources/GridView.swift
+3
-0
No files found.
Examples/Programmatic/GridView/GridView/ViewController.swift
View file @
0ae3220c
...
@@ -40,7 +40,9 @@ class ViewController: UIViewController {
...
@@ -40,7 +40,9 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
prepareView
()
prepareView
()
prepareHorizontalGridViewExample
()
// prepareHorizontalGridViewExample()
// prepareVerticalGridViewExample()
prepareSmallCardViewExample
()
}
}
...
@@ -49,6 +51,48 @@ class ViewController: UIViewController {
...
@@ -49,6 +51,48 @@ class ViewController: UIViewController {
view
.
backgroundColor
=
MaterialColor
.
white
view
.
backgroundColor
=
MaterialColor
.
white
}
}
/// Prepares the small card example.
private
func
prepareSmallCardViewExample
()
{
var
image
:
UIImage
?
=
UIImage
.
imageWithColor
(
MaterialColor
.
blueGrey
.
darken4
,
size
:
CGSizeMake
(
100
,
100
))
let
imageView
:
MaterialView
=
MaterialView
()
imageView
.
grid
=
.
Grid3
imageView
.
image
=
image
let
contentView
:
GridView
=
GridView
()
contentView
.
grid
=
.
Grid9
contentView
.
unifiedHeight
=
40
contentView
.
backgroundColor
=
MaterialColor
.
blue
.
base
let
titleGridView
:
GridView
=
GridView
()
titleGridView
.
grid
=
.
Grid9
titleGridView
.
spacing
=
8
titleGridView
.
unifiedHeight
=
40
image
=
UIImage
(
named
:
"ic_more_vert_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
moreButton
:
FlatButton
=
FlatButton
()
moreButton
.
grid
=
.
Grid2
moreButton
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
moreButton
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
moreButton
.
backgroundColor
=
MaterialColor
.
green
.
base
moreButton
.
setImage
(
image
,
forState
:
.
Normal
)
moreButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
let
titleLabel
:
MaterialLabel
=
MaterialLabel
()
titleLabel
.
grid
=
.
Grid7
titleLabel
.
text
=
"Material GridView ahskjdha sjdha sjkdhas jkhd "
titleLabel
.
textColor
=
MaterialColor
.
blueGrey
.
darken4
titleGridView
.
views
=
[
titleLabel
,
moreButton
]
contentView
.
views
=
[
titleGridView
]
let
gridView
:
GridView
=
GridView
(
frame
:
CGRectMake
(
16
,
100
,
view
.
bounds
.
width
-
32
,
100
))
gridView
.
unifiedHeight
=
100
gridView
.
views
=
[
imageView
,
contentView
]
view
.
addSubview
(
gridView
)
}
/// Prepares the Horizontal GridView example.
/// Prepares the Horizontal GridView example.
private
func
prepareHorizontalGridViewExample
()
{
private
func
prepareHorizontalGridViewExample
()
{
var
image
:
UIImage
?
=
UIImage
(
named
:
"ic_flash_auto_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
var
image
:
UIImage
?
=
UIImage
(
named
:
"ic_flash_auto_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
...
@@ -97,5 +141,62 @@ class ViewController: UIViewController {
...
@@ -97,5 +141,62 @@ class ViewController: UIViewController {
MaterialLayout
.
alignFromTop
(
view
,
child
:
gridView
)
MaterialLayout
.
alignFromTop
(
view
,
child
:
gridView
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
gridView
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
gridView
)
}
}
internal
func
handleButton
()
{
print
(
"Clicked Button"
)
}
/// Prepares the Vertical GridView example.
private
func
prepareVerticalGridViewExample
()
{
var
image
:
UIImage
?
=
UIImage
(
named
:
"ic_flash_auto_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
btn1
:
FlatButton
=
FlatButton
()
// btn1.grid = .Grid2
btn1
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
btn1
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
btn1
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
btn1
.
setImage
(
image
,
forState
:
.
Normal
)
btn1
.
setImage
(
image
,
forState
:
.
Highlighted
)
btn1
.
addTarget
(
self
,
action
:
"handleButton"
,
forControlEvents
:
.
TouchUpInside
)
image
=
UIImage
(
named
:
"ic_flash_off_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
btn2
:
FlatButton
=
FlatButton
()
// btn2.grid = .Grid3
btn2
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
btn2
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
btn2
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
btn2
.
setImage
(
image
,
forState
:
.
Normal
)
btn2
.
setImage
(
image
,
forState
:
.
Highlighted
)
image
=
UIImage
(
named
:
"ic_flash_on_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
btn3
:
FlatButton
=
FlatButton
()
btn3
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
btn3
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
btn3
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
btn3
.
setImage
(
image
,
forState
:
.
Normal
)
btn3
.
setImage
(
image
,
forState
:
.
Highlighted
)
let
label1
:
MaterialLabel
=
MaterialLabel
()
label1
.
text
=
"A"
label1
.
backgroundColor
=
MaterialColor
.
blue
.
base
let
label2
:
MaterialLabel
=
MaterialLabel
()
label2
.
text
=
"B"
// label2.grid = .Grid2
label2
.
backgroundColor
=
MaterialColor
.
blue
.
base
let
gridView
:
GridView
=
GridView
()
// let gridView: GridView = GridView(frame: CGRectMake(0, 100, view.bounds.width, 100))
gridView
.
grid
=
.
Grid12
gridView
.
layout
=
.
Vertical
// gridView.spacing = 32
// gridView.unifiedHeight = 40
gridView
.
views
=
[
btn1
,
btn2
,
label2
]
view
.
addSubview
(
gridView
)
gridView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
gridView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
gridView
)
MaterialLayout
.
height
(
view
,
child
:
gridView
,
height
:
400
)
}
}
}
Sources/GridView.swift
View file @
0ae3220c
...
@@ -120,6 +120,7 @@ public class GridView : MaterialView {
...
@@ -120,6 +120,7 @@ public class GridView : MaterialView {
let
g
:
Int
=
grid
.
rawValue
let
g
:
Int
=
grid
.
rawValue
let
w
:
CGFloat
=
(
width
-
spacing
)
/
CGFloat
(
g
)
let
w
:
CGFloat
=
(
width
-
spacing
)
/
CGFloat
(
g
)
let
h
:
CGFloat
=
(
height
-
spacing
)
/
CGFloat
(
g
)
if
let
v
:
Array
<
GridCell
>
=
views
{
if
let
v
:
Array
<
GridCell
>
=
views
{
var
n
:
Int
=
0
var
n
:
Int
=
0
for
var
i
:
Int
=
0
,
l
:
Int
=
v
.
count
;
i
<
l
;
++
i
{
for
var
i
:
Int
=
0
,
l
:
Int
=
v
.
count
;
i
<
l
;
++
i
{
...
@@ -128,6 +129,8 @@ public class GridView : MaterialView {
...
@@ -128,6 +129,8 @@ public class GridView : MaterialView {
let
m
:
Int
=
cell
.
grid
.
rawValue
let
m
:
Int
=
cell
.
grid
.
rawValue
if
.
Horizontal
==
layout
{
if
.
Horizontal
==
layout
{
view
.
frame
=
CGRectMake
(
CGFloat
(
i
+
n
)
*
w
+
spacing
,
0
,
(
w
*
CGFloat
(
m
))
-
spacing
,
0
<
unifiedHeight
?
unifiedHeight
:
view
.
intrinsicContentSize
()
.
height
)
view
.
frame
=
CGRectMake
(
CGFloat
(
i
+
n
)
*
w
+
spacing
,
0
,
(
w
*
CGFloat
(
m
))
-
spacing
,
0
<
unifiedHeight
?
unifiedHeight
:
view
.
intrinsicContentSize
()
.
height
)
}
else
{
view
.
frame
=
CGRectMake
(
0
,
CGFloat
(
i
+
n
)
*
h
+
spacing
,
view
.
intrinsicContentSize
()
.
width
,
(
h
*
CGFloat
(
m
))
-
spacing
)
}
}
view
.
removeFromSuperview
()
view
.
removeFromSuperview
()
addSubview
(
view
)
addSubview
(
view
)
...
...
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