Skip to content

Commit 20ed9ae

Browse files
committed
Add runtime attributes update support
1 parent c844271 commit 20ed9ae

7 files changed

+102
-24
lines changed

Cards/Sources/Animator.swift

-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ class Animator: NSObject, UIViewControllerAnimatedTransitioning {
122122
let xMove = -( xDistance * bounceIntensity )
123123
let yMove = -( yDistance * bounceIntensity )
124124

125-
//let xMove = (old.x < new.x ) ? LayoutHelper.XScreen(bounceIntensity) : -LayoutHelper.XScreen(bounceIntensity)
126-
//let yMove = (old.y < new.y ) ? LayoutHelper.YScreen(bounceIntensity) : -LayoutHelper.YScreen(bounceIntensity)
127-
128125
return CGAffineTransform(translationX: xMove, y: yMove)
129126
}
130127

Cards/Sources/Card.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ import UIKit
212212
}
213213

214214
func goParallax() {
215-
let amount = 10
215+
let amount = 20
216216

217217
let horizontal = UIInterpolatingMotionEffect(keyPath: "center.x", type: .tiltAlongHorizontalAxis)
218218
horizontal.minimumRelativeValue = -amount

Cards/Sources/CardArticle.swift

+15-3
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,35 @@ import UIKit
1414
/**
1515
Text of the title label.
1616
*/
17-
@IBInspectable public var title: String = "The Art of the Impossible"
17+
@IBInspectable public var title: String = "The Art of the Impossible" {
18+
didSet{
19+
titleLbl.text = title
20+
}
21+
}
1822
/**
1923
Max font size the title label.
2024
*/
2125
@IBInspectable public var titleSize: CGFloat = 26
2226
/**
2327
Text of the subtitle label.
2428
*/
25-
@IBInspectable public var subtitle: String = "Inside the extraordinary world of Monument Valley 2"
29+
@IBInspectable public var subtitle: String = "Inside the extraordinary world of Monument Valley 2" {
30+
didSet{
31+
subtitleLbl.text = subtitle
32+
}
33+
}
2634
/**
2735
Max font size the subtitle label.
2836
*/
2937
@IBInspectable public var subtitleSize: CGFloat = 17
3038
/**
3139
Text of the category label.
3240
*/
33-
@IBInspectable public var category: String = "world premiere"
41+
@IBInspectable public var category: String = "world premiere" {
42+
didSet{
43+
categoryLbl.text = category.uppercased()
44+
}
45+
}
3446

3547
//Priv Vars
3648
var titleLbl = UILabel ()

Cards/Sources/CardGroup.swift

+15-3
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,35 @@ import UIKit
1414
/**
1515
Text of the title label.
1616
*/
17-
@IBInspectable public var title: String = "Welcome to XI Cards !"
17+
@IBInspectable public var title: String = "Welcome to XI Cards !" {
18+
didSet{
19+
titleLbl.text = title
20+
}
21+
}
1822
/**
1923
Max font size the title label.
2024
*/
2125
@IBInspectable public var titleSize: CGFloat = 26
2226
/**
2327
Text of the subtitle label.
2428
*/
25-
@IBInspectable public var subtitle: String = "from the editors"
29+
@IBInspectable public var subtitle: String = "from the editors" {
30+
didSet{
31+
subtitleLbl.text = subtitle.uppercased()
32+
}
33+
}
2634
/**
2735
Max font size the subtitle label.
2836
*/
2937
@IBInspectable public var subtitleSize: CGFloat = 26
3038
/**
3139
Style for the blur effect.
3240
*/
33-
@IBInspectable public var blurEffect: UIBlurEffectStyle = .extraLight
41+
@IBInspectable public var blurEffect: UIBlurEffectStyle = .extraLight {
42+
didSet{
43+
blurV.effect = UIBlurEffect(style: blurEffect)
44+
}
45+
}
3446

3547
//Priv Vars
3648
var subtitleLbl = UILabel ()

Cards/Sources/CardGroupSliding.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@ import UIKit
1313
/**
1414
Size for the collection view items.
1515
*/
16-
@IBInspectable public var iconsSize: CGFloat = 80
16+
@IBInspectable public var iconsSize: CGFloat = 80 {
17+
didSet{
18+
slidingCV.reloadData()
19+
}
20+
}
1721
/**
1822
Corner radius of the collection view items
1923
*/
20-
@IBInspectable public var iconsRadius: CGFloat = 40
24+
@IBInspectable public var iconsRadius: CGFloat = 40 {
25+
didSet{
26+
slidingCV.reloadData()
27+
}
28+
}
2129

2230
/**
2331
Data source for the collection view.

Cards/Sources/CardHighlight.swift

+28-5
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,58 @@ import UIKit
1313
/**
1414
Text of the title label.
1515
*/
16-
@IBInspectable public var title: String = "welcome \nto \ncards !"
16+
@IBInspectable public var title: String = "welcome \nto \ncards !" {
17+
didSet{
18+
titleLbl.text = title.uppercased()
19+
titleLbl.lineHeight(0.70)
20+
}
21+
}
1722
/**
1823
Max font size the title label.
1924
*/
2025
@IBInspectable public var titleSize:CGFloat = 26
2126
/**
2227
Text of the title label of the item at the bottom.
2328
*/
24-
@IBInspectable public var itemTitle: String = "Flappy Bird"
29+
@IBInspectable public var itemTitle: String = "Flappy Bird" {
30+
didSet{
31+
itemTitleLbl.text = itemTitle
32+
}
33+
}
2534
/**
2635
Max font size the subtitle label of the item at the bottom.
2736
*/
2837
@IBInspectable public var itemTitleSize: CGFloat = 16
2938
/**
3039
Text of the subtitle label of the item at the bottom.
3140
*/
32-
@IBInspectable public var itemSubtitle: String = "Flap that !"
41+
@IBInspectable public var itemSubtitle: String = "Flap that !" {
42+
didSet{
43+
itemSubtitleLbl.text = itemSubtitle
44+
}
45+
}
3346
/**
3447
Max font size the subtitle label of the item at the bottom.
3548
*/
3649
@IBInspectable public var itemSubtitleSize: CGFloat = 14
3750
/**
3851
Image displayed in the icon ImageView.
3952
*/
40-
@IBInspectable public var icon: UIImage?
53+
@IBInspectable public var icon: UIImage? {
54+
didSet{
55+
iconIV.image = icon
56+
bgIconIV.image = icon
57+
}
58+
}
4159
/**
4260
Corner radius for the icon ImageView
4361
*/
44-
@IBInspectable public var iconRadius: CGFloat = 16
62+
@IBInspectable public var iconRadius: CGFloat = 16 {
63+
didSet{
64+
iconIV.layer.cornerRadius = iconRadius
65+
bgIconIV.layer.cornerRadius = iconRadius*2
66+
}
67+
}
4568
/**
4669
Text for the card's button.
4770
*/

Cards/Sources/CardPlayer.swift

+33-7
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,59 @@ import Player
1515
/**
1616
Text of the title label.
1717
*/
18-
@IBInspectable public var title: String = "Big Buck Bunny"
18+
@IBInspectable public var title: String = "Big Buck Bunny" {
19+
didSet{
20+
titleLbl.text = title
21+
}
22+
}
1923
/**
2024
Max font size of the title label.
2125
*/
2226
@IBInspectable public var titleSize: CGFloat = 26
2327
/**
2428
Text of the subtitle label.
2529
*/
26-
@IBInspectable public var subtitle: String = "Inside the extraordinary world of Buck Bunny"
30+
@IBInspectable public var subtitle: String = "Inside the extraordinary world of Buck Bunny" {
31+
didSet{
32+
subtitleLbl.text = subtitle
33+
}
34+
}
2735
/**
2836
Max font size of the subtitle label.
2937
*/
3038
@IBInspectable public var subtitleSize: CGFloat = 19
3139
/**
3240
Text of the category label.
3341
*/
34-
@IBInspectable public var category: String = "today's movie"
42+
@IBInspectable public var category: String = "today's movie" {
43+
didSet{
44+
categoryLbl.text = category.uppercased()
45+
}
46+
}
3547
/**
3648
Size for the play button in the player.
3749
*/
38-
@IBInspectable public var playBtnSize: CGFloat = 56
50+
@IBInspectable public var playBtnSize: CGFloat = 56 {
51+
didSet {
52+
layout(animating: false)
53+
}
54+
}
3955
/**
4056
Image shown in the play button.
4157
*/
42-
@IBInspectable public var playImage: UIImage?
58+
@IBInspectable public var playImage: UIImage? {
59+
didSet {
60+
playIV.image = playImage
61+
}
62+
}
4363
/**
4464
Image shown before the player is loaded.
4565
*/
46-
@IBInspectable public var playerCover: UIImage?
66+
@IBInspectable public var playerCover: UIImage? {
67+
didSet{
68+
playerCoverIV.image = playerCover
69+
}
70+
}
4771
/**
4872
If the player should start the playback when is ready.
4973
*/
@@ -56,7 +80,9 @@ import Player
5680
Source for the video ( streaming or local ).
5781
*/
5882
@IBInspectable public var videoSource: URL? {
59-
didSet { player.url = videoSource }
83+
didSet {
84+
player.url = videoSource
85+
}
6086
}
6187

6288
/**

0 commit comments

Comments
 (0)