From 1aac35a5527ea0744c60bbf89218a1481a7961d7 Mon Sep 17 00:00:00 2001 From: Dima Date: Mon, 24 Nov 2025 20:00:21 +0500 Subject: [PATCH 1/3] =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20Messengers=20=D0=B8=20Country?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../country/CountryCodeBottomSheet.kt | 80 ++++--------------- .../messengers/MessengersBottomSheet.kt | 79 ++++-------------- 2 files changed, 31 insertions(+), 128 deletions(-) diff --git a/app/src/main/java/ru/yandex/practicum/contacts/presentation/country/CountryCodeBottomSheet.kt b/app/src/main/java/ru/yandex/practicum/contacts/presentation/country/CountryCodeBottomSheet.kt index e74ab23..39ad953 100644 --- a/app/src/main/java/ru/yandex/practicum/contacts/presentation/country/CountryCodeBottomSheet.kt +++ b/app/src/main/java/ru/yandex/practicum/contacts/presentation/country/CountryCodeBottomSheet.kt @@ -35,73 +35,25 @@ fun CountryCodeBottomSheet( onCodesSelected: (Set) -> Unit, onDismiss: () -> Unit ) { - ModalBottomSheet( - onDismissRequest = onDismiss, - dragHandle = { BottomSheetDefaults.DragHandle() } - ) { - Column( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp) - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 16.dp), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = stringResource(R.string.filter_by_country_code), - style = MaterialTheme.typography.titleLarge - ) - IconButton(onClick = onDismiss) { - Icon( - imageVector = Icons.Default.Close, - contentDescription = stringResource(R.string.close) - ) - } - } - - LazyColumn( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 16.dp) - ) { - items(CountryCode.COMMON_CODES) { countryCode -> - val isSelected = selectedCodes.contains(countryCode) - Surface( - modifier = Modifier - .fillMaxWidth() - .padding(vertical = 4.dp), - onClick = { - val newSelection = selectedCodes.toMutableSet() - if (isSelected) { - newSelection.remove(countryCode) - } else { - newSelection.add(countryCode) - } - onCodesSelected(newSelection) - }, - color = if (isSelected) { - MaterialTheme.colorScheme.primaryContainer - } else { - MaterialTheme.colorScheme.surface - } - ) { - CountryCodeOption( - isSelected = isSelected, - countryCode = countryCode, - selectedCodes = selectedCodes, - onCodesSelected = onCodesSelected - ) - } - } - } - } + CommonBottomSheet( + title = stringResource(R.string.filter_by_country_code), + items = CountryCode.COMMON_CODES, + selectedItems = selectedCodes, + onItemsSelected = { selected -> + selected.firstOrNull()?.let { onCodesSelected(it) } + }, + onDismiss = onDismiss + ){countryCode, isSelected -> + CountryCodeOption( + isSelected = isSelected, + countryCode = countryCode, + selectedCodes = selectedCodes, + onCodesSelected = onCodesSelected + ) } } + @Composable private fun CountryCodeOption( isSelected: Boolean, diff --git a/app/src/main/java/ru/yandex/practicum/contacts/presentation/messengers/MessengersBottomSheet.kt b/app/src/main/java/ru/yandex/practicum/contacts/presentation/messengers/MessengersBottomSheet.kt index dcddf8d..35d832d 100644 --- a/app/src/main/java/ru/yandex/practicum/contacts/presentation/messengers/MessengersBottomSheet.kt +++ b/app/src/main/java/ru/yandex/practicum/contacts/presentation/messengers/MessengersBottomSheet.kt @@ -35,70 +35,21 @@ fun MessengersBottomSheet( onAppsSelected: (Set) -> Unit, onDismiss: () -> Unit ) { - ModalBottomSheet( - onDismissRequest = onDismiss, - dragHandle = { BottomSheetDefaults.DragHandle() } - ) { - Column( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp) - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 16.dp), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = stringResource(R.string.filter_by_messaging_app), - style = MaterialTheme.typography.titleLarge - ) - IconButton(onClick = onDismiss) { - Icon( - imageVector = Icons.Default.Close, - contentDescription = stringResource(R.string.close) - ) - } - } - - LazyColumn( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 16.dp) - ) { - items(MessagingApp.entries) { app -> - val isSelected = selectedApps.contains(app) - Surface( - modifier = Modifier - .fillMaxWidth() - .padding(vertical = 4.dp), - onClick = { - val newSelection = selectedApps.toMutableSet() - if (isSelected) { - newSelection.remove(app) - } else { - newSelection.add(app) - } - onAppsSelected(newSelection) - }, - color = if (isSelected) { - MaterialTheme.colorScheme.primaryContainer - } else { - MaterialTheme.colorScheme.surface - } - ) { - MessengerOption( - isSelected = isSelected, - app = app, - selectedApps = selectedApps, - onAppsSelected = onAppsSelected - ) - } - } - } - } + CommonBottomSheet( + title=stringResource(R.string.filter_by_messaging_app), + items=MessagingApp.entries, + selectedItems=selectedApps, + onItemsSelected= { selected -> + selected.firstOrNull()?.let { onAppsSelected(it) } + }, + onDismiss = onDismiss + ){app, isSelected -> + MessengerOption( + isSelected = isSelected, + app = app, + selectedApps = selectedApps, + onAppsSelected = onAppsSelected + ) } } From 0b96532e9058e02a8650c0ead3729ca296c35e69 Mon Sep 17 00:00:00 2001 From: Dima Date: Mon, 24 Nov 2025 20:06:47 +0500 Subject: [PATCH 2/3] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= =?UTF-8?q?=20=20=D0=B2=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index dab7c28..b79bf1a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,5 @@ android.useAndroidX=true # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true +android.overridePathCheck=true \ No newline at end of file From bc2e7ab8380797ab1fe2cadea6de51cd8b35a31a Mon Sep 17 00:00:00 2001 From: Dima Date: Mon, 24 Nov 2025 20:24:31 +0500 Subject: [PATCH 3/3] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=B8=D0=BC=D0=BF=D0=BE=D1=80=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../country/CountryCodeBottomSheet.kt | 15 ++------------- .../messengers/MessengersBottomSheet.kt | 19 +++---------------- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/ru/yandex/practicum/contacts/presentation/country/CountryCodeBottomSheet.kt b/app/src/main/java/ru/yandex/practicum/contacts/presentation/country/CountryCodeBottomSheet.kt index 39ad953..3dd81c9 100644 --- a/app/src/main/java/ru/yandex/practicum/contacts/presentation/country/CountryCodeBottomSheet.kt +++ b/app/src/main/java/ru/yandex/practicum/contacts/presentation/country/CountryCodeBottomSheet.kt @@ -1,24 +1,14 @@ package ru.yandex.practicum.contacts.presentation.country -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Close -import androidx.compose.material3.BottomSheetDefaults import androidx.compose.material3.Checkbox import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.ModalBottomSheet -import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -27,6 +17,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import ru.yandex.practicum.contacts.R import ru.yandex.practicum.contacts.data.models.CountryCode +import ru.yandex.practicum.contacts.presentation.ui.components.CommonBottomSheet @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -39,9 +30,7 @@ fun CountryCodeBottomSheet( title = stringResource(R.string.filter_by_country_code), items = CountryCode.COMMON_CODES, selectedItems = selectedCodes, - onItemsSelected = { selected -> - selected.firstOrNull()?.let { onCodesSelected(it) } - }, + onItemsSelected = onCodesSelected, onDismiss = onDismiss ){countryCode, isSelected -> CountryCodeOption( diff --git a/app/src/main/java/ru/yandex/practicum/contacts/presentation/messengers/MessengersBottomSheet.kt b/app/src/main/java/ru/yandex/practicum/contacts/presentation/messengers/MessengersBottomSheet.kt index 35d832d..c4237f9 100644 --- a/app/src/main/java/ru/yandex/practicum/contacts/presentation/messengers/MessengersBottomSheet.kt +++ b/app/src/main/java/ru/yandex/practicum/contacts/presentation/messengers/MessengersBottomSheet.kt @@ -1,24 +1,12 @@ package ru.yandex.practicum.contacts.presentation.messengers -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Close -import androidx.compose.material3.BottomSheetDefaults import androidx.compose.material3.Checkbox import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.ModalBottomSheet -import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -27,6 +15,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import ru.yandex.practicum.contacts.R import ru.yandex.practicum.contacts.data.models.MessagingApp +import ru.yandex.practicum.contacts.presentation.ui.components.CommonBottomSheet @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -39,11 +28,9 @@ fun MessengersBottomSheet( title=stringResource(R.string.filter_by_messaging_app), items=MessagingApp.entries, selectedItems=selectedApps, - onItemsSelected= { selected -> - selected.firstOrNull()?.let { onAppsSelected(it) } - }, + onItemsSelected=onAppsSelected, onDismiss = onDismiss - ){app, isSelected -> + ){ app , isSelected -> MessengerOption( isSelected = isSelected, app = app,