Skip to content

Commit

Permalink
bug: Fixed Music Subscription prompt not being presented (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
onl1ner committed Apr 10, 2024
1 parent 6e40863 commit 075e829
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
6 changes: 4 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ autolabeler:
branch:
- '/fix.+/i'
replacers:
- search: '/((?:feature|bug):\s*)/i'
- search: '/(feature:|bug:)\s*/i'
replace: ''
exclude-labels:
- "release"
header: |
![](./resources/banner-release-universal.png)
<img src="./.github/resources/banner-release-universal" width="100%">
<br />
<br />
template: |
## What's new?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,10 @@ struct MusicSubscriptionPrompt: View {

var body: some View {
VStack(alignment: .leading, spacing: 16.0) {
HStack {
Image("Common/AppleMusic")
.resizable()
.scaledToFit()
.frame(width: 40.0, height: 40.0)

Spacer()

Image(systemName: "xmark.circle.fill")
.font(.system(size: 16.0))
.foregroundStyle(.white)
.tappable {
self.musicManager.subscription.isOffering = false
}
}
Image("Common/AppleMusic")
.resizable()
.scaledToFit()
.frame(width: 40.0, height: 40.0)

VStack(alignment: .leading, spacing: 8.0) {
Text("Join Apple Music")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension MusicManager {
@MainActor
final class Subscription: ObservableObject {
@Published var status: MusicSubscription?
@Published var isOffering: Bool = false
@Published var needsOffer: Bool = false

var canOffer: Bool {
return self.status?.canBecomeSubscriber ?? false
Expand All @@ -24,13 +24,14 @@ extension MusicManager {

func offer() {
guard self.canOffer else { return }
self.isOffering = true
self.needsOffer = true
}

private func startObservation() {
Task {
for await subscription in MusicSubscription.subscriptionUpdates {
self.status = subscription
self.needsOffer = subscription.canBecomeSubscriber
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions mupl/Supporting Files/App/muplApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct muplApp: App {
self.prompt {
MusicAuthorizationPrompt()
}
} else if self.musicManager.subscription.isOffering {
} else if self.musicManager.subscription.needsOffer {
self.prompt {
MusicSubscriptionPrompt()
}
Expand All @@ -37,7 +37,7 @@ struct muplApp: App {
}
.transition(.opacity)
.animation(.easeIn(duration: 0.2), value: self.musicManager.authorization.status)
.animation(.easeIn(duration: 0.2), value: self.musicManager.subscription.isOffering)
.animation(.easeIn(duration: 0.2), value: self.musicManager.subscription.needsOffer)
}
.environmentObject(self.musicManager)
.environmentObject(self.musicCatalog)
Expand Down Expand Up @@ -66,9 +66,9 @@ struct muplApp: App {

private func prompt<Content: View>(@ViewBuilder _ content: () -> Content) -> some View {
ZStack {
Color.black
.opacity(0.8)
Color.clear
.ignoresSafeArea()
.background(.ultraThinMaterial)

content()
}
Expand Down

0 comments on commit 075e829

Please sign in to comment.