-
Notifications
You must be signed in to change notification settings - Fork 9
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
FeatureFormView
& PopupView
- Add ability to hide default headers
#839
base: v.next
Are you sure you want to change the base?
Conversation
@@ -39,6 +41,6 @@ extension EnvironmentValues { | |||
} | |||
|
|||
/// The validation error visibility configuration of a form. | |||
private struct FormViewValidationErrorVisibility: EnvironmentKey { |
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.
Changing this to internal allows FeatureFormView
to access the default value.
@@ -25,8 +25,10 @@ public extension FeatureFormView { | |||
|
|||
/// Specifies the visibility of validation errors in the form. | |||
/// - Parameter visibility: The preferred visibility of validation errors in the form. | |||
func validationErrors(_ visibility: ValidationErrorVisibility) -> some View { |
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.
This needed to change to return Self
so that the two FeatureFormView
modifiers can be placed in any order.
Sources/ArcGISToolkit/Components/FeatureFormView/FeatureFormView+TitleVisibility.swift
Outdated
Show resolved
Hide resolved
Allows FeatureFormView modifiers to be placed in any order
d60f0ea
to
87dbeeb
Compare
FeatureFormView
& PopupView
- Add ._Title(_:)
FeatureFormView
& PopupView
- Add ability to hide default headers
@@ -95,7 +101,7 @@ public struct FeatureFormView: View { | |||
ScrollViewReader { scrollViewProxy in | |||
ScrollView { | |||
VStack(alignment: .leading) { | |||
if !title.isEmpty { | |||
if !title.isEmpty && headerVisibility != .hidden { | |||
FormHeader(title: title) | |||
Divider() |
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.
The Divider is included as part of the header so that a developer can control whether or not it's included.
Same behavior with the new PopupView modifier.
} | ||
Divider() |
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.
The Divider is included as part of the header so that a developer can control whether or not it's included.
Same behavior with the new FeatureFormView modifier.
@@ -67,7 +67,10 @@ public struct PopupView: View { | |||
/// A Boolean value specifying whether a "close" button should be shown or not. If the "close" | |||
/// button is shown, you should pass in the `isPresented` argument to the initializer, | |||
/// so that the the "close" button can close the view. | |||
private var showCloseButton = false | |||
var showCloseButton = false |
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.
showCloseButton
is now internal so that it can be modified from PopupView+ShowCloseButton.swift
.
extension PopupView { | ||
/// Specifies whether a "close" button should be shown to the right of the popup title. If the "close" | ||
/// button is shown, you should pass in the `isPresented` argument to the `PopupView` | ||
/// initializer, so that the the "close" button can close the view. | ||
/// Defaults to `false`. | ||
/// - Parameter newShowCloseButton: The new value. | ||
/// - Returns: A new `PopupView`. | ||
public func showCloseButton(_ newShowCloseButton: Bool) -> Self { | ||
var copy = self | ||
copy.showCloseButton = newShowCloseButton | ||
return copy | ||
} | ||
} |
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.
Moved to PopupView+ShowCloseButton.swift
to be consistent with how other PopupView and FeatureFormView modifiers are written.
Sources/ArcGISToolkit/Components/FeatureFormView/FeatureFormView+TitleVisibility.swift
Outdated
Show resolved
Hide resolved
@mhdostal and @rolson this is ready for review once again. The updated changes are:
In regards to the suggestion above, would it be better to avoid the complication of maintaining new initializers? With these changes devs can hide the header and easily include a custom one with a .sheet(isPresented: $showPopup) { [popup] in
VStack(alignment: .leading) {
Text(popup!.title)
.font(.title)
PopupView(popup: popup!)
.popupHeader(.hidden)
}
.padding()
} |
This is still ready for review. I made one more slight change to avoid breaking the behavior of |
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.
One question.
.labelStyle(.iconOnly) | ||
Spacer() | ||
if (showCloseButtonDeprecatedModifierIsApplied && showCloseButton) | ||
|| (!showCloseButtonDeprecatedModifierIsApplied && isPresented != nil) { |
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.
Is it assumed that if isPresented != nil
then isPresented?.wrappedValue == true
?
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.
Yes, assumed. One could technically do something odd like pass .constant(false)
into the initializer parameter and still have the PopupView
presented but that would be unintended use of the parameter.
Closes #835
PopupView.popupHeader(_:)
FeatureFormView.formHeader(_:)
PopupView.showCloseButton(_:)