Remove Modifier parameter in private function when only default value is used.
This will improve the code coverage metrics, and this also fixes a few potential bug, where the Modifier was used several times.
This commit is contained in:
parent
6f082232d3
commit
72b89338b3
59 changed files with 117 additions and 262 deletions
|
|
@ -204,12 +204,10 @@ private fun RoomDetailsTopBar(
|
|||
goBack: () -> Unit,
|
||||
onActionClicked: (RoomDetailsAction) -> Unit,
|
||||
showEdit: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
var showMenu by remember { mutableStateOf(false) }
|
||||
|
||||
TopAppBar(
|
||||
modifier = modifier,
|
||||
title = { },
|
||||
navigationIcon = { BackButton(onClick = goBack) },
|
||||
actions = {
|
||||
|
|
@ -237,8 +235,14 @@ private fun RoomDetailsTopBar(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun MainActionsSection(state: RoomDetailsState, onShareRoom: () -> Unit, modifier: Modifier = Modifier) {
|
||||
Row(modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
|
||||
private fun MainActionsSection(
|
||||
state: RoomDetailsState,
|
||||
onShareRoom: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
) {
|
||||
val roomNotificationSettings = state.roomNotificationSettings
|
||||
if (state.canShowNotificationSettings && roomNotificationSettings != null) {
|
||||
if (roomNotificationSettings.mode == RoomNotificationMode.MUTE) {
|
||||
|
|
@ -275,10 +279,9 @@ private fun RoomHeaderSection(
|
|||
roomName: String,
|
||||
roomAlias: String?,
|
||||
openAvatarPreview: (url: String) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
|
|
@ -312,9 +315,8 @@ private fun RoomHeaderSection(
|
|||
private fun TopicSection(
|
||||
roomTopic: RoomTopicState,
|
||||
onActionClicked: (RoomDetailsAction) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
PreferenceCategory(title = stringResource(CommonStrings.common_topic), modifier = modifier) {
|
||||
PreferenceCategory(title = stringResource(CommonStrings.common_topic)) {
|
||||
if (roomTopic is RoomTopicState.CanAddTopic) {
|
||||
PreferenceText(
|
||||
title = stringResource(R.string.screen_room_details_add_topic_title),
|
||||
|
|
@ -338,14 +340,13 @@ private fun TopicSection(
|
|||
private fun NotificationSection(
|
||||
isDefaultMode: Boolean,
|
||||
openRoomNotificationSettings: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val subtitle = if (isDefaultMode) {
|
||||
stringResource(R.string.screen_room_details_notification_mode_default)
|
||||
} else {
|
||||
stringResource(R.string.screen_room_details_notification_mode_custom)
|
||||
}
|
||||
PreferenceCategory(modifier = modifier) {
|
||||
PreferenceCategory {
|
||||
ListItem(
|
||||
headlineContent = { Text(text = stringResource(R.string.screen_room_details_notification_title)) },
|
||||
supportingContent = { Text(text = subtitle) },
|
||||
|
|
@ -359,9 +360,8 @@ private fun NotificationSection(
|
|||
private fun MembersSection(
|
||||
memberCount: Long,
|
||||
openRoomMemberList: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
PreferenceCategory(modifier = modifier) {
|
||||
PreferenceCategory {
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(CommonStrings.common_people)) },
|
||||
leadingContent = ListItemContent.Icon(IconSource.Resource(CommonDrawables.ic_user)),
|
||||
|
|
@ -374,9 +374,8 @@ private fun MembersSection(
|
|||
@Composable
|
||||
private fun InviteSection(
|
||||
invitePeople: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
PreferenceCategory(modifier = modifier) {
|
||||
PreferenceCategory {
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.screen_room_details_invite_people_title)) },
|
||||
leadingContent = ListItemContent.Icon(IconSource.Resource(CommonDrawables.ic_user_add)),
|
||||
|
|
@ -388,9 +387,8 @@ private fun InviteSection(
|
|||
@Composable
|
||||
private fun PollsSection(
|
||||
openPollHistory: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
PreferenceCategory(modifier = modifier) {
|
||||
PreferenceCategory {
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.screen_polls_history_title)) },
|
||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Polls)),
|
||||
|
|
@ -400,8 +398,8 @@ private fun PollsSection(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun SecuritySection(modifier: Modifier = Modifier) {
|
||||
PreferenceCategory(title = stringResource(R.string.screen_room_details_security_title), modifier = modifier) {
|
||||
private fun SecuritySection() {
|
||||
PreferenceCategory(title = stringResource(R.string.screen_room_details_security_title)) {
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.screen_room_details_encryption_enabled_title)) },
|
||||
supportingContent = { Text(stringResource(R.string.screen_room_details_encryption_enabled_subtitle)) },
|
||||
|
|
@ -411,15 +409,17 @@ private fun SecuritySection(modifier: Modifier = Modifier) {
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun OtherActionsSection(isDm: Boolean, onLeaveRoom: () -> Unit, modifier: Modifier = Modifier) {
|
||||
PreferenceCategory(showDivider = false, modifier = modifier) {
|
||||
private fun OtherActionsSection(isDm: Boolean, onLeaveRoom: () -> Unit) {
|
||||
PreferenceCategory(showDivider = false) {
|
||||
ListItem(
|
||||
headlineContent = {
|
||||
val leaveText = stringResource(id = if (isDm) {
|
||||
R.string.screen_room_details_leave_conversation_title
|
||||
} else {
|
||||
R.string.screen_room_details_leave_room_title
|
||||
})
|
||||
val leaveText = stringResource(
|
||||
id = if (isDm) {
|
||||
R.string.screen_room_details_leave_conversation_title
|
||||
} else {
|
||||
R.string.screen_room_details_leave_room_title
|
||||
}
|
||||
)
|
||||
Text(leaveText)
|
||||
},
|
||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Leave)),
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ import io.element.android.libraries.designsystem.theme.components.Text
|
|||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
||||
@Composable
|
||||
internal fun BlockUserSection(state: RoomMemberDetailsState, modifier: Modifier = Modifier) {
|
||||
PreferenceCategory(showDivider = false, modifier = modifier) {
|
||||
internal fun BlockUserSection(state: RoomMemberDetailsState) {
|
||||
PreferenceCategory(showDivider = false) {
|
||||
when (state.isBlocked) {
|
||||
is AsyncData.Failure -> PreferenceBlockUser(isBlocked = state.isBlocked.prevData, isLoading = false, eventSink = state.eventSink)
|
||||
is AsyncData.Loading -> PreferenceBlockUser(isBlocked = state.isBlocked.prevData, isLoading = true, eventSink = state.eventSink)
|
||||
|
|
@ -70,7 +70,6 @@ private fun PreferenceBlockUser(
|
|||
isBlocked: Boolean?,
|
||||
isLoading: Boolean,
|
||||
eventSink: (RoomMemberDetailsEvents) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val loadingCurrentValue = @Composable {
|
||||
CircularProgressIndicator(
|
||||
|
|
@ -87,7 +86,6 @@ private fun PreferenceBlockUser(
|
|||
onClick = { if (!isLoading) eventSink(RoomMemberDetailsEvents.UnblockUser(needsConfirmation = true)) },
|
||||
trailingContent = if (isLoading) ListItemContent.Custom(loadingCurrentValue) else null,
|
||||
style = ListItemStyle.Primary,
|
||||
modifier = modifier,
|
||||
)
|
||||
} else {
|
||||
ListItem(
|
||||
|
|
@ -96,7 +94,6 @@ private fun PreferenceBlockUser(
|
|||
style = ListItemStyle.Destructive,
|
||||
onClick = { if (!isLoading) eventSink(RoomMemberDetailsEvents.BlockUser(needsConfirmation = true)) },
|
||||
trailingContent = if (isLoading) ListItemContent.Custom(loadingCurrentValue) else null,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,10 +193,8 @@ fun RoomDetailsEditView(
|
|||
private fun LabelledReadOnlyField(
|
||||
title: String,
|
||||
value: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier,
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
Text(
|
||||
|
|
|
|||
|
|
@ -115,10 +115,8 @@ private fun RoomInviteMembersTopBar(
|
|||
canSend: Boolean,
|
||||
onBackPressed: () -> Unit,
|
||||
onSubmitPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
TopAppBar(
|
||||
modifier = modifier,
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(R.string.screen_room_details_invite_people_title),
|
||||
|
|
|
|||
|
|
@ -194,10 +194,8 @@ private fun RoomMemberListTopBar(
|
|||
canInvite: Boolean,
|
||||
onBackPressed: () -> Unit,
|
||||
onInvitePressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
TopAppBar(
|
||||
modifier = modifier,
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(CommonStrings.common_people),
|
||||
|
|
|
|||
|
|
@ -108,14 +108,12 @@ fun RoomMemberDetailsView(
|
|||
@Composable
|
||||
private fun StartDMSection(
|
||||
onStartDMClicked: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(CommonStrings.common_direct_chat)) },
|
||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Chat)),
|
||||
style = ListItemStyle.Primary,
|
||||
onClick = onStartDMClicked,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -178,10 +178,8 @@ private fun RoomSpecificNotificationSettingsView(
|
|||
@Composable
|
||||
private fun RoomNotificationSettingsTopBar(
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
TopAppBar(
|
||||
modifier = modifier,
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(R.string.screen_room_details_notification_title),
|
||||
|
|
|
|||
|
|
@ -103,10 +103,8 @@ fun UserDefinedRoomNotificationSettingsView(
|
|||
private fun UserDefinedRoomNotificationSettingsTopBar(
|
||||
roomName: String,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
TopAppBar(
|
||||
modifier = modifier,
|
||||
title = {
|
||||
Text(
|
||||
text = roomName,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue