-
Notifications
You must be signed in to change notification settings - Fork 110
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
Changes from 10 commits
02ae6d3
5240dad
6cb21d9
047c059
212a98b
57e7cd6
447abe6
d45868d
921e982
2862373
358d15c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import SwiftUI | ||
|
||
struct PointOfSaleExitPosAlertView: View { | ||
@Environment(\.dismiss) private var dismiss | ||
@ObservedObject private var viewModel: PointOfSaleDashboardViewModel | ||
|
||
init(viewModel: PointOfSaleDashboardViewModel) { | ||
self.viewModel = viewModel | ||
} | ||
|
||
var body: some View { | ||
VStack(spacing: 0 ) { | ||
HStack { | ||
Spacer() | ||
Button { | ||
viewModel.showExitPOSModal = false | ||
} label: { | ||
Image(systemName: "xmark") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: Constants.closeIconSize, height: Constants.closeIconSize) | ||
.foregroundColor(Color.posTertiaryTexti3) | ||
} | ||
.frame(width: Constants.closeButtonSize, height: Constants.closeButtonSize) | ||
} | ||
Text(Localization.exitTitle) | ||
.font(.posModalTitle) | ||
.padding(.bottom, Constants.titleBottomPadding) | ||
Text(Localization.exitBody) | ||
.font(.posModalBody) | ||
.padding(.bottom, Constants.bodyBottomPadding) | ||
Button { | ||
dismiss() | ||
} label: { | ||
Text(Localization.exitButton) | ||
} | ||
.buttonStyle(POSPrimaryButtonStyle()) | ||
} | ||
.padding(Constants.padding) | ||
} | ||
} | ||
|
||
private extension PointOfSaleExitPosAlertView { | ||
enum Constants { | ||
static let titleBottomPadding: CGFloat = 20.0 | ||
static let bodyBottomPadding: CGFloat = 60.0 | ||
static let padding: CGFloat = 40.0 | ||
static let closeIconSize: CGFloat = 30.0 | ||
static let closeButtonSize: CGFloat = 40.0 | ||
} | ||
|
||
enum Localization { | ||
static let exitTitle = NSLocalizedString( | ||
"pos.exitPOSModal.exitTitle", | ||
value: "Exit Point of Sale mode?", | ||
comment: "Title of the exit Point of Sale modal alert" | ||
) | ||
static let exitBody = NSLocalizedString( | ||
"pos.exitPOSModal.exitBody", | ||
value: "Any orders in progress will be lost.", | ||
comment: "Body text of the exit Point of Sale modal alert" | ||
) | ||
static let exitButton = NSLocalizedString( | ||
"pos.exitPOSModal.exitButtom", | ||
value: "Exit", | ||
comment: "Button text of the exit Point of Sale modal alert" | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ import SwiftUI | |
struct POSModalViewModifier<ModalContent: View>: ViewModifier { | ||
@Binding var isPresented: Bool | ||
let modalContent: () -> ModalContent | ||
let fixedWidth: Bool | ||
let fixedHeight: Bool | ||
Comment on lines
+6
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
@Environment(\.sizeCategory) var sizeCategory | ||
|
||
|
@@ -18,8 +20,8 @@ struct POSModalViewModifier<ModalContent: View>: ViewModifier { | |
|
||
modalContent() | ||
.frame( | ||
width: min(frameWidth, windowBounds.width), | ||
height: min(frameHeight, windowBounds.height)) | ||
width: fixedWidth ? min(frameWidth, windowBounds.width) : nil, | ||
height: fixedHeight ? min(frameHeight, windowBounds.height) : nil) | ||
.background(Color(.systemBackground)) | ||
.cornerRadius(16) | ||
.shadow(radius: 10) | ||
|
@@ -82,8 +84,14 @@ struct POSModalViewModifier<ModalContent: View>: ViewModifier { | |
} | ||
|
||
extension View { | ||
func posModal<ModalContent: View>(isPresented: Binding<Bool>, @ViewBuilder content: @escaping () -> ModalContent) -> some View { | ||
func posModal<ModalContent: View>(isPresented: Binding<Bool>, | ||
fixedWidth: Bool = true, | ||
fixedHeight: Bool = true, | ||
@ViewBuilder content: @escaping () -> ModalContent) -> some View { | ||
self.modifier( | ||
POSModalViewModifier(isPresented: isPresented, modalContent: content)) | ||
POSModalViewModifier(isPresented: isPresented, | ||
modalContent: content, | ||
fixedWidth: fixedWidth, | ||
fixedHeight: fixedHeight)) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are the same as 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. |
||
static let posModalTitle: Font = Font.system(size: UIFontMetrics.default.scaledValue(for: 36), weight: .bold) | ||
} |
There was a problem hiding this comment.
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 modelThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 358d15c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, good point, tnx!