Updated on 2026-08-14
This commit is contained in:
parent
1560706cba
commit
eef969ae57
8 changed files with 44 additions and 38 deletions
|
|
@ -17,6 +17,7 @@ dependencies {
|
|||
|
||||
/** Domain */
|
||||
implementation(projects.domain.models)
|
||||
implementation(projects.domain.addressBook)
|
||||
|
||||
/** Core modules */
|
||||
implementation(projects.core.configToggles)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,14 @@ internal class DefaultAddressBookComponent @AssistedInject constructor(
|
|||
when (config) {
|
||||
AddressBookRoute.List -> addressBookListComponentFactory.create(
|
||||
context = childByContext(componentContext),
|
||||
params = AddressBookListComponent.Params,
|
||||
params = AddressBookListComponent.Params(
|
||||
onContactClick = { contactId ->
|
||||
// TODO [REDACTED_TASK_KEY] router.push(EditContact(contactId))
|
||||
},
|
||||
onAddContactClick = {
|
||||
// TODO [REDACTED_TASK_KEY] router.push(AddContact)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,5 +7,8 @@ internal interface AddressBookListComponent : ComposableContentComponent {
|
|||
|
||||
interface Factory : ComponentFactory<Params, AddressBookListComponent>
|
||||
|
||||
data object Params
|
||||
data class Params(
|
||||
val onContactClick: (String) -> Unit,
|
||||
val onAddContactClick: () -> Unit,
|
||||
)
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.features.addressbook.list.contract.AddressBookListEvent
|
||||
import com.tangem.features.addressbook.list.contract.AddressBookListUM
|
||||
import com.tangem.features.addressbook.list.model.AddressBookListModel
|
||||
import com.tangem.features.addressbook.list.ui.AddressBookEmptyScreen
|
||||
|
|
@ -16,7 +15,7 @@ import dagger.assisted.AssistedInject
|
|||
|
||||
internal class DefaultAddressBookListComponent @AssistedInject constructor(
|
||||
@Assisted context: AppComponentContext,
|
||||
@Assisted params: AddressBookListComponent.Params,
|
||||
@Assisted val params: AddressBookListComponent.Params,
|
||||
) : AddressBookListComponent, AppComponentContext by context {
|
||||
|
||||
private val model: AddressBookListModel = getOrCreateModel(params)
|
||||
|
|
@ -26,9 +25,11 @@ internal class DefaultAddressBookListComponent @AssistedInject constructor(
|
|||
val state by model.state.collectAsStateWithLifecycle()
|
||||
when (state) {
|
||||
AddressBookListUM.Empty -> AddressBookEmptyScreen(
|
||||
onAddContactClick = { model.onAction(event = AddressBookListEvent.NewContactClick) },
|
||||
onAddContactClick = params.onAddContactClick,
|
||||
onBackClick = router::pop,
|
||||
modifier = modifier,
|
||||
)
|
||||
is AddressBookListUM.AddressList -> TODO("[REDACTED_TASK_KEY]")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
package com.tangem.features.addressbook.list.contract
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
internal sealed interface AddressBookListUM {
|
||||
|
||||
data object Empty : AddressBookListUM
|
||||
}
|
||||
|
||||
internal sealed interface AddressBookListEvent {
|
||||
data object NewContactClick : AddressBookListEvent
|
||||
data class ContactClick(val contactId: String) : AddressBookListEvent
|
||||
data class ChipClick(val walletId: String) : AddressBookListEvent
|
||||
data class SearchInput(val query: String) : AddressBookListEvent
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.tangem.features.addressbook.list.contract
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.domain.addressbook.model.Contact
|
||||
|
||||
@Immutable
|
||||
internal sealed class AddressBookListUM {
|
||||
|
||||
data object Empty : AddressBookListUM()
|
||||
data class AddressList(val contacts: List<Contact>) : AddressBookListUM()
|
||||
}
|
||||
|
|
@ -2,9 +2,6 @@ package com.tangem.features.addressbook.list.model
|
|||
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.features.addressbook.list.AddressBookListComponent
|
||||
import com.tangem.features.addressbook.list.contract.AddressBookListEvent
|
||||
import com.tangem.features.addressbook.list.contract.AddressBookListUM
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
|
@ -13,22 +10,10 @@ import javax.inject.Inject
|
|||
|
||||
@ModelScoped
|
||||
internal class AddressBookListModel @Inject constructor(
|
||||
paramsContainer: ParamsContainer,
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
) : Model() {
|
||||
|
||||
private val params: AddressBookListComponent.Params = paramsContainer.require()
|
||||
|
||||
val state: StateFlow<AddressBookListUM> = MutableStateFlow(
|
||||
AddressBookListUM.Empty,
|
||||
)
|
||||
|
||||
fun onAction(event: AddressBookListEvent) {
|
||||
when (event) {
|
||||
AddressBookListEvent.NewContactClick -> params
|
||||
is AddressBookListEvent.ContactClick -> Unit
|
||||
is AddressBookListEvent.ChipClick -> Unit
|
||||
is AddressBookListEvent.SearchInput -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,15 +15,29 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.components.PrimaryButtonIconEnd
|
||||
import com.tangem.core.ui.components.appbar.TangemTopAppBar
|
||||
import com.tangem.core.ui.components.appbar.models.TopAppBarButtonUM
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
||||
@Composable
|
||||
internal fun AddressBookEmptyScreen(onAddContactClick: () -> Unit, modifier: Modifier = Modifier) {
|
||||
internal fun AddressBookEmptyScreen(
|
||||
onAddContactClick: () -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
TangemTopAppBar(
|
||||
modifier = Modifier.statusBarsPadding(),
|
||||
title = resourceReference(R.string.address_book_title),
|
||||
startButton = TopAppBarButtonUM.Back(
|
||||
onBackClicked = onBackClick,
|
||||
),
|
||||
)
|
||||
NoContactInfo()
|
||||
PrimaryButtonIconEnd(
|
||||
modifier = Modifier
|
||||
|
|
@ -84,5 +98,5 @@ private fun ContactImage() {
|
|||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun Preview_AddressBookEmptyScreen() {
|
||||
AddressBookEmptyScreen(onAddContactClick = {})
|
||||
AddressBookEmptyScreen(onAddContactClick = {}, onBackClick = {})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue