Skip to content

Commit

Permalink
IOS-2605 Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mgolovko committed Apr 9, 2024
1 parent 5713116 commit c17641a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import Foundation
import SwiftUI

private struct DynamicForegroundViewModifier: ViewModifier {
private struct DynamicForegroundStyle: ShapeStyle {

@Environment(\.isEnabled) private var isEnable
let enabledColor: Color
let disabledColor: Color

func body(content: Content) -> some View {
content
.foregroundColor(isEnable ? enabledColor : disabledColor)
func resolve(in environment: EnvironmentValues) -> some ShapeStyle {
if environment.isEnabled {
return enabledColor
} else {
return disabledColor
}
}
}

extension View {
func buttonDynamicForegroundColor() -> some View {
modifier(DynamicForegroundViewModifier(enabledColor: .Button.active, disabledColor: .Button.inactive))
func buttonDynamicForegroundStyle() -> some View {
foregroundStyle(DynamicForegroundStyle(enabledColor: .Button.active, disabledColor: .Button.inactive))
}

func textDynamicForegroundColor(color: Color) -> some View {
modifier(DynamicForegroundViewModifier(enabledColor: color, disabledColor: .Text.tertiary))
func dynamicForegroundStyle(color: Color, disabledColor: Color) -> some View {
foregroundStyle(DynamicForegroundStyle(enabledColor: color, disabledColor: disabledColor))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ struct IconView: View {
ObjectIconView(icon: objectIcon)
case .asset(let imageAsset):
Image(asset: imageAsset)
.buttonDynamicForegroundColor()
.buttonDynamicForegroundStyle()
case .image(let uIImage):
Image(uiImage: uIImage)
.buttonDynamicForegroundColor()
.buttonDynamicForegroundStyle()
case nil:
EmptyView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct TodoIconView: View {
Image(asset: checked ? .TaskLayout.done : .TaskLayout.empty)
.resizable()
.scaledToFit()
.buttonDynamicForegroundColor()
.buttonDynamicForegroundStyle()
.frame(maxWidth: 28, maxHeight: 28)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct SettingsSectionItemView: View {
}
HStack(alignment: .center, spacing: 0) {
AnytypeText(name, style: .uxBodyRegular)
.foregroundColor(.Text.primary)
.dynamicForegroundStyle(color: .Text.primary, disabledColor: .Text.tertiary)
Spacer()
decorationView
}
Expand All @@ -57,11 +57,11 @@ struct SettingsSectionItemView: View {
case .arrow(let text):
HStack(alignment: .center, spacing: 10) {
AnytypeText(text, style: .bodyRegular)
.foregroundColor(.Text.secondary)
.dynamicForegroundStyle(color: .Text.secondary, disabledColor: .Text.tertiary)
.lineLimit(1)
Image(asset: .arrowForward)
.renderingMode(.template)
.foregroundColor(.Text.tertiary)
.dynamicForegroundStyle(color: .Text.tertiary, disabledColor: .Button.inactive)
}
case .button(let text):
AnytypeText(text, style: .caption1Medium)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct SetViewPicker: View {
ToolbarItem(placement: .navigationBarLeading) {
if viewModel.canEditViews {
EditButton()
.buttonDynamicForegroundColor()
.buttonDynamicForegroundStyle()
}
}
ToolbarItem(placement: .navigationBarTrailing) {
Expand Down

0 comments on commit c17641a

Please sign in to comment.