@@ -56,7 +56,7 @@ public class IterableEmbeddedView:UIView {
56
56
/// Title
57
57
private var EMtitle : String ? = " Placeholding Title " {
58
58
didSet {
59
- if let title = EMtitle {
59
+ if let title = embeddedMessageTitle {
60
60
labelTitle. text = title
61
61
labelTitle. isHidden = false
62
62
} else {
@@ -68,10 +68,10 @@ public class IterableEmbeddedView:UIView {
68
68
public var EMimage : UIImage ? = nil
69
69
70
70
/// Description
71
- var EMdescription : String ? = " Placeholding Description " {
71
+ var embeddedMessageBody : String ? = " Placeholding Description " {
72
72
didSet {
73
- if let description = EMdescription {
74
- labelDescription. text = description
73
+ if let body = embeddedMessageBody {
74
+ labelDescription. text = body
75
75
labelDescription. isHidden = false
76
76
} else {
77
77
labelDescription. isHidden = true
@@ -82,7 +82,7 @@ public class IterableEmbeddedView:UIView {
82
82
/// Primary Button Text
83
83
var EMbuttonText : String ? = " Placeholding BTN 1 " {
84
84
didSet {
85
- if let btn = EMbuttonText {
85
+ if let btn = embeddedMessagePrimaryBtnTitle {
86
86
primaryBtn. titleText = btn
87
87
primaryBtn. isHidden = false
88
88
} else {
@@ -94,7 +94,7 @@ public class IterableEmbeddedView:UIView {
94
94
/// Secondary Button Text
95
95
var EMbuttonTwoText : String ? = " Placeholding BTN 2 " {
96
96
didSet {
97
- if let btn = EMbuttonTwoText {
97
+ if let btn = embeddedMessageSecondaryBtnTitle {
98
98
secondaryBtn. titleText = btn
99
99
secondaryBtn. isHidden = false
100
100
} else {
@@ -226,6 +226,11 @@ public class IterableEmbeddedView:UIView {
226
226
titleTextColor = config? . titleTextColor ?? defaultTitleTextColor
227
227
descriptionTextColor = config? . bodyTextColor ?? defaultBodyTextColor
228
228
}
229
+
230
+ embeddedMessageTitle = message. elements? . title
231
+ embeddedMessageBody = message. elements? . body
232
+ embeddedMessagePrimaryBtnTitle = message. elements? . buttons? . first? . title
233
+ embeddedMessageSecondaryBtnTitle = message. elements? . buttons? [ 1 ] . title
229
234
230
235
private func loadViewType( viewType: IterableEmbeddedViewType ) {
231
236
switch viewType {
@@ -237,29 +242,53 @@ public class IterableEmbeddedView:UIView {
237
242
cardImageView. image = EMimage
238
243
cardImageView. isHidden = false
239
244
cardImageTopConstraint. isActive = true
245
+ titleToTopConstraint. isActive = false
240
246
titleToTopConstraint? . isActive = false
241
247
} else {
242
248
// Hide cardImageView and deactivate its constraints
243
249
cardImageView. isHidden = true
244
250
cardImageTopConstraint. isActive = false
251
+ titleToTopConstraint. isActive = true
245
252
titleToTopConstraint? . isActive = true
246
253
247
254
// Remove cardImageView from its superview and release it
248
255
cardImageView. removeFromSuperview ( )
249
256
cardImageView = nil
250
257
}
251
258
case . banner:
259
+ imgView. isHidden = EMimage == nil
260
+ bannerBorderColor = cardBorderColor
252
261
imgView. isHidden = self . EMimage == nil
253
262
imgView. image = EMimage
254
263
cardImageView. isHidden = true
264
+ cardImageTopConstraint. isActive = false
265
+ titleToTopConstraint. isActive = true
255
266
cardImageTopConstraint? . isActive = false
256
267
titleToTopConstraint? . isActive = true
257
268
case . notification:
258
269
imgView. isHidden = true
259
270
cardImageView. isHidden = true
271
+ cardImageTopConstraint. isActive = false
272
+ titleToTopConstraint. isActive = true
260
273
cardImageTopConstraint? . isActive = false
261
274
titleToTopConstraint? . isActive = true
262
275
}
276
+
277
+ bannerBackgroundColor = config? . backgroundColor ?? defaultBackgroundColor
278
+ bannerBorderColor = config? . borderColor ?? defaultBorderColor
279
+ bannerBorderWidth = config? . borderWidth ?? 1.0
280
+ bannerCornerRadius = config? . borderCornerRadius ?? 8.0
281
+ primaryBtnColor = config? . primaryBtnBackgroundColor ?? defaultPrimaryBtnColor
282
+ primaryBtnTextColor = config? . primaryBtnTextColor ?? defaultPrimaryBtnTextColor
283
+ secondaryBtnColor = config? . secondaryBtnBackgroundColor ?? defaultSecondaryBtnColor
284
+ secondaryBtnTextColor = config? . secondaryBtnTextColor ?? defaultSecondaryBtnTextColor
285
+ titleTextColor = config? . titleTextColor ?? defaultTitleTextColor
286
+ descriptionTextColor = config? . bodyTextColor ?? defaultBodyTextColor
287
+
288
+ embeddedMessageTitle = message. elements? . title
289
+ embeddedMessageBody = message. elements? . body
290
+ embeddedMessagePrimaryBtnTitle = message. elements? . buttons? . first? . title
291
+ embeddedMessageSecondaryBtnTitle = message. elements? . buttons ? [ 1 ] . title
263
292
}
264
293
265
294
private func loadImage( from url: URL , withViewType viewType: IterableEmbeddedViewType ) {
@@ -475,12 +504,6 @@ public class IterableEmbeddedView:UIView {
475
504
IterableAPI . embeddedManager. handleEmbeddedClick ( message: message!, buttonIdentifier: buttonIdentifier, clickedUrl: clickedUrl)
476
505
}
477
506
}
478
-
479
- //TODO: Delegate handling
480
- // if (iterableEmbeddedViewDelegate != nil) {
481
- // iterableEmbeddedViewDelegate.didPressPrimaryButton(button: sender, viewTag: self.tag, message: message)
482
- // }
483
- else { }
484
507
}
485
508
486
509
// MARK: Second Button
@@ -546,13 +569,6 @@ public class IterableEmbeddedView:UIView {
546
569
IterableAPI . embeddedManager. handleEmbeddedClick ( message: message!, buttonIdentifier: buttonIdentifier, clickedUrl: clickedUrl)
547
570
}
548
571
}
549
-
550
- //TODO: Delegate handling
551
- // if (iterableEmbeddedViewDelegate != nil) {
552
- // iterableEmbeddedViewDelegate.didPressSecondaryButton(button: sender, viewTag: self.tag, message: message)
553
- // }
554
- // else { }
555
-
556
572
}
557
573
558
574
// MARK: Image
0 commit comments