I made a SwiftUI component which lets you can drag anywhere to dismiss a view. This app lets you demo this feature and provides you two examples of how to implement the feature with one line of code.
The code is open source and hosted on GitHub. Link is in the app.