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
[Notifications Refresh] Present Comment Moderations Options View #23175
[Notifications Refresh] Present Comment Moderations Options View #23175
Conversation
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
|
import SwiftUI | ||
import WordPressUI | ||
|
||
class BottomSheetContentViewController: UIViewController { |
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 logic was extracted from CompliancePopoverViewController
. I was going to implement the same class for the Comment Moderations Options View
but then I thought why not implement a reusable component instead.
I'll open a separate PR to refactor the CompliancePopoverViewController
to use this class.
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
|
if let presentationController = parent?.presentationController as? DrawerPresentationController { | ||
presentationController.transition(to: presentationController.currentPosition) | ||
} | ||
} |
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 code adjusts the layout of the bottom sheet when fonts are enlarged. I needed a way to update the parent view in response to changes in the child view's size. While I don't like this approach of accessing DrawerPresentationController
due to it making too many assumptions about implementation details, it is the best approach I could think 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.
Do we need to handle the else
path here? I think it is fine as long as it works with other VC types. Otherwise, it would make sense to specify the type rather than make it look like it is more flexible.
@@ -140,6 +140,10 @@ class CommentDetailViewController: UIViewController, NoResultsViewHost { | |||
return cell | |||
}() | |||
|
|||
private weak var changeStatusViewController: UIViewController? |
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.
If that's the presenting view controller, you can use unowned
here and maybe specify the VCType rather than using UIViewController
since the name already specifies it.
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.
That's the bottom sheet view controller being presented. I need to keep a reference to this view controller so I can dismiss it later when the user selects a status. The reference is optional because the view controller might not always be present.
While now it's possible to have optional unowned references:
private unowned var changeStatusViewController: BottomSheetViewController?
Unlike with weak
, the reference won't automatically turn nil
if the object is deallocated. Accessing a deallocated object will cause the app to crash.
I need the object to automatically turn nil
when the view controller is deallocated ( aka dismissed ).
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.
maybe specify the VCType rather than using UIViewController since the name already specifies it.
Resolved in 346b52c
if let presentationController = parent?.presentationController as? DrawerPresentationController { | ||
presentationController.transition(to: presentationController.currentPosition) | ||
} | ||
} |
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.
Do we need to handle the else
path here? I think it is fine as long as it works with other VC types. Otherwise, it would make sense to specify the type rather than make it look like it is more flexible.
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.
AC is satisfied. All actions work as expected.
b59804a
to
346b52c
Compare
4a4fc79
into
feature/notifications_refresh_p2
Fixes https://github.com/Automattic/wordpress-mobile/issues/38
Description
This pull request adds logic where tapping the 'Change Status' button in the header menu brings up the Comment Moderation Options view.
Test Instructions
Regression Notes
Potential unintended areas of impact
N/A
What I did to test those areas of impact (or what existing automated tests I relied on)
N/A
What automated tests I added (or what prevented me from doing so)
N/A
PR submission checklist:
RELEASE-NOTES.txt
if necessary.Testing checklist: