More cleanup on BugReportView.
This commit is contained in:
parent
5accd9f139
commit
da7e9a8bf2
2 changed files with 27 additions and 7 deletions
|
|
@ -110,12 +110,14 @@ fun BugReportView(
|
||||||
onCheckedChange = { eventSink(BugReportEvents.SetSendLog(it)) },
|
onCheckedChange = { eventSink(BugReportEvents.SetSendLog(it)) },
|
||||||
enabled = isFormEnabled,
|
enabled = isFormEnabled,
|
||||||
title = stringResource(id = R.string.screen_bug_report_include_logs),
|
title = stringResource(id = R.string.screen_bug_report_include_logs),
|
||||||
|
subtitle = stringResource(id = R.string.screen_bug_report_logs_description),
|
||||||
)
|
)
|
||||||
PreferenceSwitch(
|
PreferenceSwitch(
|
||||||
isChecked = state.formState.canContact,
|
isChecked = state.formState.canContact,
|
||||||
onCheckedChange = { eventSink(BugReportEvents.SetCanContact(it)) },
|
onCheckedChange = { eventSink(BugReportEvents.SetCanContact(it)) },
|
||||||
enabled = isFormEnabled,
|
enabled = isFormEnabled,
|
||||||
title = stringResource(id = R.string.screen_bug_report_contact_me)
|
title = stringResource(id = R.string.screen_bug_report_contact_me_title),
|
||||||
|
subtitle = stringResource(id = R.string.screen_bug_report_contact_me),
|
||||||
)
|
)
|
||||||
if (state.screenshotUri != null) {
|
if (state.screenshotUri != null) {
|
||||||
PreferenceSwitch(
|
PreferenceSwitch(
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,12 @@
|
||||||
package io.element.android.libraries.designsystem.components.preferences
|
package io.element.android.libraries.designsystem.components.preferences
|
||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.defaultMinSize
|
import androidx.compose.foundation.layout.defaultMinSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Announcement
|
import androidx.compose.material.icons.filled.Announcement
|
||||||
|
|
@ -35,6 +38,7 @@ import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||||
import io.element.android.libraries.designsystem.theme.components.Text
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
import io.element.android.libraries.designsystem.toEnabledColor
|
import io.element.android.libraries.designsystem.toEnabledColor
|
||||||
|
import io.element.android.libraries.designsystem.toSecondaryEnabledColor
|
||||||
import io.element.android.libraries.theme.ElementTheme
|
import io.element.android.libraries.theme.ElementTheme
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -42,6 +46,7 @@ fun PreferenceSwitch(
|
||||||
title: String,
|
title: String,
|
||||||
isChecked: Boolean,
|
isChecked: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
subtitle: String? = null,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
icon: ImageVector? = null,
|
icon: ImageVector? = null,
|
||||||
showIconAreaIfNoIcon: Boolean = false,
|
showIconAreaIfNoIcon: Boolean = false,
|
||||||
|
|
@ -60,13 +65,25 @@ fun PreferenceSwitch(
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
isVisible = showIconAreaIfNoIcon
|
isVisible = showIconAreaIfNoIcon
|
||||||
)
|
)
|
||||||
Text(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.weight(1f),
|
.weight(1f)
|
||||||
style = ElementTheme.typography.fontBodyLgRegular,
|
.align(Alignment.CenterVertically)
|
||||||
text = title,
|
) {
|
||||||
color = enabled.toEnabledColor(),
|
Text(
|
||||||
)
|
style = ElementTheme.typography.fontBodyLgRegular,
|
||||||
|
text = title,
|
||||||
|
color = enabled.toEnabledColor(),
|
||||||
|
)
|
||||||
|
if (subtitle != null) {
|
||||||
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
|
Text(
|
||||||
|
style = ElementTheme.typography.fontBodyMdRegular,
|
||||||
|
text = subtitle,
|
||||||
|
color = enabled.toSecondaryEnabledColor(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO Create a wrapper for Switch
|
// TODO Create a wrapper for Switch
|
||||||
Switch(
|
Switch(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -86,6 +103,7 @@ internal fun PreferenceSwitchPreview() = ElementThemedPreview { ContentToPreview
|
||||||
private fun ContentToPreview() {
|
private fun ContentToPreview() {
|
||||||
PreferenceSwitch(
|
PreferenceSwitch(
|
||||||
title = "Switch",
|
title = "Switch",
|
||||||
|
subtitle = "Subtitle Switch",
|
||||||
icon = Icons.Default.Announcement,
|
icon = Icons.Default.Announcement,
|
||||||
enabled = true,
|
enabled = true,
|
||||||
isChecked = true
|
isChecked = true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue