File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed
Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ struct HubMenu: View {
3030
3131 LazyVGrid ( columns: gridItemLayout, spacing: Constants . itemSpacing) {
3232 ForEach ( viewModel. menuElements, id: \. self) { menu in
33- HubMenuElement ( image: menu. icon, text: menu. title, onTapGesture: {
33+ HubMenuElement ( image: menu. icon, imageColor : menu . iconColor , text: menu. title, onTapGesture: {
3434 switch menu {
3535 case . woocommerceAdmin:
3636 ServiceLocator . analytics. track ( . hubMenuOptionTapped, withProperties: [ Constants . option: " admin_menu " ] )
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import SwiftUI
44///
55struct HubMenuElement : View {
66 let image : UIImage
7+ let imageColor : UIColor
78 let text : String
89 let onTapGesture : ( ( ) -> Void )
910
@@ -19,8 +20,10 @@ struct HubMenuElement: View {
1920 Color ( UIColor ( light: . listBackground,
2021 dark: . secondaryButtonBackground) )
2122 Image ( uiImage: image)
23+ . renderingMode ( . template)
2224 . resizable ( )
2325 . scaledToFit ( )
26+ . foregroundColor ( Color ( imageColor) )
2427 . frame ( width: iconSize, height: iconSize)
2528 }
2629 . frame ( width: imageSize, height: imageSize, alignment: . center)
@@ -42,7 +45,9 @@ struct HubMenuElement: View {
4245struct HubMenuElement_Previews : PreviewProvider {
4346 static var previews : some View {
4447 HubMenuElement ( image: . starOutlineImage( ) ,
45- text: " Menu " , onTapGesture: { } )
48+ imageColor: . blue,
49+ text: " Menu " ,
50+ onTapGesture: { } )
4651 . previewLayout ( . fixed( width: 160 , height: 160 ) )
4752 . previewDisplayName ( " Hub Menu Element " )
4853 }
Original file line number Diff line number Diff line change @@ -112,13 +112,27 @@ extension HubMenuViewModel {
112112 var icon : UIImage {
113113 switch self {
114114 case . woocommerceAdmin:
115- return . wordPressLogoImage. imageWithTintColor ( . blue ) ?? . wordPressLogoImage
115+ return . wordPressLogoImage
116116 case . viewStore:
117- return . storeImage. imageWithTintColor ( . accent ) ?? . storeImage
117+ return . storeImage
118118 case . coupons:
119119 return . couponImage
120120 case . reviews:
121- return . starImage( size: 24.0 ) . imageWithTintColor ( . primary) ?? . starImage( size: 24.0 )
121+ return . starImage( size: 24.0 )
122+ }
123+ }
124+
125+ var iconColor : UIColor {
126+ switch self {
127+ case . woocommerceAdmin:
128+ return . blue
129+ case . viewStore:
130+ return . accent
131+ case . coupons:
132+ return UIColor ( light: . withColorStudio( . green, shade: . shade30) ,
133+ dark: . withColorStudio( . green, shade: . shade50) )
134+ case . reviews:
135+ return . primary
122136 }
123137 }
124138 }
You can’t perform that action at this time.
0 commit comments