Page MenuHomePhabricator

[Spike] Investigate sharing entire review
Closed, ResolvedPublic2 Estimated Story Points

Description

We can already successfully generate and share a single slide image from Year in Review V2. For V3, we want a "Share entire review' button. With this spike we want to investigate if it's possible to generate multiple images from that button (this would be a snapshot of each slide in the review), and share them to a social media platform like Instagram from the share sheet. Document any difficulties, or if successful, take a screencast of the behavior to demo to Product.

Timebox: 2 days

Event Timeline

Tsevener set the point value for this task to 2.Aug 20 2025, 7:26 PM

We can very easily add something like this code block below

func handleShareAll() {
    var snapshots: [UIImage] = []

    for slide in slides {
        switch slide {
        case .standard(let viewModel):
            let view = WMFYearInReviewSlideStandardShareableView(viewModel: viewModel, hashtag: hashtag)
            snapshots.append(view.snapshot())
        case .location:
            // todo
            break
        }
    }

    coordinatorDelegate?.handleYearInReviewAction(.shareAll(images: snapshots))
}

All this does is iterate through all of the slides, create the view, then does the shareAll action I created.

case .shareAll(let images):
    guard let viewModel else { return }

    let contentProvider = YiRShareActivityContentProvider(
        text: viewModel.localizedStrings.shareText,
        appStoreURL: viewModel.shareLink,
        hashtag: viewModel.hashtag
    )

    let imageProviders = images.map {
        ShareAFactActivityImageItemProvider(image: $0)
    }

    let activityItems: [Any] = [contentProvider] + imageProviders

    let activityController = UIActivityViewController(
        activityItems: activityItems,
        applicationActivities: nil
    )
    activityController.excludedActivityTypes = [.print, .assignToContact, .addToReadingList]

    if let visibleVC = self.navigationController.visibleViewController {
        if let popover = activityController.popoverPresentationController {
            popover.sourceRect = visibleVC.view.bounds
            popover.sourceView = visibleVC.view
            popover.permittedArrowDirections = []
        }

        visibleVC.present(activityController, animated: true, completion: nil)
    }

This copies the individual code for creating one image, but creates multiple.

A lot of sharing capabilities seem to come 'for free' here, at least for Instagram, and I would assume that it would work with other popular apps as well.

see video here