From c17641a2f94761296e8404ac201628ec87980cb9 Mon Sep 17 00:00:00 2001 From: Mikhail Golovko Date: Tue, 9 Apr 2024 13:14:55 +0300 Subject: [PATCH 1/2] IOS-2605 Fix --- .../arrowForward.imageset/Contents.json | 3 +++ .../BasicComponents/DynamicForeground.swift | 20 ++++++++++--------- .../Common/SwiftUI/IconView/IconView.swift | 4 ++-- .../Specific/Object/TodoIconView.swift | 2 +- .../Sections/SettingsSectionItemView.swift | 6 +++--- .../Popups/ViewPicker/SetViewPicker.swift | 2 +- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Anytype/Resources/Assets.xcassets/Common/arrowForward.imageset/Contents.json b/Anytype/Resources/Assets.xcassets/Common/arrowForward.imageset/Contents.json index ec39488723..f8cd741335 100644 --- a/Anytype/Resources/Assets.xcassets/Common/arrowForward.imageset/Contents.json +++ b/Anytype/Resources/Assets.xcassets/Common/arrowForward.imageset/Contents.json @@ -8,5 +8,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/BasicComponents/DynamicForeground.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/BasicComponents/DynamicForeground.swift index 3c460936c5..ffb55b98a1 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/BasicComponents/DynamicForeground.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/BasicComponents/DynamicForeground.swift @@ -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)) } } diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/IconView/IconView.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/IconView/IconView.swift index e8a173e589..e7ebdb547b 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/IconView/IconView.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/IconView/IconView.swift @@ -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() } diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/IconView/Specific/Object/TodoIconView.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/IconView/Specific/Object/TodoIconView.swift index 2c4f18624c..074d49c671 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/IconView/Specific/Object/TodoIconView.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/IconView/Specific/Object/TodoIconView.swift @@ -11,7 +11,7 @@ struct TodoIconView: View { Image(asset: checked ? .TaskLayout.done : .TaskLayout.empty) .resizable() .scaledToFit() - .buttonDynamicForegroundColor() + .buttonDynamicForegroundStyle() .frame(maxWidth: 28, maxHeight: 28) } } diff --git a/Anytype/Sources/PresentationLayer/Settings/Settings/Sections/SettingsSectionItemView.swift b/Anytype/Sources/PresentationLayer/Settings/Settings/Sections/SettingsSectionItemView.swift index 949403939a..9865531c39 100644 --- a/Anytype/Sources/PresentationLayer/Settings/Settings/Sections/SettingsSectionItemView.swift +++ b/Anytype/Sources/PresentationLayer/Settings/Settings/Sections/SettingsSectionItemView.swift @@ -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 } @@ -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) diff --git a/Anytype/Sources/PresentationLayer/TextEditor/Set/Views/Popups/ViewPicker/SetViewPicker.swift b/Anytype/Sources/PresentationLayer/TextEditor/Set/Views/Popups/ViewPicker/SetViewPicker.swift index 39edded8b8..d33ab628e8 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/Set/Views/Popups/ViewPicker/SetViewPicker.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/Set/Views/Popups/ViewPicker/SetViewPicker.swift @@ -57,7 +57,7 @@ struct SetViewPicker: View { ToolbarItem(placement: .navigationBarLeading) { if viewModel.canEditViews { EditButton() - .buttonDynamicForegroundColor() + .buttonDynamicForegroundStyle() } } ToolbarItem(placement: .navigationBarTrailing) { From 0a9ddf8c8d435255152b5a8c0cd195215eab7f61 Mon Sep 17 00:00:00 2001 From: Mikhail Golovko Date: Tue, 9 Apr 2024 13:16:27 +0300 Subject: [PATCH 2/2] IOS-2605 Rollback --- .../Assets.xcassets/Common/arrowForward.imageset/Contents.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/Anytype/Resources/Assets.xcassets/Common/arrowForward.imageset/Contents.json b/Anytype/Resources/Assets.xcassets/Common/arrowForward.imageset/Contents.json index f8cd741335..ec39488723 100644 --- a/Anytype/Resources/Assets.xcassets/Common/arrowForward.imageset/Contents.json +++ b/Anytype/Resources/Assets.xcassets/Common/arrowForward.imageset/Contents.json @@ -8,8 +8,5 @@ "info" : { "author" : "xcode", "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "template" } }