[16][6][13] Refactoring / Switchcraft integration / Support for Alerts #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For #16 #6 #13
Summary:
Alerts
This PR introduces a bunch of changes to support a dynamic alert system within the DebugMenu, including support for displaying the SwitchCraft alert.
DebugTextFieldAlertAction
allows us to surface an alert with a textField, useful for things like testing voucher redemptions for example.DebugMenuView will now display an alert whenever its dataSource configures the
DebugAlert
object. Useful to surface whether a network call succeeded or not.DebugHostControllerAction
allows us to execute a closure that operates on aUIHostingController
. This is useful for presenting anyUIViewController
or customUIAlertController
without needing to create a SwiftUI wrapper each time.This action is what allows us to use Switchcrafts
display(from parentVC: UIViewController)
from a SwiftUI view.Other Changes
I also completed a few points from #13 in this PR. Password entry now takes a binding that toggles the visibility of the debug menu entry point instead of directly navigating to it.
DebugMenuAccessConfig
introduced to provide passwordSHA and longPressGesture duration. (Will expand to include gesture type etc. in the future ). Moved visibility toggle / password config to global DebugMenuStore instance in example project.Other:
Note
I was unsure how we wanted to integrate Switchcraft and after some thought decided it may be best to not have it be tightly coupled to this library. The
DebugHostControllerAction
allows us to easily display the Switchcraft alert without forcing us to use the library.This way we can have a package collection that includes this framework and Switchcraft without this framework listing Switchcraft as a dependency. Let me know if anyone has any thoughts on this / thinks we should just rewrite a SwiftUI solution.