orbit-swiftui icon indicating copy to clipboard operation
orbit-swiftui copied to clipboard

Use native SwiftUI environment keys

Open PavelHolec opened this issue 2 years ago • 1 comments

Some components might use existing environment keys or modifiers in favour of parameters.

Available related environment keys

  • #401
  • #404
    • lineLimit, lineSpacing, multilineTextAlignment , textCase, truncationMode : could be used in Text/Heading to be able to inject text-based modifiers inside.
    • A font override could be supported as well.
  • defaultMinListRowHeight
    • can be used to support ListChoice
  • accessibilityReduceMotion
    • should be respected whenever we do animations
    • ~~can be also used in snapshot test code to force non-animated version~~ - This environment key is read-only 🤷
  • tint
    • can be used to override the accent color of some elements (button, checkbox, switch)

iOS14+ modifiers

  • isFocused (iOS14+)
    • could be used whenever we have similar flag or enum
    • works correctly on InputField when used from iOS14+ client
  • controlSize (iOS15+)
    • could be used for sizing Badges or Buttons (whenever we have size enum)

Related modifiers

  • foregroundColor() and tint() (iOS15+):
    • write-only modifier 🤷 Can be partially accessed by:
      • ForegroundShapeStyle()
      • TintShapeStyle()
      • But we cannot access the underlying UIKit color that we need for the TextLink overlay or other formatting implementation

PavelHolec avatar Jun 13 '22 08:06 PavelHolec

https://www.fivestars.blog/articles/swiftui-environment-values/

https://developer.apple.com/documentation/swiftui/environmentvalues

sjavora avatar Aug 15 '22 20:08 sjavora