Skip to content

Commit

Permalink
Merge branch 'qualif' into refactor/647_Code-Clean-Up
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovic35 authored Jan 29, 2024
2 parents 53bea30 + 382ad0b commit dfab1b3
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased](https://github.com/Orange-OpenSource/ods-ios/compare/0.16.0...qualif)

- [DemoApp/SDK] Code cleanup ([#647](https://github.com/Orange-OpenSource/ods-ios/issues/647)])
- [DemoApp/SDK] Components page accessibility issues (Bug [#563](https://github.com/Orange-OpenSource/ods-ios/issues/563))
- [SDK] Update Banners to align buttons when text is too long ([#642](https://github.com/Orange-OpenSource/ods-ios/issues/642))
- [SDK] Update Cards to align buttons when text is too long ([#630](https://github.com/Orange-OpenSource/ods-ios/issues/630))
- [Tooling] Upgrate to xcode 15 ([#638](https://github.com/Orange-OpenSource/ods-ios/issues/638))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public struct ODSAboutModule<TermsOfService>: View where TermsOfService: View {
private let headerIllustration: Image
private let applicationInformation: ODSAboutApplicationInformation
private let listItemConfigurations: [ODSAboutListItemConfig]
private let title: String

// ==================
// MARK: Initializers
Expand Down Expand Up @@ -68,6 +69,7 @@ public struct ODSAboutModule<TermsOfService>: View where TermsOfService: View {
]

self.listItemConfigurations = (listItemConfigurations + internalItemsConfig).sorted()
title = °°"modules.about.title"
}

// ==========
Expand All @@ -92,7 +94,7 @@ public struct ODSAboutModule<TermsOfService>: View where TermsOfService: View {
.padding(.bottom, ODSSpacing.s)
}
.listStyle(.plain)
.navigationTitle(°°"modules.about.title")
.odsNavigationTitle(title)
.navigationBarTitleDisplayMode(.large)
.background(ODSInternalColor.primaryBackground.color)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Software Name: Orange Design System
// SPDX-FileCopyrightText: Copyright (c) Orange SA
// SPDX-License-Identifier: MIT
//
// This software is distributed under the MIT licence,
// the text of which is available at https://opensource.org/license/MIT/
// or see the "LICENSE" file for more details.
//
// Authors: See CONTRIBUTORS.txt
// Software description: A SwiftUI components library with code examples for Orange Design System
//

import Foundation
import SwiftUI

/// `ViewModifier` which defines a navigation title for the calling `View` and also use `UIAccessibility` to notify for screen changed.
/// The title can be a wording key which will be localized.
struct AccssibleNavigationTitleModifier: ViewModifier {

let title: String

func body(content: Content) -> some View {
content
.navigationTitle(title)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
UIAccessibility.post(notification: .screenChanged, argument: title)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Software Name: Orange Design System
// SPDX-FileCopyrightText: Copyright (c) Orange SA
// SPDX-License-Identifier: MIT
//
// This software is distributed under the MIT licence,
// the text of which is available at https://opensource.org/license/MIT/
// or see the "LICENSE" file for more details.
//
// Authors: See CONTRIBUTORS.txt
// Software description: A SwiftUI components library with code examples for Orange Design System
//

import Foundation
import SwiftUI

extension View {

/// Adds a modifier to the current `View` so as to define a naivgation title using the current `title`
/// and also send a notification for accessibility layers for a change of screen when appeared.
/// - Parameter title: The navigation title
/// - Returns View: The view with a new modifier
public func odsNavigationTitle(_ title: String) -> some View {
self.modifier(AccssibleNavigationTitleModifier(title: title))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
077C384A2A9DDC79003D6B51 /* CustomizableVariant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 077C37EF2A9DDC78003D6B51 /* CustomizableVariant.swift */; };
077C384B2A9DDC79003D6B51 /* ComponentPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 077C37F02A9DDC78003D6B51 /* ComponentPage.swift */; };
077C384C2A9DDC79003D6B51 /* Component.swift in Sources */ = {isa = PBXBuildFile; fileRef = 077C37F12A9DDC78003D6B51 /* Component.swift */; };
077C384D2A9DDC79003D6B51 /* ComponentList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 077C37F22A9DDC78003D6B51 /* ComponentList.swift */; };
077C384D2A9DDC79003D6B51 /* ComponentsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 077C37F22A9DDC78003D6B51 /* ComponentsList.swift */; };
077C384E2A9DDC79003D6B51 /* ButtonsComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 077C37F52A9DDC78003D6B51 /* ButtonsComponent.swift */; };
077C384F2A9DDC79003D6B51 /* IconVariant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 077C37F62A9DDC78003D6B51 /* IconVariant.swift */; };
077C38502A9DDC79003D6B51 /* EmphasisAndFunctionnalVariant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 077C37F72A9DDC79003D6B51 /* EmphasisAndFunctionnalVariant.swift */; };
Expand Down Expand Up @@ -188,7 +188,7 @@
077C37EF2A9DDC78003D6B51 /* CustomizableVariant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomizableVariant.swift; sourceTree = "<group>"; };
077C37F02A9DDC78003D6B51 /* ComponentPage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComponentPage.swift; sourceTree = "<group>"; };
077C37F12A9DDC78003D6B51 /* Component.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Component.swift; sourceTree = "<group>"; };
077C37F22A9DDC78003D6B51 /* ComponentList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComponentList.swift; sourceTree = "<group>"; };
077C37F22A9DDC78003D6B51 /* ComponentsList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComponentsList.swift; sourceTree = "<group>"; };
077C37F52A9DDC78003D6B51 /* ButtonsComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonsComponent.swift; sourceTree = "<group>"; };
077C37F62A9DDC78003D6B51 /* IconVariant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IconVariant.swift; sourceTree = "<group>"; };
077C37F72A9DDC79003D6B51 /* EmphasisAndFunctionnalVariant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmphasisAndFunctionnalVariant.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -435,7 +435,7 @@
children = (
077C37EE2A9DDC78003D6B51 /* Template */,
077C37F32A9DDC78003D6B51 /* Pages */,
077C37F22A9DDC78003D6B51 /* ComponentList.swift */,
077C37F22A9DDC78003D6B51 /* ComponentsList.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -1295,7 +1295,7 @@
077C37E62A9DDC1A003D6B51 /* MainTabView.swift in Sources */,
077C385D2A9DDC79003D6B51 /* ActivityIndicatorVariant.swift in Sources */,
077C38612A9DDC79003D6B51 /* CardExampleData.swift in Sources */,
077C384D2A9DDC79003D6B51 /* ComponentList.swift in Sources */,
077C384D2A9DDC79003D6B51 /* ComponentsList.swift in Sources */,
077C38512A9DDC79003D6B51 /* CapitalizedTextInputsVariant.swift in Sources */,
07B1A09C2B1E191F00ABF0A1 /* InputChipsVariant.swift in Sources */,
077C38632A9DDC79003D6B51 /* CardHorizontalVariant.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import SwiftUI

struct ComponentsList: View {

@Environment(\.sizeCategory) private var sizeCategory
@EnvironmentObject private var themeProvider: ThemeProvider

// =======================
// MARK: Stored Properties
// =======================

@EnvironmentObject private var themeProvider: ThemeProvider

let components: [Component]
let columns = [GridItem(.adaptive(minimum: 150.0), spacing: ODSSpacing.none, alignment: .center)]

Expand Down Expand Up @@ -55,15 +57,18 @@ struct ComponentsList: View {
var body: some View {
NavigationView {
ScrollView {
LazyVGrid(columns: columns, spacing: ODSSpacing.none) {
ForEach(components, id: \.id) { component in
smallCard(for: component)
if sizeCategory.isAccessibilityCategory {
smallCards()
.padding(.all, ODSSpacing.s)
} else {
LazyVGrid(columns: columns, spacing: ODSSpacing.none) {
smallCards()
}
.padding(.all, ODSSpacing.s)
}
.padding(.all, ODSSpacing.s)
}
.navigationTitle("main_view.tabs.components")
.navigationbarMenuForThemeSelection()
.odsNavigationTitle("main_view.tabs.components".🌐)

ComponentPage(component: components[0])
}
Expand All @@ -74,6 +79,12 @@ struct ComponentsList: View {
// MARK: Private helper
// =====================

private func smallCards() -> some View {
ForEach(components, id: \.id) { component in
smallCard(for: component)
}
}

private func smallCard(for component: Component) -> some View {
NavigationLink {
ComponentPage(component: component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import SwiftUI

struct GuidelinesList: View {

// ======================
// MARK: Store properties
// ======================

@EnvironmentObject private var themeProvider: ThemeProvider

// =======================
// MARK: Stored properties
// =======================

private let guidelines: [Guideline]
private let columns = [GridItem(.flexible(), alignment: .topLeading)]

Expand Down Expand Up @@ -51,8 +52,8 @@ struct GuidelinesList: View {
}
}
.padding(.all, ODSSpacing.m)
.navigationTitle("shared.guidelines")
.navigationbarMenuForThemeSelection()
.odsNavigationTitle("shared.guidelines".🌐)
}

GuidelinePage(guideline: guidelines[0]) // Why ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct SpacingsPageDescription: View {
// ======================

private let spacings = Spacing.allCases

// ==========
// MARK: Body
// ==========
Expand All @@ -34,6 +34,7 @@ struct SpacingsPageDescription: View {
.padding(.horizontal, ODSSpacing.m)
}
.padding(.bottom, ODSSpacing.m)
.accessibilityRespondsToUserInteraction(false) // Switch Control must not focus this view
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct ModulesList: View {
}
.padding(.all, ODSSpacing.m)
}
.navigationTitle("shared.modules")
.odsNavigationTitle("shared.modules".🌐)
.navigationbarMenuForThemeSelection()
}
.navigationViewStyle(.stack)
Expand Down

0 comments on commit dfab1b3

Please sign in to comment.