Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#583] Vocalize buttons selected state #686

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]\(https://github.com/Orange-OpenSource/ods-ios/compare/0.76.0...qualif)

- [SDK] Vocalized buttons selected status with Voice Over ([#583](https://github.com/Orange-OpenSource/ods-ios/issues/583))
- [Tooling] Add Git tags in CI/CD pipelines for TestFlight builds, update CocoaPods ([#680](https://github.com/Orange-OpenSource/ods-ios/issues/680))

## [Unreleased]\(https://github.com/Orange-OpenSource/ods-ios/compare/0.17.0...qualif)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@

import SwiftUI

struct Chip<Leading, Text>: View where Leading: View, Text: View {
// ============
// MARK: - Chip
// ============

struct Chip<Leading, Text>: View where Leading: View, Text: View {

@ScaledMetric(relativeTo: .body) private var leadingHeight = 24
@ScaledMetric(relativeTo: .body) private var frameHeight = 32
@ScaledMetric(relativeTo: .body) private var labelPadding = ODSSpacing.xs

// =======================
// MARK: Stored properties
// =======================
Expand All @@ -25,10 +33,6 @@ struct Chip<Leading, Text>: View where Leading: View, Text: View {
@ViewBuilder private let text: () -> Text
@ViewBuilder private let leading: () -> Leading

@ScaledMetric(relativeTo: .body) private var leadingHeight = 24
@ScaledMetric(relativeTo: .body) private var frameHeight = 32
@ScaledMetric(relativeTo: .body) private var labelPadding = ODSSpacing.xs

// =================
// MARK: Intializers
// =================
Expand Down Expand Up @@ -100,25 +104,31 @@ struct Chip<Leading, Text>: View where Leading: View, Text: View {
}
}

struct ChipContentModifier: ViewModifier {
// =============================
// MARK: - Chip Content Modifier
// =============================

private struct ChipContentModifier: ViewModifier {

let isSelected: Bool
private let lineWidth: CGFloat = 1.0
@Environment(\.theme) private var theme
@Environment(\.isEnabled) private var isEnabled
private let lineWidth: CGFloat = 1.0
let isSelected: Bool

func body(content: Content) -> some View {
if isSelected {
content
.foregroundColor(.black)
.background(theme.componentColors.accent, in: Capsule())
.opacity(isEnabled ? 1 : 0.5)
.accessibilityAddTraits(.isSelected)
} else {
content
.foregroundColor(.primary)
.overlay(Capsule().stroke(Color.primary, lineWidth: lineWidth))
.padding(.all, lineWidth)
.opacity(isEnabled ? 1 : 0.5)
.accessibilityRemoveTraits(.isSelected)
}
}
}
2 changes: 1 addition & 1 deletion OrangeDesignSystemDemo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: f27533e868bea2f44cde6a3fca747074cfa663a6

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
Loading