-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
21 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,8 @@ | |
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
20 changes: 11 additions & 9 deletions
20
Anytype/Sources/PresentationLayer/Common/SwiftUI/BasicComponents/DynamicForeground.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters