mirror of
https://github.com/bitwarden/android.git
synced 2025-03-15 18:58:59 +03:00
BIT-1405: Update date-time picker labels (#1156)
This commit is contained in:
parent
e220d627f1
commit
b2f8d89de4
6 changed files with 18 additions and 4 deletions
|
@ -38,6 +38,7 @@ import java.time.ZonedDateTime
|
|||
* This composable displays an [OutlinedTextField] with a dropdown icon as a trailing icon.
|
||||
* When the field is clicked, a date picker dialog appears.
|
||||
*
|
||||
* @param label The displayed label.
|
||||
* @param currentZonedDateTime The currently displayed time.
|
||||
* @param formatPattern The pattern to format the displayed time.
|
||||
* @param onDateSelect The callback to be invoked when a new date is selected.
|
||||
|
@ -48,6 +49,7 @@ import java.time.ZonedDateTime
|
|||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun BitwardenDateSelectButton(
|
||||
label: String,
|
||||
currentZonedDateTime: ZonedDateTime?,
|
||||
formatPattern: String,
|
||||
onDateSelect: (ZonedDateTime) -> Unit,
|
||||
|
@ -62,8 +64,6 @@ fun BitwardenDateSelectButton(
|
|||
?: "mm/dd/yyyy",
|
||||
)
|
||||
}
|
||||
// TODO: This should be "Date" but we don't have that string (BIT-1405)
|
||||
val label = stringResource(id = R.string.deletion_date)
|
||||
|
||||
OutlinedTextField(
|
||||
modifier = modifier
|
||||
|
|
|
@ -15,7 +15,6 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
|
@ -31,6 +30,7 @@ import java.time.ZonedDateTime
|
|||
* This composable displays an [OutlinedTextField] with a dropdown icon as a trailing icon.
|
||||
* When the field is clicked, a time picker dialog appears.
|
||||
*
|
||||
* @param label The displayed label.
|
||||
* @param currentZonedDateTime The currently displayed time.
|
||||
* @param formatPattern The pattern to format the displayed time.
|
||||
* @param onTimeSelect The callback to be invoked when a new time is selected.
|
||||
|
@ -41,6 +41,7 @@ import java.time.ZonedDateTime
|
|||
*/
|
||||
@Composable
|
||||
fun BitwardenTimeSelectButton(
|
||||
label: String,
|
||||
currentZonedDateTime: ZonedDateTime?,
|
||||
formatPattern: String,
|
||||
onTimeSelect: (hour: Int, minute: Int) -> Unit,
|
||||
|
@ -56,7 +57,6 @@ fun BitwardenTimeSelectButton(
|
|||
?: "--:-- --",
|
||||
)
|
||||
}
|
||||
val label = stringResource(id = R.string.time)
|
||||
OutlinedTextField(
|
||||
modifier = modifier
|
||||
.clearAndSetSemantics {
|
||||
|
|
|
@ -367,6 +367,8 @@ private fun AddSendOptions(
|
|||
.semantics { testTag = "SendCustomDeletionDatePicker" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
dateLabel = stringResource(id = R.string.deletion_date),
|
||||
timeLabel = stringResource(id = R.string.deletion_time),
|
||||
dateFormatPattern = state.common.dateFormatPattern,
|
||||
timeFormatPattern = state.common.timeFormatPattern,
|
||||
currentZonedDateTime = state.common.deletionDate,
|
||||
|
@ -396,6 +398,8 @@ private fun AddSendOptions(
|
|||
.semantics { testTag = "SendCustomExpirationDatePicker" }
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
dateLabel = stringResource(id = R.string.expiration_date),
|
||||
timeLabel = stringResource(id = R.string.expiration_time),
|
||||
dateFormatPattern = state.common.dateFormatPattern,
|
||||
timeFormatPattern = state.common.timeFormatPattern,
|
||||
currentZonedDateTime = state.common.expirationDate,
|
||||
|
|
|
@ -23,6 +23,8 @@ import kotlin.time.Duration.Companion.minutes
|
|||
/**
|
||||
* Displays a UI for selecting a customizable date and time.
|
||||
*
|
||||
* @param dateLabel The display label for the date selection field.
|
||||
* @param timeLabel The display label for the time selection field.
|
||||
* @param currentZonedDateTime The currently selected time, `null` when no time is selected yet.
|
||||
* @param dateFormatPattern The pattern to use when displaying the date.
|
||||
* @param timeFormatPattern The pattern for displaying the time.
|
||||
|
@ -33,6 +35,8 @@ import kotlin.time.Duration.Companion.minutes
|
|||
*/
|
||||
@Composable
|
||||
fun AddSendCustomDateChooser(
|
||||
dateLabel: String,
|
||||
timeLabel: String,
|
||||
currentZonedDateTime: ZonedDateTime?,
|
||||
dateFormatPattern: String,
|
||||
timeFormatPattern: String,
|
||||
|
@ -61,6 +65,7 @@ fun AddSendCustomDateChooser(
|
|||
) {
|
||||
BitwardenDateSelectButton(
|
||||
modifier = Modifier.weight(1f),
|
||||
label = dateLabel,
|
||||
formatPattern = dateFormatPattern,
|
||||
currentZonedDateTime = currentZonedDateTime,
|
||||
isEnabled = isEnabled,
|
||||
|
@ -72,6 +77,7 @@ fun AddSendCustomDateChooser(
|
|||
Spacer(modifier = Modifier.width(16.dp))
|
||||
BitwardenTimeSelectButton(
|
||||
modifier = Modifier.weight(1f),
|
||||
label = timeLabel,
|
||||
formatPattern = timeFormatPattern,
|
||||
currentZonedDateTime = currentZonedDateTime,
|
||||
isEnabled = isEnabled,
|
||||
|
|
|
@ -65,6 +65,8 @@ fun SendDeletionDateChooser(
|
|||
Column {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
AddSendCustomDateChooser(
|
||||
dateLabel = stringResource(id = R.string.deletion_date),
|
||||
timeLabel = stringResource(id = R.string.deletion_time),
|
||||
currentZonedDateTime = currentZonedDateTime,
|
||||
dateFormatPattern = dateFormatPattern,
|
||||
timeFormatPattern = timeFormatPattern,
|
||||
|
|
|
@ -67,6 +67,8 @@ fun SendExpirationDateChooser(
|
|||
Column {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
AddSendCustomDateChooser(
|
||||
dateLabel = stringResource(id = R.string.expiration_date),
|
||||
timeLabel = stringResource(id = R.string.expiration_time),
|
||||
currentZonedDateTime = currentZonedDateTime,
|
||||
dateFormatPattern = dateFormatPattern,
|
||||
timeFormatPattern = timeFormatPattern,
|
||||
|
|
Loading…
Add table
Reference in a new issue