apptekstudios / ASNavigationView

6 stars 1 forks source link

Feature Request: Either add an action to a ASNavigation button or have a programmatic way to trigger the view pop #2

Open tarasis opened 4 years ago

tarasis commented 4 years ago

Request for either a way to pass an action to ASNavigation*Button, or a way to programmatically trigger the view pop.

Use case:

A list with detail views. Each detail view has a delete button which removes it from the List. Pressing the delete button should trigger the action and then dismiss the view so that the list is displayed.

Current Behaviour:

With a standard List, deleting it from the data source, causes the next detail view to appear.

Hence trying out ASNavigationView.

However there is no option to add an action/closure to ASNavigationPopToRootButton Adding .onTapGesture to ASNavigationPopToRootButton is ignored Adding .onTapGesture to the HStack for the button view overrides the ASNavigationPopToRootButton press functionality.

Trying to use the dynamicNavigationState directly (@Environment(\.dynamicNavState) var dynamicNavState) causes a compiler error: 'dynamicNavState' is inaccessible due to 'internal' protection level

apptekstudios commented 4 years ago

I added a closure to achieve this 👍 ASNavigationPopToRootButton(onPopToRoot: { ... }) { Text("Test") }

Going ahead will also add a programmatic way via an environment variable, but yet to decide on the best way to provide that api

tarasis commented 4 years ago

Thank you, that's works a treat!