Skip to content

Commit f89ddbd

Browse files
committed
Color Trail
1 parent 4a2c1e0 commit f89ddbd

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

MotionToastView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'MotionToastView'
11-
s.version = '0.1.6'
11+
s.version = '0.1.7'
1212
s.summary = 'A Beautiful Toast Library for iOS Swift'
1313

1414
# This description is used to generate tags and improve search results.

Source/MotionToastStyles/MTPale.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,34 @@ class MTPale: UIView {
4747
}
4848

4949
func setupViews(toastType: ToastType) {
50-
let bundle = Bundle(for: type(of: self))
5150
switch toastType {
5251
case .success:
5352
headLabel.text = "Success"
5453
circleImg.image = loadImage(name: "success_icon_white")
5554
sideBarView.backgroundColor = UIColor(hex: "6FCF97")
5655
circleView.backgroundColor = UIColor(hex: "6FCF97")
57-
toastView.backgroundColor = UIColor(named: "alpha_green_dark", in: bundle, compatibleWith: nil)!
56+
toastView.backgroundColor = loadColor(name: "alpha_green_dark")
5857
break
5958
case .error:
6059
headLabel.text = "Error"
6160
circleImg.image = loadImage(name: "error_icon_white")
6261
sideBarView.backgroundColor = UIColor(hex: "EB5757")
6362
circleView.backgroundColor = UIColor(hex: "EB5757")
64-
toastView.backgroundColor = UIColor(named: "alpha_red_dark", in: bundle, compatibleWith: nil)!
63+
toastView.backgroundColor = loadColor(name: "alpha_red_dark")
6564
break
6665
case .warning:
6766
headLabel.text = "Warning"
6867
circleImg.image = loadImage(name: "warning_icon_white")
6968
sideBarView.backgroundColor = UIColor(hex: "F2C94C")
7069
circleView.backgroundColor = UIColor(hex: "F2C94C")
71-
toastView.backgroundColor = UIColor(named: "alpha_yellow_dark", in: bundle, compatibleWith: nil)!
70+
toastView.backgroundColor = UIColor(hex: "456789")
7271
break
7372
case .info:
7473
headLabel.text = "Info"
7574
circleImg.image = loadImage(name: "info_icon_white")
7675
sideBarView.backgroundColor = UIColor(hex: "2F80ED")
7776
circleView.backgroundColor = UIColor(hex: "2F80ED")
78-
toastView.backgroundColor = UIColor(named: "alpha_blue_dark", in: bundle, compatibleWith: nil)!
77+
toastView.backgroundColor = loadColor(name: "alpha_blue_dark")
7978
break
8079
}
8180
}
@@ -86,8 +85,17 @@ class MTPale: UIView {
8685
let bundle = Bundle(url: url)
8786
return UIImage(named: name, in: bundle, compatibleWith: nil)
8887
}
89-
print("MotionToastView")
88+
print("MotionToastView Image")
9089
return nil
9190
}
9291

92+
func loadColor(name: String) -> UIColor? {
93+
let podBundle = Bundle(for: MTPale.self)
94+
if let url = podBundle.url(forResource: "MotionToastView", withExtension: "bundle") {
95+
let bundle = Bundle(url: url)
96+
return UIColor(named: name, in: bundle, compatibleWith: nil)
97+
}
98+
print("MotionToastView Color")
99+
return nil
100+
}
93101
}

Source/MotionToastStyles/MTVibrant.swift

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,30 @@ class MTVibrant: UIView {
4444
}
4545

4646
func setupViews(toastType: ToastType) {
47-
let bundle = Bundle(for: type(of: self))
4847
switch toastType {
4948
case .success:
5049
headLabel.text = "Success"
51-
headLabel.textColor = UIColor(named: "white_green", in: bundle, compatibleWith: nil)!
50+
headLabel.textColor = loadColor(name: "white_green")
5251
circleImg.image = loadImage(name: "success_icon")
53-
toastView.backgroundColor = UIColor(named: "green_dark", in: bundle, compatibleWith: nil)!
52+
toastView.backgroundColor = loadColor(name: "green_dark")
5453
break
5554
case .error:
5655
headLabel.text = "Error"
57-
headLabel.textColor = UIColor(named: "white_red", in: bundle, compatibleWith: nil)!
56+
headLabel.textColor = loadColor(name: "white_red")
5857
circleImg.image = loadImage(name: "error_icon")
59-
toastView.backgroundColor = UIColor(named: "red_dark", in: bundle, compatibleWith: nil)!
58+
toastView.backgroundColor = loadColor(name: "red_dark")
6059
break
6160
case .warning:
6261
headLabel.text = "Warning"
63-
headLabel.textColor = UIColor(named: "white_yellow", in: bundle, compatibleWith: nil)!
62+
headLabel.textColor = loadColor(name: "white_yellow")
6463
circleImg.image = loadImage(name: "warning_icon")
65-
toastView.backgroundColor = UIColor(named: "yellow_dark", in: bundle, compatibleWith: nil)!
64+
toastView.backgroundColor = loadColor(name: "yellow_dark")
6665
break
6766
case .info:
6867
headLabel.text = "Info"
69-
headLabel.textColor = UIColor(named: "white_blue", in: bundle, compatibleWith: nil)!
68+
headLabel.textColor = loadColor(name: "white_blue")
7069
circleImg.image = loadImage(name: "info_icon")
71-
toastView.backgroundColor = UIColor(named: "blue_dark", in: bundle, compatibleWith: nil)!
70+
toastView.backgroundColor = loadColor(name: "blue_dark")
7271
break
7372
}
7473
}
@@ -79,7 +78,17 @@ class MTVibrant: UIView {
7978
let bundle = Bundle(url: url)
8079
return UIImage(named: name, in: bundle, compatibleWith: nil)
8180
}
82-
print("MotionToastView")
81+
print("MotionToastView Image")
82+
return nil
83+
}
84+
85+
func loadColor(name: String) -> UIColor? {
86+
let podBundle = Bundle(for: MTVibrant.self)
87+
if let url = podBundle.url(forResource: "MotionToastView", withExtension: "bundle") {
88+
let bundle = Bundle(url: url)
89+
return UIColor(named: name, in: bundle, compatibleWith: nil)
90+
}
91+
print("MotionToastView Color")
8392
return nil
8493
}
8594
}

0 commit comments

Comments
 (0)