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

Fix for Small banner and added more Accessibility labels #31

Merged
merged 1 commit into from
Nov 26, 2023
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 Sources/Billboard/Views/BillboardAdInfoLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct BillboardAdInfoLabel: View {
.offset(x:0.5)
}
.frame(width: 22, height: 14)
.accessibilityLabel(Text("Advertisement"))
}
}

Expand Down
56 changes: 31 additions & 25 deletions Sources/Billboard/Views/BillboardBannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public struct BillboardBannerView : View {

public var body: some View {

HStack(spacing: 10) {
ZStack(alignment: .trailing) {
Button {
if let url = advert.appStoreLink {
openURL(url)
Expand All @@ -41,9 +41,10 @@ public struct BillboardBannerView : View {
.resizable()
.frame(width: 60, height: 60)
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
.accessibilityHidden(true)
}

VStack(alignment: .leading, spacing: 4) {

BillboardAdInfoLabel(advert: advert)

VStack(alignment: .leading) {
Expand All @@ -58,42 +59,47 @@ public struct BillboardBannerView : View {
.opacity(0.8)
}
}
.accessibilityHidden(true)
Spacer()
}
.padding(.trailing, hideDismissButtonAndTimer ? 0: 40)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
Spacer()

if !hideDismissButtonAndTimer {
if canDismiss {
Button {
if config.allowHaptics {
haptics(.light)
}

withAnimation(.spring()) {
Group {
if !hideDismissButtonAndTimer {
if canDismiss {
Button {
if config.allowHaptics {
haptics(.light)
}
showAdvertisement = false
} label: {
Label("Dismiss advertisement", systemImage: "xmark.circle.fill")
.labelStyle(.iconOnly)
.font(.compatibleSystem(.title2, design: .rounded, weight: .bold))
.symbolRenderingMode(.hierarchical)
.imageScale(.large)
.controlSize(.large)
}

} label: {
Label("Dismiss advertisement", systemImage: "xmark.circle.fill")
.labelStyle(.iconOnly)
.font(.compatibleSystem(.title2, design: .rounded, weight: .bold))
.symbolRenderingMode(.hierarchical)
.imageScale(.large)
.controlSize(.large)
.tint(advert.tint)
} else {
BillboardCountdownView(advert:advert,
totalDuration: config.duration,
canDismiss: $canDismiss)
.padding(.trailing, 2)
}
.tint(advert.tint)
} else {
BillboardCountdownView(advert:advert,
totalDuration: config.duration,
canDismiss: $canDismiss)
.padding(.trailing, 2)
}
}
.padding(.trailing, 9)
}
.accessibilityLabel(Text("\(advert.name), \(advert.title)"))
.padding(10)
.background(backgroundView)
.overlay(RoundedRectangle(cornerRadius: 16, style: .continuous).stroke(Color.primary.opacity(0.1), lineWidth: 1))
.animation(.spring(), value: showAdvertisement)
.task {
await fetchAppIcon()
}
Expand Down Expand Up @@ -139,7 +145,7 @@ struct BillboardBannerView_Previews: PreviewProvider {
static var previews: some View {
VStack {
BillboardBannerView(advert: BillboardSamples.sampleDefaultAd)
BillboardBannerView(advert: BillboardSamples.sampleDefaultAd, includeShadow: false)
BillboardBannerView(advert: BillboardSamples.sampleDefaultAd, hideDismissButtonAndTimer: true)
}
.padding()

Expand Down
Loading