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

[Woo POS] M2: Exit POS modal presentation #13530

Merged
merged 11 commits into from
Aug 9, 2024
Merged

Conversation

bozidarsevo
Copy link
Contributor

@bozidarsevo bozidarsevo commented Aug 7, 2024

Closes: #13278

Description

As a part of M2, info modal for exiting POS is added.
When user taps the three dot button in floating action control and taps "Exit POS" we present this info modal where user had the option to either exit POS or close the modal.
This way we are adding one more step of confirmation to make sure users to not exit POS by accident.

Testing information

  • Enter POS
  • Tap three dot button in floating action control
  • Check that the Exit POS modal is shown
  • Tap on the X button and check that the modal is dismissed but you are still in POS
  • Tap three dot button in floating action control again
  • Tap on the "Exit" button and check that you have exited POS successfully

Screenshots

Simulator Screenshot - iPad Pro (11-inch) (4th generation) 17 2 - 2024-08-07 at 15 39 38

Simulator.Screen.Recording.-.iPad.Pro.11-inch.4th.generation.17.2.-.2024-08-07.at.15.29.05.mp4

  • I have considered adding unit tests for this change. If I decided not to add them, I have provided a brief explanation below (optional):
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.
  • This PR includes refactoring; smoke testing of the entire section is needed.

@bozidarsevo bozidarsevo added this to the 19.9 milestone Aug 7, 2024
@@ -9,7 +9,7 @@ enum PointOfSaleAssets: CaseIterable {
case exit
case getSupport
case removeCartItem
case dismissProductsBanner
case xClose
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this since it is being used in various places so I wanted to make it a bit more generic

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We spoke about with @joshheald offline but it would make sense to use SF symbols rather than images for most of these. xmark represents the same symbol, so we could use Image(systemName: "xmark").

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #13458

@dangermattic
Copy link
Collaborator

dangermattic commented Aug 7, 2024

1 Warning
⚠️ This PR is assigned to the milestone 19.9. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

Comment on lines 79 to 81
.padding(.bottom)
.padding(.bottom)
.padding(.bottom)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this ok? I was trying to avoid writing explicit numbers for padding but wanted to make it be like on Figma designs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to use an explicit number for padding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can define it in one of the shared Layout structs, or the Constants enum for this view

Comment on lines +6 to +7
let fixedWidth: Bool
let fixedHeight: Bool
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this properties to allow more flexible usage/layout of the POS modals

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 7, 2024

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr13530-358d15c
Version19.8
Bundle IDcom.automattic.alpha.woocommerce
Commit358d15c
App Center BuildWooCommerce - Prototype Builds #10297
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@bozidarsevo bozidarsevo marked this pull request as ready for review August 7, 2024 14:00
Copy link
Collaborator

@staskus staskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good!

I left a couple of suggestions 👍

@@ -9,7 +9,7 @@ enum PointOfSaleAssets: CaseIterable {
case exit
case getSupport
case removeCartItem
case dismissProductsBanner
case xClose
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We spoke about with @joshheald offline but it would make sense to use SF symbols rather than images for most of these. xmark represents the same symbol, so we could use Image(systemName: "xmark").

@@ -59,6 +59,37 @@ struct PointOfSaleDashboardView: View {
}
}
})
.posModal(isPresented: $viewModel.showExitPOSModal, fixedWidth: false, fixedHeight: false, content: {
VStack(spacing: 0 ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move it to a separate method or a file just as we have with PointOfSaleCardPresentPaymentAlert to keep this method cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.foregroundColor(Color.posTertiaryTexti3)
}
}
Text("Exit Point of Sale mode?")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localized string

@@ -3,4 +3,6 @@ import SwiftUI
extension Font {
static let posBody: Font = Font.system(size: UIFontMetrics.default.scaledValue(for: 24))
static let posTitle: Font = Font.largeTitle
static let posModalBody: Font = Font.system(size: UIFontMetrics.default.scaledValue(for: 24))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the same as posBody and posTitle TfaZ4LUkEwEGrxfnEFzvJj-fi-3385_18076

We have a task to clearly define all the fonts from specification and maybe we should do it sooner rather than later. For this PR I suggest using the existing font definitions.

Comment on lines 79 to 81
.padding(.bottom)
.padding(.bottom)
.padding(.bottom)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to use an explicit number for padding.

Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bozidarsevo Some suggested changes – main one is the removal of fixedHeight: false for the connection modals, so they stay a consistent size throughout.

@@ -9,7 +9,7 @@ enum PointOfSaleAssets: CaseIterable {
case exit
case getSupport
case removeCartItem
case dismissProductsBanner
case xClose
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #13458

Comment on lines 79 to 81
.padding(.bottom)
.padding(.bottom)
.padding(.bottom)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can define it in one of the shared Layout structs, or the Constants enum for this view

@@ -46,7 +46,7 @@ struct PointOfSaleDashboardView: View {
.animation(.easeInOut, value: viewModel.isInitialLoading)
.background(Color.posBackgroundGreyi3)
.navigationBarBackButtonHidden(true)
.posModal(isPresented: $totalsViewModel.showsCardReaderSheet, content: {
.posModal(isPresented: $totalsViewModel.showsCardReaderSheet, fixedHeight: false, content: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.posModal(isPresented: $totalsViewModel.showsCardReaderSheet, fixedHeight: false, content: {
.posModal(isPresented: $totalsViewModel.showsCardReaderSheet, content: {

Height should be fixed – otherwise the card reader connection modal changes size as the connection progresses, which is quite distracting.

Comment on lines 64 to 71
HStack {
Spacer()
Button {
viewModel.showExitPOSModal = false
} label: {
Image(PointOfSaleAssets.xClose.imageName)
.frame(width: Constants.closeIconSize, height: Constants.closeIconSize)
.foregroundColor(Color.posTertiaryTexti3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could consider putting all this in a
.overlay(alignment: .topTrailing) modifier – see FeatureAnnouncementCardView for an example

.padding(.bottom)
.padding(.bottom)
Button {
presentationMode.wrappedValue.dismiss()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
presentationMode.wrappedValue.dismiss()
dismiss()

This is pre-existing, but it would be nice to shift to using:

@Environment(\.dismiss) private var dismiss

for dismissal, as it's a bit more readable.

Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:
I made a change so it just needs the binding to dismiss the modal, not the whole vm.

Comment on lines 5 to 9
@ObservedObject private var viewModel: PointOfSaleDashboardViewModel

init(viewModel: PointOfSaleDashboardViewModel) {
self.viewModel = viewModel
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if this just had the isPresented binding, not the whole view model

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 358d15c

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good point, tnx!

@bozidarsevo bozidarsevo merged commit 2a72a74 into trunk Aug 9, 2024
22 checks passed
@bozidarsevo bozidarsevo deleted the issue/13278-exit-pos-modal branch August 9, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Woo POS] M2: Exit POS modal presentation
5 participants