Skip to content

Commit

Permalink
Simplify shipping labels payment navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
hichamboushaba committed Feb 7, 2025
1 parent 5561390 commit 8311417
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import android.view.View
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import com.woocommerce.android.AppUrls
import com.woocommerce.android.AppUrls.FETCH_PAYMENT_METHOD_URL_PATH
import com.woocommerce.android.NavGraphOrdersDirections
import com.woocommerce.android.NavGraphMainDirections
import com.woocommerce.android.R
import com.woocommerce.android.databinding.FragmentEditShippingLabelPaymentBinding
import com.woocommerce.android.extensions.findNavController
import com.woocommerce.android.extensions.handleNotice
import com.woocommerce.android.extensions.navigateBackWithNotice
import com.woocommerce.android.extensions.navigateBackWithResult
Expand Down Expand Up @@ -198,10 +197,10 @@ class EditShippingLabelPaymentFragment :
viewModel.event.observe(viewLifecycleOwner) { event ->
when (event) {
is AddPaymentMethod -> {
findNavController().navigateSafely(
NavGraphOrdersDirections.actionGlobalAuthenticatedWebViewFragment(
findNavController(R.id.nav_host_fragment_main).navigateSafely(
NavGraphMainDirections.actionGlobalAuthenticatedWebViewFragment(
urlToLoad = AppUrls.WPCOM_ADD_PAYMENT_METHOD,
urlsToTriggerExit = arrayOf(FETCH_PAYMENT_METHOD_URL_PATH),
urlsToTriggerExit = arrayOf(AppUrls.FETCH_PAYMENT_METHOD_URL_PATH),
title = getFragmentTitle()
)
)
Expand All @@ -215,7 +214,7 @@ class EditShippingLabelPaymentFragment :
}

private fun setupResultHandlers() {
handleNotice(AuthenticatedWebViewFragment.WEBVIEW_RESULT) {
handleNotice(AuthenticatedWebViewFragment.WEBVIEW_RESULT, navHostId = R.id.nav_host_fragment_main) {
viewModel.onPaymentMethodAdded()
}
}
Expand Down
38 changes: 0 additions & 38 deletions WooCommerce/src/main/res/navigation/nav_graph_orders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -486,44 +486,6 @@
android:label="EditShippingLabelPaymentFragment"
tools:layout="@layout/fragment_edit_shipping_label_payment">
</fragment>
<action
android:id="@+id/action_global_AuthenticatedWebViewFragment"
app:destination="@id/AuthenticatedWebViewFragment" />
<fragment
android:id="@+id/AuthenticatedWebViewFragment"
android:name="com.woocommerce.android.ui.common.webview.AuthenticatedWebViewFragment"
android:label="AuthenticatedWebViewFragment"
tools:layout="@layout/fragment_wpcom_webview">
<argument
android:name="urlToLoad"
app:argType="string" />
<argument
android:name="title"
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<argument
android:name="urlsToTriggerExit"
android:defaultValue="@null"
app:argType="string[]"
app:nullable="true" />
<argument
android:name="captureBackButton"
android:defaultValue="true"
app:argType="boolean" />
<argument
android:name="displayMode"
android:defaultValue="REGULAR"
app:argType="com.woocommerce.android.ui.common.webview.AuthenticatedWebViewViewModel$DisplayMode" />
<argument
android:name="urlComparisonMode"
android:defaultValue="PARTIAL"
app:argType="com.woocommerce.android.ui.common.webview.AuthenticatedWebViewViewModel$UrlComparisonMode" />
<argument
android:name="clearCache"
android:defaultValue="false"
app:argType="boolean" />
</fragment>
<fragment
android:id="@+id/shippingCarrierRatesFragment"
android:name="com.woocommerce.android.ui.orders.shippinglabels.creation.ShippingCarrierRatesFragment"
Expand Down

0 comments on commit 8311417

Please sign in to comment.