@@ -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