generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BITAU-184 Allow user to save to Bitwarden when adding a code manually (…
- Loading branch information
1 parent
bcc7e67
commit 5ac5e31
Showing
6 changed files
with
441 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...bitwarden/authenticator/ui/authenticator/feature/manualcodeentry/SaveManualCodeButtons.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.bitwarden.authenticator.ui.authenticator.feature.manualcodeentry | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.semantics.semantics | ||
import androidx.compose.ui.semantics.testTag | ||
import androidx.compose.ui.unit.dp | ||
import com.bitwarden.authenticator.R | ||
import com.bitwarden.authenticator.ui.platform.components.button.BitwardenFilledButton | ||
import com.bitwarden.authenticator.ui.platform.components.button.BitwardenFilledTonalButton | ||
import com.bitwarden.authenticator.ui.platform.components.button.BitwardenOutlinedButton | ||
|
||
/** | ||
* Displays save buttons for saving a manually entered code. | ||
* | ||
* @param state State of the buttons to show. | ||
* @param onSaveLocallyClick Callback invoked when the user clicks save locally. | ||
* @param onSaveToBitwardenClick Callback invoked when the user clicks save to Bitwarden. | ||
*/ | ||
@Composable | ||
fun SaveManualCodeButtons( | ||
state: ManualCodeEntryState.ButtonState, | ||
onSaveLocallyClick: () -> Unit, | ||
onSaveToBitwardenClick: () -> Unit, | ||
) { | ||
|
||
when (state) { | ||
ManualCodeEntryState.ButtonState.LocalOnly -> { | ||
BitwardenFilledTonalButton( | ||
label = stringResource(id = R.string.add_code), | ||
onClick = onSaveLocallyClick, | ||
modifier = Modifier | ||
.semantics { testTag = "AddCodeButton" } | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp), | ||
) | ||
} | ||
|
||
ManualCodeEntryState.ButtonState.SaveLocallyPrimary -> { | ||
Column { | ||
BitwardenFilledButton( | ||
label = stringResource(id = R.string.add_code_locally), | ||
onClick = onSaveLocallyClick, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp), | ||
) | ||
BitwardenOutlinedButton( | ||
label = stringResource(R.string.add_code_to_bitwarden), | ||
onClick = onSaveToBitwardenClick, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp), | ||
) | ||
} | ||
} | ||
|
||
ManualCodeEntryState.ButtonState.SaveToBitwardenPrimary -> { | ||
Column { | ||
BitwardenFilledButton( | ||
label = stringResource(id = R.string.add_code_to_bitwarden), | ||
onClick = onSaveToBitwardenClick, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp), | ||
) | ||
BitwardenOutlinedButton( | ||
label = stringResource(R.string.add_code_locally), | ||
onClick = onSaveLocallyClick, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp), | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.