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

In-App Updates: Update blocking modal UI #23220

Merged
merged 2 commits into from
May 22, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class AppUpdatePresenter: AppUpdatePresenterProtocol {
guard let window = UIApplication.sharedIfAvailable()?.mainWindow,
let topViewController = window.topmostPresentedViewController,
!((topViewController as? UINavigationController)?.viewControllers.first is BlockingUpdateViewController) else {
wpAssertionFailure("Failed to show blocking update view")
// Don't show if the view is already being displayed
return
}
let viewModel = AppStoreInfoViewModel(appStoreInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ struct AppStoreInfoViewModel {
let message = Strings.message
let whatsNewTitle = Strings.whatsNew
let updateButtonTitle = Strings.Actions.update
let latestVersionButtonTitle = Strings.Actions.latestVersion
let cancelButtonTitle = Strings.Actions.cancel
let moreInfoButtonTitle = Strings.Actions.moreInfo

init(_ appStoreInfo: AppStoreLookupResponse.AppStoreInfo) {
self.appName = appStoreInfo.trackName
Expand All @@ -27,7 +27,7 @@ private enum Strings {

enum Actions {
static let update = NSLocalizedString("appUpdate.action.update", value: "Update", comment: "Update button title")
static let latestVersion = NSLocalizedString("appUpdate.action.latestVersion", value: "Get the latest version", comment: "Get the latest version button title")
static let cancel = NSLocalizedString("appUpdate.action.cancel", value: "Cancel", comment: "Cancel button title")
static let moreInfo = NSLocalizedString("appUpdate.action.moreInfo", value: "More info", comment: "More info button title")
}
}
22 changes: 7 additions & 15 deletions WordPress/Classes/ViewRelated/AppUpdate/BlockingUpdateView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import UIKit
import StoreKit

final class BlockingUpdateViewController: UIHostingController<BlockingUpdateView> {
init(viewModel: AppStoreInfoViewModel, onUpdateTapped: @escaping () -> Void) {
super.init(rootView: .init(viewModel: viewModel, onUpdateTapped: onUpdateTapped))
init(viewModel: AppStoreInfoViewModel, onButtonTapped: @escaping () -> Void) {
super.init(rootView: .init(viewModel: viewModel, onButtonTapped: onButtonTapped))
}

@MainActor required dynamic init?(coder aDecoder: NSCoder) {
Expand All @@ -15,7 +15,7 @@ final class BlockingUpdateViewController: UIHostingController<BlockingUpdateView

struct BlockingUpdateView: View {
let viewModel: AppStoreInfoViewModel
let onUpdateTapped: (() -> Void)
let onButtonTapped: (() -> Void)

var body: some View {
VStack(alignment: .leading, spacing: 8) {
Expand All @@ -36,7 +36,10 @@ struct BlockingUpdateView: View {

Spacer()

buttonsView
DSButton(title: viewModel.latestVersionButtonTitle, style: .init(emphasis: .primary, size: .large)) {
onButtonTapped()
}
.padding(.bottom, 20)
}
.padding([.leading, .trailing], 20)
.interactiveDismissDisabled()
Expand Down Expand Up @@ -80,15 +83,4 @@ struct BlockingUpdateView: View {
}
}
}

private var buttonsView: some View {
VStack {
DSButton(title: viewModel.updateButtonTitle, style: .init(emphasis: .primary, size: .large)) {
onUpdateTapped()
}
DSButton(title: viewModel.moreInfoButtonTitle, style: .init(emphasis: .tertiary, size: .large)) {
// Todo
}
}
}
}