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

Change payment method prompt from alert view to action sheet #4656

Merged
merged 2 commits into from Oct 12, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Wikipedia/Code/ArticleViewController+Announcements.swift
Expand Up @@ -89,7 +89,7 @@ extension ArticleViewController {
wmf_showFundraisingAnnouncement(theme: theme, asset: asset, primaryButtonTapHandler: { sender in

AppInteractionFunnel.shared.logFundraisingCampaignModalDidTapDonate(project: project)
self.pushToDonateForm(asset: asset)
self.pushToDonateForm(asset: asset, sourceView: sender as? UIButton)
dataController.markAssetAsPermanentlyHidden(asset: asset)

}, secondaryButtonTapHandler: { sender in
Expand Down Expand Up @@ -122,7 +122,7 @@ extension ArticleViewController {
}, showMaybeLater: shouldShowMaybeLater)
}

private func pushToDonateForm(asset: WKFundraisingCampaignConfig.WKAsset) {
private func pushToDonateForm(asset: WKFundraisingCampaignConfig.WKAsset, sourceView: UIView?) {
let firstAction = asset.actions[0]
let donateURL = firstAction.url

Expand All @@ -140,7 +140,7 @@ extension ArticleViewController {

if canOfferNativeDonateForm(countryCode: asset.countryCode, currencyCode: asset.currencyCode, languageCode: asset.languageCode, bannerID: utmSource, appVersion: appVersion),
let donateURL = donateURL {
presentNewDonorExperiencePaymentMethodActionSheet(donateSource: .articleCampaignModal, countryCode: asset.countryCode, currencyCode: asset.currencyCode, languageCode: asset.languageCode, donateURL: donateURL, bannerID: utmSource, appVersion: appVersion, articleURL: articleURL, loggingDelegate: self)
presentNewDonorExperiencePaymentMethodActionSheet(donateSource: .articleCampaignModal, countryCode: asset.countryCode, currencyCode: asset.currencyCode, languageCode: asset.languageCode, donateURL: donateURL, bannerID: utmSource, appVersion: appVersion, articleURL: articleURL, sourceView: sourceView, loggingDelegate: self)
} else {
self.navigate(to: donateURL, userInfo: [
RoutingUserInfoKeys.campaignArticleURL: articleURL as Any,
Expand Down
8 changes: 6 additions & 2 deletions Wikipedia/Code/UIViewController+DonateHelpers.swift
Expand Up @@ -118,7 +118,7 @@ import PassKit
navigationController?.pushViewController(donateViewController, animated: true)
}

@objc func presentNewDonorExperiencePaymentMethodActionSheet(donateSource: DonateSource, countryCode: String, currencyCode: String, languageCode: String, donateURL: URL, bannerID: String?, appVersion: String?, articleURL: URL?, loggingDelegate: WKDonateLoggingDelegate?) {
@objc func presentNewDonorExperiencePaymentMethodActionSheet(donateSource: DonateSource, countryCode: String, currencyCode: String, languageCode: String, donateURL: URL, bannerID: String?, appVersion: String?, articleURL: URL?, sourceView: UIView?, loggingDelegate: WKDonateLoggingDelegate?) {

let wikimediaProject: WikimediaProject?
if let articleURL {
Expand All @@ -135,7 +135,7 @@ import PassKit

let cancelButtonTitle = CommonStrings.cancelActionTitle

let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let alert = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)

alert.addAction(UIAlertAction(title: cancelButtonTitle, style: .cancel, handler: { action in
if donateSource == .articleCampaignModal,
Expand Down Expand Up @@ -192,6 +192,10 @@ import PassKit

alert.preferredAction = applePayAction

if let popoverPresentationController = alert.popoverPresentationController {
popoverPresentationController.sourceView = sourceView
}

let presentationVC = donateSource == .articleCampaignModal ? presentedViewController : self
presentationVC?.present(alert, animated: true)
}
Expand Down
2 changes: 1 addition & 1 deletion Wikipedia/Code/WMFSettingsViewController.m
Expand Up @@ -305,7 +305,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

NSString *appVersion = [[NSBundle mainBundle] wmf_debugVersion];
if ([self canOfferNativeDonateFormWithCountryCode:countryCode currencyCode:currencyCode languageCode:languageCode bannerID:nil appVersion: appVersion]) {
[self presentNewDonorExperiencePaymentMethodActionSheetWithDonateSource: DonateSourceSettings countryCode:countryCode currencyCode:currencyCode languageCode:languageCode donateURL:self.donationURL bannerID:nil appVersion: appVersion articleURL:nil loggingDelegate:self];
[self presentNewDonorExperiencePaymentMethodActionSheetWithDonateSource: DonateSourceSettings countryCode:countryCode currencyCode:currencyCode languageCode:languageCode donateURL:self.donationURL bannerID:nil appVersion: appVersion articleURL:nil sourceView: cell loggingDelegate:self];
} else {
// New experience pushing to in-app browser
[self wmf_navigateToURL:[self donationURL] useSafari:NO];
Expand Down