Skip to content

feat: history options screens when creating new channel [WPB-15877] #4090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 3, 2025
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import com.wire.android.util.ui.PreviewMultipleThemes
@Composable
fun WireRadioButton(
checked: Boolean,
onButtonChecked: (() -> Unit),
modifier: Modifier = Modifier,
onButtonChecked: (() -> Unit)? = null,
enabled: Boolean = true,
modifier: Modifier = Modifier
) {
RadioButton(
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.wire.android.ui.common.groupname

import com.wire.android.ui.home.newconversation.channelaccess.ChannelAccessType
import com.wire.android.ui.home.newconversation.channelaccess.ChannelAddPermissionType
import com.wire.android.ui.home.newconversation.channelhistory.ChannelHistoryType
import com.wire.android.ui.home.newconversation.model.Contact
import com.wire.kalium.logic.data.conversation.CreateConversationParam
import kotlinx.collections.immutable.ImmutableSet
Expand All @@ -40,6 +41,7 @@ data class GroupMetadataState(
val isServicesAllowed: Boolean = false,
val channelAccessType: ChannelAccessType = ChannelAccessType.PRIVATE,
val channelAddPermissionType: ChannelAddPermissionType = ChannelAddPermissionType.ADMINS,
val channelHistoryType: ChannelHistoryType = ChannelHistoryType.Off,
val completed: Completed = Completed.None,
) {
enum class Completed {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ fun GroupConversationSettings(
title = stringResource(R.string.channel_access_label),
subtitle = stringResource(id = R.string.channel_access_short_description),
arrowType = if (state.isUpdatingChannelAccessAllowed) ArrowType.TITLE_ALIGNED else ArrowType.NONE,
arrowLabel = stringResource(state.channelAccessType!!.label),
arrowLabel = stringResource(state.channelAccessType!!.labelResId),
arrowLabelColor = colorsScheme().onBackground,
onClick = onChannelAccessItemClicked,
isClickable = state.isUpdatingChannelAccessAllowed,
clickable = Clickable(
enabled = state.isUpdatingChannelAccessAllowed,
onClick = onChannelAccessItemClicked,
),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wire.android.R
import com.wire.android.model.Clickable
import com.wire.android.ui.common.ArrowRightIcon
import com.wire.android.ui.common.WireRadioButton
import com.wire.android.ui.common.button.WireSecondaryButton
import com.wire.android.ui.common.clickable
import com.wire.android.ui.home.settings.SettingsOptionSwitch
import com.wire.android.ui.home.settings.SwitchState
import com.wire.android.ui.theme.WireTheme
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.ui.PreviewMultipleThemes

@Composable
fun GroupConversationOptionsItem(
Expand All @@ -57,9 +59,7 @@ fun GroupConversationOptionsItem(
.fillMaxWidth()
.background(MaterialTheme.wireColorScheme.surface)
.defaultMinSize(minHeight = MaterialTheme.wireDimensions.conversationOptionsItemMinHeight),
isClickable: Boolean = false,
onClick: () -> Unit = {},
clickable: Clickable = Clickable(enabled = isClickable, onClick = onClick),
clickable: Clickable = Clickable(enabled = false, onClick = {}),
arrowLabel: String? = null,
arrowLabelColor: Color = MaterialTheme.wireColorScheme.secondaryText,
subtitle: String? = null,
Expand All @@ -70,7 +70,8 @@ fun GroupConversationOptionsItem(
switchState: SwitchState = SwitchState.None,
titleStyle: TextStyle = MaterialTheme.wireTypography.body02,
arrowType: ArrowType = ArrowType.CENTER_ALIGNED,
contentDescription: String? = null
contentDescription: String? = null,
selected: Boolean? = null,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
Expand All @@ -96,6 +97,12 @@ fun GroupConversationOptionsItem(
)
}
Row(verticalAlignment = Alignment.CenterVertically) {
if (selected != null) {
WireRadioButton(
checked = selected,
modifier = Modifier.padding(end = MaterialTheme.wireDimensions.spacing8x),
)
}
Text(
text = title,
style = titleStyle,
Expand Down Expand Up @@ -142,7 +149,6 @@ private fun ArrowRight() {
Box(
modifier = Modifier.padding(
start = MaterialTheme.wireDimensions.spacing8x,
end = MaterialTheme.wireDimensions.spacing8x
)
) { ArrowRightIcon(contentDescription = R.string.content_description_empty) }
}
Expand All @@ -152,14 +158,14 @@ enum class ArrowType {
}

@Composable
@Preview(name = "Item with label and title")
fun PreviewGroupConversationOptionsWithLabelAndTitle() {
@PreviewMultipleThemes
fun PreviewGroupConversationOptionsWithLabelAndTitle() = WireTheme {
GroupConversationOptionsItem(title = "Conversation group title", label = "GROUP NAME")
}

@Composable
@Preview(name = "Item with title and switch clickable")
fun PreviewGroupConversationOptionsWithTitleAndSwitchClickable() {
@PreviewMultipleThemes
fun PreviewGroupConversationOptionsWithTitleAndSwitchClickable() = WireTheme {
GroupConversationOptionsItem(
title = "Services",
switchState = SwitchState.Enabled(value = true, onCheckedChange = {}),
Expand All @@ -168,8 +174,18 @@ fun PreviewGroupConversationOptionsWithTitleAndSwitchClickable() {
}

@Composable
@Preview(name = "Item with title and text only switch")
fun PreviewGroupConversationOptionsWithTitleAndTextOnlySwitch() {
@PreviewMultipleThemes
fun PreviewGroupConversationOptionsWithTitleAndSwitchWithoutArrow() = WireTheme {
GroupConversationOptionsItem(
title = "Services",
switchState = SwitchState.Enabled(value = true, onCheckedChange = {}),
arrowType = ArrowType.NONE
)
}

@Composable
@PreviewMultipleThemes
fun PreviewGroupConversationOptionsWithTitleAndTextOnlySwitch() = WireTheme {
GroupConversationOptionsItem(
title = "Services",
switchState = SwitchState.TextOnly(value = true),
Expand All @@ -178,8 +194,8 @@ fun PreviewGroupConversationOptionsWithTitleAndTextOnlySwitch() {
}

@Composable
@Preview(name = "Item with title, subtitle and icon")
fun PreviewGroupConversationOptionsWithTitleAndSubtitleAndIcon() {
@PreviewMultipleThemes
fun PreviewGroupConversationOptionsWithTitleAndSubtitleAndIcon() = WireTheme {
GroupConversationOptionsItem(
title = "Group Color",
subtitle = "Red",
Expand All @@ -195,8 +211,8 @@ fun PreviewGroupConversationOptionsWithTitleAndSubtitleAndIcon() {
}

@Composable
@Preview(name = "Item with title, subtitle, switch and footer button")
fun PreviewGroupConversationOptionsWithTitleAndSubtitleAndSwitchAndFooterButton() {
@PreviewMultipleThemes
fun PreviewGroupConversationOptionsWithTitleAndSubtitleAndSwitchAndFooterButton() = WireTheme {
GroupConversationOptionsItem(
title = "Guests",
subtitle = "Turn this option ON to open this conversation to people outside your team, even if they don't have Wire.",
Expand All @@ -207,12 +223,23 @@ fun PreviewGroupConversationOptionsWithTitleAndSubtitleAndSwitchAndFooterButton(
}

@Composable
@Preview(name = "Item with title and subtitle without arrow")
fun PreviewGroupConversationOptionsWithTitleAndSubtitleWithoutArrow() {
@PreviewMultipleThemes
fun PreviewGroupConversationOptionsWithTitleAndSubtitleWithoutArrow() = WireTheme {
GroupConversationOptionsItem(
label = "Cipher Suite",
title = "MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519(0x0001)",
titleStyle = MaterialTheme.wireTypography.body01,
arrowType = ArrowType.NONE
)
}

@Composable
@PreviewMultipleThemes
fun PreviewGroupConversationOptionsWithTitleAndArrowLabelAndRadioButton() = WireTheme {
GroupConversationOptionsItem(
title = "Custom",
arrowLabel = "12 weeks",
arrowType = ArrowType.TITLE_ALIGNED,
selected = true,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.wire.android.ui.home.newconversation.channelaccess.ChannelAccessType
import com.wire.android.ui.home.newconversation.channelaccess.ChannelAddPermissionType
import com.wire.android.ui.home.newconversation.channelaccess.toDomainEnum
import com.wire.android.ui.home.newconversation.channelhistory.ChannelHistoryType
import com.wire.android.ui.home.newconversation.common.CreateGroupState
import com.wire.android.ui.home.newconversation.groupOptions.GroupOptionState
import com.wire.android.ui.home.newconversation.model.Contact
Expand Down Expand Up @@ -87,6 +88,7 @@
}
)
var isChannelCreationPossible: Boolean by mutableStateOf(true)
var isFreemiumAccount: Boolean by mutableStateOf(false) // TODO: implement logic to determine if the account is freemium

var createGroupState: CreateGroupState by mutableStateOf(CreateGroupState.Default)

Expand Down Expand Up @@ -139,6 +141,10 @@
newGroupState = newGroupState.copy(isChannel = isChannel)
}

fun setChannelHistoryType(channelHistoryType: ChannelHistoryType) {
newGroupState = newGroupState.copy(channelHistoryType = channelHistoryType)

Check warning on line 145 in app/src/main/kotlin/com/wire/android/ui/home/newconversation/NewConversationViewModel.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/newconversation/NewConversationViewModel.kt#L145

Added line #L145 was not covered by tests
}

private fun setConversationCreationParam() {
viewModelScope.launch {
val selfUser = getSelfUser()
Expand Down Expand Up @@ -265,6 +271,7 @@
),
access = Conversation.accessFor(groupOptionsState.isAllowGuestEnabled),
channelAddPermission = newGroupState.channelAddPermissionType.toDomainEnum()
// TODO: include channel history type
)
)
handleNewGroupCreationResult(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.theme.WireTheme
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.ui.PreviewMultipleThemes
Expand Down Expand Up @@ -71,7 +72,7 @@ fun AccessScreenItem(
enabled = isEnabled
)
Text(
text = stringResource(channelAccessType.label),
text = stringResource(channelAccessType.labelResId),
style = MaterialTheme.wireTypography.body01,
color = if (isEnabled) colorsScheme().onBackground else Color.Gray,
modifier = Modifier.padding(vertical = dimensions().spacing16x)
Expand All @@ -81,7 +82,7 @@ fun AccessScreenItem(

@Composable
@PreviewMultipleThemes
fun PreviewAccessScreenItem() {
fun PreviewAccessScreenItem() = WireTheme {
AccessScreenItem(
channelAccessType = ChannelAccessType.PRIVATE,
selectedAccess = ChannelAccessType.PRIVATE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
package com.wire.android.ui.home.newconversation.channelaccess

import android.os.Parcelable
import androidx.annotation.StringRes
import com.wire.android.R
import com.wire.kalium.logic.data.conversation.ConversationDetails.Group.Channel.ChannelAccess
import kotlinx.parcelize.Parcelize

@Parcelize
enum class ChannelAccessType(val label: Int) : Parcelable {
enum class ChannelAccessType(@StringRes val labelResId: Int) : Parcelable {
PUBLIC(R.string.channel_public_label),
PRIVATE(R.string.channel_private_label)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
*/
package com.wire.android.ui.home.newconversation.channelaccess

import androidx.annotation.StringRes
import com.wire.android.R
import com.wire.kalium.logic.data.conversation.ConversationDetails.Group.Channel.ChannelAddPermission

enum class ChannelAddPermissionType(val label: Int) {
enum class ChannelAddPermissionType(@StringRes val labelResId: Int) {
ADMINS(R.string.channel_add_permission_admin_label),
EVERYONE(R.string.channel_add_permission_admin_members_label)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.selectableBackground
import com.wire.android.ui.theme.WireTheme
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.ui.PreviewMultipleThemes
Expand All @@ -53,7 +54,7 @@ fun PermissionItem(
) {
RadioButton(selected = isSelected, onClick = { onItemClicked(channelAddPermissionType) })
Text(
text = stringResource(channelAddPermissionType.label),
text = stringResource(channelAddPermissionType.labelResId),
style = MaterialTheme.wireTypography.body01,
color = MaterialTheme.wireColorScheme.onBackground,
modifier = Modifier.padding(vertical = dimensions().spacing16x)
Expand All @@ -63,7 +64,7 @@ fun PermissionItem(

@Composable
@PreviewMultipleThemes
fun PreviewPermissionItem() {
fun PreviewPermissionItem() = WireTheme {
PermissionItem(
channelAddPermissionType = ChannelAddPermissionType.ADMINS,
selectedPermission = ChannelAddPermissionType.ADMINS,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Wire
* Copyright (C) 2025 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.home.newconversation.channelhistory

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
class ChannelHistoryCustomArgs(val currentType: ChannelHistoryType) : Parcelable

Check warning on line 24 in app/src/main/kotlin/com/wire/android/ui/home/newconversation/channelhistory/ChannelHistoryCustomArgs.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/newconversation/channelhistory/ChannelHistoryCustomArgs.kt#L23-L24

Added lines #L23 - L24 were not covered by tests

@Parcelize
class ChannelHistoryCustomNavBackArgs(val customType: ChannelHistoryType.On.Specific) : Parcelable

Check warning on line 27 in app/src/main/kotlin/com/wire/android/ui/home/newconversation/channelhistory/ChannelHistoryCustomArgs.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/newconversation/channelhistory/ChannelHistoryCustomArgs.kt#L26-L27

Added lines #L26 - L27 were not covered by tests
Loading
Loading