Skip to content

Commit

Permalink
Implement WooShippingLabelCreationViewModel.onPackageSelected
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomazFB committed Dec 12, 2024
1 parent 2ed22bc commit 48746ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch
import javax.inject.Inject
import kotlinx.coroutines.flow.update

@HiltViewModel
class WooShippingLabelCreationViewModel @Inject constructor(
Expand Down Expand Up @@ -191,7 +192,15 @@ class WooShippingLabelCreationViewModel @Inject constructor(
}

fun onPackageSelected(packageData: PackageData) {

selectedPackage.update { content ->
when (content) {
is NotAvailable -> PackageSelectionState.Data(
selectedPackage = packageData,
totalWeight = packageData.weight
)
is PackageSelectionState.Data -> content.copy(selectedPackage = packageData)
}
}
}

data object StartPackageSelection : Event()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.WooShippingLabelPackageCreationViewModel.PackageSelected
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.WooShippingLabelPackageCreationViewModel.PackageType
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.WooShippingLabelPackageCreationViewModel.ShowPackageTypeDialog
import com.woocommerce.android.ui.orders.wooshippinglabels.packages.ui.PackageData
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand Down

0 comments on commit 48746ad

Please sign in to comment.