Skip to content

Commit

Permalink
Merge pull request #535 from Automattic/task/eoy-hide-share-text
Browse files Browse the repository at this point in the history
End of Year: Hide "next story" text when being shared
  • Loading branch information
emilylaguna authored Nov 18, 2022
2 parents 4156787 + cb78731 commit 28095c0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions podcasts/End of Year/Stories/EpilogueStory.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import SwiftUI

struct EpilogueStory: StoryView {
@Environment(\.renderForSharing) var renderForSharing: Bool
var duration: TimeInterval = 5.seconds

var identifier: String = "epilogue"
Expand Down Expand Up @@ -53,6 +54,7 @@ struct EpilogueStory: StoryView {
}
.buttonStyle(ReplayButtonStyle())
.padding(.top, 20)
.opacity(renderForSharing ? 0 : 1)
}
.padding()
}
Expand Down
3 changes: 2 additions & 1 deletion podcasts/End of Year/Stories/ListenedCategoriesStory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PocketCastsServer
import PocketCastsDataModel

struct ListenedCategoriesStory: StoryView {
@Environment(\.renderForSharing) var renderForSharing: Bool
var duration: TimeInterval = 5.seconds

let listenedCategories: [ListenedCategory]
Expand Down Expand Up @@ -40,7 +41,7 @@ struct ListenedCategoriesStory: StoryView {
.multilineTextAlignment(.center)
.frame(maxHeight: geometry.size.height * 0.07)
.minimumScaleFactor(0.01)
.opacity(0.8)
.opacity(renderForSharing ? 0.0 : 0.8)
}
.padding(.trailing, 40)
.padding(.leading, 40)
Expand Down
4 changes: 3 additions & 1 deletion podcasts/End of Year/Stories/ListenedNumbersStory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import PocketCastsServer
import PocketCastsDataModel

struct ListenedNumbersStory: StoryView {
@Environment(\.renderForSharing) var renderForSharing: Bool

var duration: TimeInterval = 5.seconds

let identifier: String = "number_of_podcasts_and_episodes_listened"
Expand Down Expand Up @@ -70,7 +72,7 @@ struct ListenedNumbersStory: StoryView {
.multilineTextAlignment(.center)
.frame(maxHeight: geometry.size.height * 0.07)
.minimumScaleFactor(0.01)
.opacity(0.8)
.opacity(renderForSharing ? 0.0 : 0.8)
.padding(.bottom, geometry.size.height * 0.18)
}
.padding(.trailing, 40)
Expand Down
12 changes: 12 additions & 0 deletions podcasts/End of Year/StoryShareableProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,22 @@ class StoryShareableProvider: UIActivityItemProvider {
let snapshot = ZStack {
AnyView(view)
}
.environment(\.renderForSharing, true)
.frame(width: 370, height: 658)
.snapshot()

generatedItem = snapshot
self.view = nil
}
}

extension EnvironmentValues {
var renderForSharing: Bool {
get { self[RenderSharingKey.self] }
set { self[RenderSharingKey.self] = newValue }
}

private struct RenderSharingKey: EnvironmentKey {
static let defaultValue: Bool = false
}
}

0 comments on commit 28095c0

Please sign in to comment.