mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
PM-12668: Update TopAppBars accross the app (#4074)
This commit is contained in:
parent
cd9f4e8723
commit
86db9bd3fa
9 changed files with 86 additions and 35 deletions
|
@ -29,7 +29,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
|||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetReason
|
||||
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenMediumTopAppBar
|
||||
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
|
||||
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
|
||||
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
|
||||
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
|
||||
|
@ -101,8 +101,9 @@ fun ResetPasswordScreen(
|
|||
.fillMaxSize()
|
||||
.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
BitwardenMediumTopAppBar(
|
||||
BitwardenTopAppBar(
|
||||
title = stringResource(id = R.string.update_master_password),
|
||||
navigationIcon = null,
|
||||
scrollBehavior = scrollBehavior,
|
||||
actions = {
|
||||
BitwardenTextButton(
|
||||
|
|
|
@ -28,7 +28,7 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenMediumTopAppBar
|
||||
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
|
||||
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
|
||||
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
|
||||
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
|
||||
|
@ -62,8 +62,9 @@ fun SetPasswordScreen(
|
|||
.fillMaxSize()
|
||||
.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
BitwardenMediumTopAppBar(
|
||||
BitwardenTopAppBar(
|
||||
title = stringResource(id = R.string.set_master_password),
|
||||
navigationIcon = null,
|
||||
scrollBehavior = scrollBehavior,
|
||||
actions = {
|
||||
BitwardenTextButton(
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.RowScope
|
|||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.MediumTopAppBar
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.TopAppBarScrollBehavior
|
||||
import androidx.compose.material3.rememberTopAppBarState
|
||||
|
@ -45,13 +46,14 @@ fun BitwardenMediumTopAppBar(
|
|||
dividerStyle: TopAppBarDividerStyle = TopAppBarDividerStyle.ON_SCROLL,
|
||||
actions: @Composable RowScope.() -> Unit = {},
|
||||
) {
|
||||
MediumTopAppBar(
|
||||
TopAppBar(
|
||||
colors = bitwardenTopAppBarColors(),
|
||||
scrollBehavior = scrollBehavior,
|
||||
expandedHeight = 56.dp,
|
||||
title = {
|
||||
Text(
|
||||
text = title,
|
||||
style = BitwardenTheme.typography.titleLarge,
|
||||
style = BitwardenTheme.typography.headlineMedium,
|
||||
modifier = Modifier.testTag(tag = "PageTitleLabel"),
|
||||
)
|
||||
},
|
||||
|
|
|
@ -19,6 +19,7 @@ import androidx.compose.ui.platform.testTag
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.mirrorIfRtl
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.scrolledContainerBottomDivider
|
||||
|
@ -107,6 +108,8 @@ fun BitwardenTopAppBar(
|
|||
colors = bitwardenTopAppBarColors(),
|
||||
scrollBehavior = scrollBehavior,
|
||||
navigationIcon = navigationIconContent,
|
||||
collapsedHeight = 48.dp,
|
||||
expandedHeight = 96.dp,
|
||||
title = {
|
||||
// The height of the component is controlled and will only allow for 1 extra row,
|
||||
// making adding any arguments for softWrap and minLines superfluous.
|
||||
|
@ -127,6 +130,7 @@ fun BitwardenTopAppBar(
|
|||
colors = bitwardenTopAppBarColors(),
|
||||
scrollBehavior = scrollBehavior,
|
||||
navigationIcon = navigationIconContent,
|
||||
expandedHeight = 48.dp,
|
||||
title = {
|
||||
Text(
|
||||
text = title,
|
||||
|
|
|
@ -70,9 +70,7 @@ fun SettingsScreen(
|
|||
}
|
||||
}
|
||||
|
||||
val scrollBehavior =
|
||||
TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState())
|
||||
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
BitwardenScaffold(
|
||||
topBar = {
|
||||
BitwardenMediumTopAppBar(
|
||||
|
|
|
@ -179,14 +179,7 @@ fun GeneratorScreen(
|
|||
RandomWordHandlers.create(viewModel = viewModel)
|
||||
}
|
||||
|
||||
val scrollBehavior = when (state.generatorMode) {
|
||||
GeneratorMode.Default -> {
|
||||
TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState())
|
||||
}
|
||||
|
||||
else -> TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
}
|
||||
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
BitwardenScaffold(
|
||||
topBar = {
|
||||
when (state.generatorMode) {
|
||||
|
|
|
@ -103,7 +103,7 @@ fun SendScreen(
|
|||
)
|
||||
|
||||
val sendHandlers = remember(viewModel) { SendHandlers.create(viewModel) }
|
||||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(
|
||||
state = rememberTopAppBarState(),
|
||||
)
|
||||
BitwardenScaffold(
|
||||
|
|
|
@ -179,7 +179,7 @@ private fun VaultScreenScaffold(
|
|||
onDimBottomNavBarRequest(shouldShowMenu)
|
||||
}
|
||||
var shouldShowExitConfirmationDialog by rememberSaveable { mutableStateOf(false) }
|
||||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(
|
||||
state = rememberTopAppBarState(),
|
||||
canScroll = { !accountMenuVisible },
|
||||
)
|
||||
|
|
|
@ -12,7 +12,10 @@ import androidx.compose.ui.test.hasText
|
|||
import androidx.compose.ui.test.isDialog
|
||||
import androidx.compose.ui.test.isDisplayed
|
||||
import androidx.compose.ui.test.isPopup
|
||||
import androidx.compose.ui.test.onAllNodesWithContentDescription
|
||||
import androidx.compose.ui.test.onAllNodesWithText
|
||||
import androidx.compose.ui.test.onFirst
|
||||
import androidx.compose.ui.test.onLast
|
||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
|
@ -37,6 +40,7 @@ import org.junit.Assert.assertTrue
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
@Suppress("LargeClass")
|
||||
class SendScreenTest : BaseComposeTest() {
|
||||
|
||||
private var onNavigateToNewSendCalled = false
|
||||
|
@ -438,14 +442,20 @@ class SendScreenTest : BaseComposeTest() {
|
|||
viewState = SendState.ViewState.Content(
|
||||
textTypeCount = 0,
|
||||
fileTypeCount = 1,
|
||||
sendItems = listOf(DEFAULT_SEND_ITEM),
|
||||
sendItems = listOf(
|
||||
DEFAULT_SEND_ITEM,
|
||||
DEFAULT_SEND_ITEM.copy(id = "mockId-2"),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
// We scroll to the last item but click the first one to avoid clicking the FAB by mistake
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.onAllNodesWithContentDescription("Options")
|
||||
.apply { onLast().performScrollTo() }
|
||||
.onFirst()
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
|
@ -462,14 +472,20 @@ class SendScreenTest : BaseComposeTest() {
|
|||
viewState = SendState.ViewState.Content(
|
||||
textTypeCount = 0,
|
||||
fileTypeCount = 1,
|
||||
sendItems = listOf(DEFAULT_SEND_ITEM),
|
||||
sendItems = listOf(
|
||||
DEFAULT_SEND_ITEM,
|
||||
DEFAULT_SEND_ITEM.copy(id = "mockId-2"),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
// We scroll to the last item but click the first one to avoid clicking the FAB by mistake
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.onAllNodesWithContentDescription("Options")
|
||||
.apply { onLast().performScrollTo() }
|
||||
.onFirst()
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
|
@ -492,14 +508,20 @@ class SendScreenTest : BaseComposeTest() {
|
|||
viewState = SendState.ViewState.Content(
|
||||
textTypeCount = 0,
|
||||
fileTypeCount = 1,
|
||||
sendItems = listOf(DEFAULT_SEND_ITEM),
|
||||
sendItems = listOf(
|
||||
DEFAULT_SEND_ITEM,
|
||||
DEFAULT_SEND_ITEM.copy(id = "mockId-2"),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
// We scroll to the last item but click the first one to avoid clicking the FAB by mistake
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.onAllNodesWithContentDescription("Options")
|
||||
.apply { onLast().performScrollTo() }
|
||||
.onFirst()
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
|
@ -522,14 +544,20 @@ class SendScreenTest : BaseComposeTest() {
|
|||
viewState = SendState.ViewState.Content(
|
||||
textTypeCount = 0,
|
||||
fileTypeCount = 1,
|
||||
sendItems = listOf(DEFAULT_SEND_ITEM),
|
||||
sendItems = listOf(
|
||||
DEFAULT_SEND_ITEM,
|
||||
DEFAULT_SEND_ITEM.copy(id = "mockId-2"),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
// We scroll to the last item but click the first one to avoid clicking the FAB by mistake
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.onAllNodesWithContentDescription("Options")
|
||||
.apply { onLast().performScrollTo() }
|
||||
.onFirst()
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
|
@ -552,14 +580,20 @@ class SendScreenTest : BaseComposeTest() {
|
|||
viewState = SendState.ViewState.Content(
|
||||
textTypeCount = 0,
|
||||
fileTypeCount = 1,
|
||||
sendItems = listOf(DEFAULT_SEND_ITEM),
|
||||
sendItems = listOf(
|
||||
DEFAULT_SEND_ITEM,
|
||||
DEFAULT_SEND_ITEM.copy(id = "mockId-2"),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
// We scroll to the last item but click the first one to avoid clicking the FAB by mistake
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.onAllNodesWithContentDescription("Options")
|
||||
.apply { onLast().performScrollTo() }
|
||||
.onFirst()
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
|
@ -582,14 +616,20 @@ class SendScreenTest : BaseComposeTest() {
|
|||
viewState = SendState.ViewState.Content(
|
||||
textTypeCount = 0,
|
||||
fileTypeCount = 1,
|
||||
sendItems = listOf(DEFAULT_SEND_ITEM),
|
||||
sendItems = listOf(
|
||||
DEFAULT_SEND_ITEM,
|
||||
DEFAULT_SEND_ITEM.copy(id = "mockId-2"),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
// We scroll to the last item but click the first one to avoid clicking the FAB by mistake
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.onAllNodesWithContentDescription("Options")
|
||||
.apply { onLast().performScrollTo() }
|
||||
.onFirst()
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
|
@ -611,14 +651,20 @@ class SendScreenTest : BaseComposeTest() {
|
|||
viewState = SendState.ViewState.Content(
|
||||
textTypeCount = 0,
|
||||
fileTypeCount = 1,
|
||||
sendItems = listOf(DEFAULT_SEND_ITEM),
|
||||
sendItems = listOf(
|
||||
DEFAULT_SEND_ITEM,
|
||||
DEFAULT_SEND_ITEM.copy(id = "mockId-2"),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
// We scroll to the last item but click the first one to avoid clicking the FAB by mistake
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.onAllNodesWithContentDescription("Options")
|
||||
.apply { onLast().performScrollTo() }
|
||||
.onFirst()
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
|
@ -646,14 +692,20 @@ class SendScreenTest : BaseComposeTest() {
|
|||
viewState = SendState.ViewState.Content(
|
||||
textTypeCount = 0,
|
||||
fileTypeCount = 1,
|
||||
sendItems = listOf(DEFAULT_SEND_ITEM),
|
||||
sendItems = listOf(
|
||||
DEFAULT_SEND_ITEM,
|
||||
DEFAULT_SEND_ITEM.copy(id = "mockId-2"),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
// We scroll to the last item but click the first one to avoid clicking the FAB by mistake
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Options")
|
||||
.onAllNodesWithContentDescription("Options")
|
||||
.apply { onLast().performScrollTo() }
|
||||
.onFirst()
|
||||
.assertIsDisplayed()
|
||||
.performClick()
|
||||
|
||||
|
|
Loading…
Reference in a new issue