Merge branch 'develop' into renovate/io.nlopez.compose.rules-detekt-0.x

This commit is contained in:
Benoit Marty 2024-05-28 08:59:36 +02:00 committed by GitHub
commit 683f7d4748
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
587 changed files with 9299 additions and 2438 deletions

View file

@ -16,6 +16,9 @@
package io.element.android.features.roomlist.impl.filters
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@ -31,13 +34,15 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.FilterChip
import androidx.compose.material3.FilterChipDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.libraries.designsystem.preview.ElementPreview
@ -62,6 +67,7 @@ fun RoomListFiltersView(
}
val lazyListState = rememberLazyListState()
val previousFilters = remember { mutableStateOf(listOf<RoomListFilter>()) }
LazyRow(
contentPadding = PaddingValues(start = 8.dp, end = 16.dp),
modifier = modifier.fillMaxWidth(),
@ -75,28 +81,30 @@ fun RoomListFiltersView(
modifier = Modifier
.padding(start = 8.dp)
.testTag(TestTags.homeScreenClearFilters),
onClick = ::onClearFiltersClicked
onClick = {
previousFilters.value = state.selectedFilters()
onClearFiltersClicked()
}
)
}
}
for (filterWithSelection in state.filterSelectionStates) {
state.filterSelectionStates.forEachIndexed { i, filterWithSelection ->
item(filterWithSelection.filter) {
val zIndex = (if (previousFilters.value.contains(filterWithSelection.filter)) state.filterSelectionStates.size else 0) - i.toFloat()
RoomListFilterView(
modifier = Modifier.animateItemPlacement(),
modifier = Modifier
.animateItemPlacement()
.zIndex(zIndex),
roomListFilter = filterWithSelection.filter,
selected = filterWithSelection.isSelected,
onClick = ::onToggleFilter,
onClick = {
previousFilters.value = state.selectedFilters()
onToggleFilter(it)
},
)
}
}
}
LaunchedEffect(state.filterSelectionStates) {
// Checking for canScrollBackward is necessary for the itemPlacementAnimation to work correctly.
// We don't want the itemPlacementAnimation to be triggered when clearing the filters.
if (!state.hasAnyFilterSelected || lazyListState.canScrollBackward) {
lazyListState.animateScrollToItem(0)
}
}
}
@Composable
@ -126,16 +134,27 @@ private fun RoomListFilterView(
onClick: (RoomListFilter) -> Unit,
modifier: Modifier = Modifier
) {
val background = animateColorAsState(
targetValue = if (selected) ElementTheme.colors.bgActionPrimaryRest else ElementTheme.colors.bgCanvasDefault,
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
label = "chip background colour",
)
val textColour = animateColorAsState(
targetValue = if (selected) ElementTheme.colors.textOnSolidPrimary else ElementTheme.colors.textPrimary,
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
label = "chip text colour",
)
FilterChip(
selected = selected,
onClick = { onClick(roomListFilter) },
modifier = modifier.height(36.dp),
shape = CircleShape,
colors = FilterChipDefaults.filterChipColors(
containerColor = ElementTheme.colors.bgCanvasDefault,
selectedContainerColor = ElementTheme.colors.bgActionPrimaryRest,
labelColor = ElementTheme.colors.textPrimary,
selectedLabelColor = ElementTheme.colors.textOnSolidPrimary,
containerColor = background.value,
selectedContainerColor = background.value,
labelColor = textColour.value,
selectedLabelColor = textColour.value
),
label = {
Text(text = stringResource(id = roomListFilter.stringResource))

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="screen_invites_decline_chat_message">"დარწმუნებული ხართ, რომ გსურთ, უარი თქვათ მოწვევაზე %1$s-ში?"</string>
<string name="screen_invites_decline_chat_title">"მოწვევაზე უარის თქმა"</string>
<string name="screen_invites_decline_direct_chat_message">"დარწმუნებული ხართ, რომ გსურთ, უარი თქვათ ჩატზე %1$s-თან?"</string>
<string name="screen_invites_decline_direct_chat_title">"ჩატზე უარის თქვა"</string>
<string name="screen_invites_empty_list">"მოწვევები არ არის"</string>
<string name="screen_invites_invited_you">"%1$s (%2$s) მოგიწვიათ"</string>
<string name="screen_migration_message">"ეს არის ერთჯერადი პროცესი, მადლობა ლოდინისთვის."</string>
<string name="screen_migration_title">"თქვენი ანგარიშის კონფიგურაცია"</string>
<string name="screen_roomlist_a11y_create_message">"ახალი საუბრისა ან ოთახის შექმნა"</string>
<string name="screen_roomlist_empty_message">"დაიწყეთ ვინმესთვის შეტყობინების გაგზავნით."</string>
<string name="screen_roomlist_empty_title">"არც ერთი ჩატი ჯერ არაა."</string>
<string name="screen_roomlist_filter_people">"ხალხი"</string>
<string name="screen_roomlist_main_space_title">"ჩატები"</string>
<string name="session_verification_banner_message">"როგორც ჩანს, ახალ მოწყობილობას იყენებთ. დაადასტურეთ სხვა მოწყობილობით თქვენს დაშიფრულ შეტყობინებებზე წვდომისთვის."</string>
<string name="session_verification_banner_title">"დაადასტურეთ, რომ ეს თქვენ ხართ"</string>
</resources>

View file

@ -7,10 +7,13 @@
<string name="screen_migration_title">"正在設定您的帳號。"</string>
<string name="screen_roomlist_a11y_create_message">"建立新的對話或聊天室"</string>
<string name="screen_roomlist_filter_favourites">"我的最愛"</string>
<string name="screen_roomlist_filter_invites">"邀請"</string>
<string name="screen_roomlist_filter_people">"夥伴"</string>
<string name="screen_roomlist_filter_rooms">"聊天室"</string>
<string name="screen_roomlist_filter_unreads">"未讀"</string>
<string name="screen_roomlist_main_space_title">"所有聊天室"</string>
<string name="screen_roomlist_mark_as_read">"標為已讀"</string>
<string name="screen_roomlist_mark_as_unread">"標為未讀"</string>
<string name="session_verification_banner_message">"您似乎正在使用新的裝置。請使用另一個裝置進行驗證,以存取您的加密訊息。"</string>
<string name="session_verification_banner_title">"驗證這是您本人"</string>
</resources>

View file

@ -140,7 +140,7 @@ class RoomListPresenterTests {
}.test {
val initialState = awaitItem()
assertThat(initialState.showAvatarIndicator).isTrue()
sessionVerificationService.givenCanVerifySession(false)
sessionVerificationService.givenNeedsSessionVerification(false)
encryptionService.emitBackupState(BackupState.ENABLED)
val finalState = awaitItem()
assertThat(finalState.showAvatarIndicator).isFalse()
@ -282,7 +282,7 @@ class RoomListPresenterTests {
roomListService = roomListService,
encryptionService = encryptionService,
sessionVerificationService = FakeSessionVerificationService().apply {
givenCanVerifySession(false)
givenNeedsSessionVerification(false)
},
syncService = FakeSyncService(initialState = SyncState.Running)
)