Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SwiftUI
import UtilityLibrary

public struct MetadataDuration: View {
let text: String
Expand All @@ -15,5 +16,6 @@ public struct MetadataDuration: View {
.foregroundColor(.white)
.lineLimit(1)
.glassEffect(.clear, in: .rect(cornerRadius: 6))
.accessibilityLabel(text.accessibilityTime)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ private extension GlassCardView {
.cornerRadius(12)
}
.aspectRatio(ratio, contentMode: .fit)
.accessibilityHidden(true)
} else {
GeometryReader { geo in
CachedAsyncImage(image: imageUrl, contentMode: .fill)
.frame(width: geo.size.width, height: geo.size.height)
}
.accessibilityHidden(true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private extension LeadingImageCard {
CachedAsyncImage(image: artworkUrl, contentMode: .fill)
.frame(width: 100, height: 100)
.clipShape(RoundedRectangle(cornerRadius: CardMetrics.innerRadius, style: .continuous))
.accessibilityHidden(true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public struct MenuView<T: Hashable>: View where T: RawRepresentable, T.RawValue:
.padding(.horizontal, 20)
.padding(.vertical, 10)
.glassEffect(effect(selected: selected == option), in: .capsule)
.accessibilityAddTraits(selected == option ? .isSelected : [])
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public struct PaginatedForEach<Element: Identifiable, Content: View>: View {
}
if hasMore {
ProgressView()
.accessibilityLabel("Carregando mais conteúdo")
.frame(maxWidth: .infinity)
.padding()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct DisqusSheet: View {
Button(action: { onDismiss() },
label: { Image(systemName: "xmark") })
.tint(.primary)
.accessibilityLabel("Fechar")
}
}
}
Expand Down Expand Up @@ -70,6 +71,7 @@ struct DisqusSheet: View {
Button(action: { self.loginURL = nil },
label: { Image(systemName: "xmark") })
.tint(.primary)
.accessibilityLabel("Fechar")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public struct MMWebView: View {
Image(systemName: "xmark")
}
.tint(.primary)
.accessibilityLabel("Fechar")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct WebViewStatusOverlay: View {
switch status {
case .loading:
ProgressView()
.accessibilityLabel("Carregando conteúdo")
case let .error(error):
ContentUnavailableView(
"Estamos com um problema",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import MacMagazineUILibrary
import SwiftUI
import UtilityLibrary

enum CardLabel {
public enum CardLabel {
case title
case date
case author
Expand All @@ -26,7 +26,7 @@ private extension Array where Element == CardLabel {
}
}

enum CardButton {
public enum CardButton {
case share
case favorite
}
Expand All @@ -45,7 +45,7 @@ private extension Array where Element == CardButton {
}
}

extension View {
public extension View {
func cardAccessibility(
data: CardContent,
labels: [CardLabel]?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public struct FeedHighlightsCarouselView: View {
spacing: Layout.spacing
)
}
.accessibilityLabel(post.title)
.accessibilityHint("Duplo toque para abrir a notícia.")
.scrollTransition(.interactive) { content, phase in
content
.scaleEffect(phase.isIdentity ? 1.0 : 0.95)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ extension NewsView {
action: { readingNews = false },
label: { Image(systemName: "chevron.backward") })
.tint(.primary)
.accessibilityLabel("Voltar")
}
ToolbarItem(placement: .automatic) {
favoriteView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ private extension FullPlayerView {
.accessibilityHidden(true)
}
.padding(.horizontal, 20)
.dynamicTypeSize(.medium)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ struct SpeedWheelPicker<LeftIcon: View, RightIcon: View>: View {
.buttonStyle(.plain)
}
.frame(width: width, height: 40)
.dynamicTypeSize(.medium)
}

// MARK: - SCROLL BINDING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ struct MiniPlayerView: View {
.gesture(tapToOpen)
.gesture(tapToDismiss)
.matchedTransitionSource(id: "MINIPLAYER", in: animation)
.accessibilityAction(named: "Abrir player completo") {
playerManager.isFullscreen.toggle()
}
.accessibilityAction(named: "Fechar mini player") {
if playerManager.isPlaying {
playerManager.pause()
currentPodcast.save(current: playerManager.currentTime, using: modelContext)
}
playerManager.currentPodcast = nil
}
}

private var tapToOpen: some Gesture {
Expand Down Expand Up @@ -83,6 +93,7 @@ private extension MiniPlayerView {
Ticker(text: currentPodcast.title, speed: 30)
.frame(height: 30)
.id(currentPodcast.id)
.accessibilityLabel(currentPodcast.title)

HStack(spacing: 20) {
Button {
Expand All @@ -96,6 +107,7 @@ private extension MiniPlayerView {
.font(.system(size: 20))
}
.buttonStyle(.plain)
.accessibilityLabel("Voltar 15 segundos")

Button {
playerManager.togglePlayPause()
Expand All @@ -109,6 +121,7 @@ private extension MiniPlayerView {
.font(.system(size: 24))
}
.buttonStyle(.plain)
.accessibilityLabel(playerManager.isPlaying ? "Pausar" : "Reproduzir")

Button {
playerManager.skip(by: 15)
Expand All @@ -121,6 +134,7 @@ private extension MiniPlayerView {
.font(.system(size: 20))
}
.buttonStyle(.plain)
.accessibilityLabel("Avançar 15 segundos")
}
}
.foregroundStyle(controlsColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ struct RecentSearchesView: View {
HStack {
Text("Recentes")
.font(.headline)
.accessibilityAddTraits(.isHeader)
Spacer()
Button("Limpar") { onClear() }
.font(.subheadline)
.accessibilityLabel("Limpar buscas recentes")
}
.padding(.horizontal)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ private extension SearchResultsList {
NewsCard(data: cardContent) {
onSelectNews(feedDB)
}
.cardAccessibility(
data: cardContent,
labels: [NewsLibrary.CardLabel.title, NewsLibrary.CardLabel.date],
buttons: [NewsLibrary.CardButton.favorite, NewsLibrary.CardButton.share]
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PodcastLibrary
import StorageLibrary
import SwiftUI
import UIComponentsLibrary
import UIKit
import YouTubeLibrary

public struct SearchView: View {
Expand Down Expand Up @@ -50,6 +51,7 @@ public struct SearchView: View {
}
.onChange(of: viewModel.status) { _, newStatus in
trackSearchCompletion(newStatus)
announceSearchStatus(newStatus)
}
.navigationDestination(isPresented: $showingWebView) {
details
Expand Down Expand Up @@ -248,6 +250,25 @@ private extension SearchView {
break
}
}

func announceSearchStatus(_ status: SearchStatus) {
let message: String
switch status {
case .searching:
message = "Buscando..."
case .done:
if viewModel.results.isEmpty {
message = "Nenhum resultado encontrado"
} else {
message = "\(viewModel.results.count) resultados encontrados"
}
case .error:
message = "Erro na busca"
case .idle, .localResults:
return
}
UIAccessibility.post(notification: .announcement, argument: message)
}
}

// MARK: - Layout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ private struct ContentSheet: View {
Button(action: onDismiss,
label: { Image(systemName: "xmark") })
.tint(.primary)
.accessibilityLabel("Fechar")
}
}
.onChange(of: colorScheme) {
Expand Down Expand Up @@ -177,6 +178,7 @@ private struct PatronLoginSheet: View {
Button(action: onDismiss,
label: { Image(systemName: "xmark") })
.tint(.primary)
.accessibilityLabel("Fechar")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct DeepLinkNewsDetailView: View {
Button(action: onDismiss,
label: { Image(systemName: "xmark") })
.tint(.primary)
.accessibilityLabel("Fechar")
}
ToolbarItem(placement: .automatic) {
favoriteView
Expand Down
2 changes: 1 addition & 1 deletion MacMagazine/MacMagazine/Features/Social/SocialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private extension SocialView {
var optionsView: some View {
@Bindable var bindableViewModel = viewModel

Picker("", selection: $bindableViewModel.social) {
Picker("Seção social", selection: $bindableViewModel.social) {
ForEach(viewModel.settingsViewModel.social, id: \.self) { option in
Text(option.rawValue).tag(option)
}
Expand Down
48 changes: 48 additions & 0 deletions MacMagazine/Widget/Extensions/WidgetAccessibility+View.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import SwiftUI
import WidgetKit

private enum WidgetAccessibility {
static let label = "MacMagazine"
static let hint = "Toque para abrir as notícias"
}

// MARK: - Generic (inline / rectangular)

extension View {

func widgetAccessibility(
url: URL?,
lastPostTitle: String,
children: AccessibilityChildBehavior? = nil
) -> some View {
Group {
if let children {
self
.accessibilityElement(children: children)
.accessibilityLabel(WidgetAccessibility.label)
.accessibilityValue("Última notícia: \(lastPostTitle)")
.accessibilityHint(WidgetAccessibility.hint)
} else {
self
.accessibilityLabel(WidgetAccessibility.label)
.accessibilityValue("Última notícia: \(lastPostTitle)")
.accessibilityHint(WidgetAccessibility.hint)
}
}
.widgetURL(url)
}

// MARK: - Rectangular (multi-item)

func widgetRectangularAccessibility(
url: URL?,
accessibilityValue: String
) -> some View {
self
.accessibilityElement(children: .combine)
.accessibilityLabel(WidgetAccessibility.label)
.accessibilityValue(accessibilityValue)
.accessibilityHint(WidgetAccessibility.hint)
.widgetURL(url)
}
}
16 changes: 12 additions & 4 deletions MacMagazine/Widget/Views/WidgetElementView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ struct WidgetElementView: View {
@ViewBuilder
var body: some View {
switch widgetFamily {
case .systemSmall: smallWidget.widgetURL(post.url)
case .accessoryInline: accessoryInlineWidget
case .accessoryRectangular: accessoryRectangularWidget
default: Link(destination: post.url) { content }
case .systemSmall:
smallWidget
.widgetAccessibility(url: post.url, lastPostTitle: post.title)
case .accessoryInline:
accessoryInlineWidget
.widgetAccessibility(url: post.url, lastPostTitle: post.title)
case .accessoryRectangular:
accessoryRectangularWidget
.widgetAccessibility(url: post.url, lastPostTitle: post.title)
default:
Link(destination: post.url) { content }
.widgetAccessibility(url: nil, lastPostTitle: post.title)
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions MacMagazine/Widget/Views/WidgetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ struct WidgetView: View {
id: \.self) { index in
WidgetElementView(post: content[index])
}.header(title: "Últimas notícias", spacing: widgetFamily.spacing)
.widgetRectangularAccessibility(
url: content.first?.url,
accessibilityValue: content.prefix(quantity).map(\.title).joined(separator: "; ")
)
.trackScreen(AnalyticsConstants.Screen.widget(widgetFamily.description).name, analytics: analytics)
}
}
Expand Down
Loading