Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Use TopAppBarMultiColor and TopAppBarBackIcon from dev.medzik.and…
Browse files Browse the repository at this point in the history
…roid.components
  • Loading branch information
M3DZIK committed Jun 10, 2024
1 parent ae73816 commit 5934f04
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import androidx.navigation.NavController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import dev.medzik.android.components.icons.TopAppBarBackIcon
import dev.medzik.librepass.android.MainActivity
import dev.medzik.librepass.android.common.NavigationAnimations
import dev.medzik.librepass.android.ui.components.TopBar
import dev.medzik.librepass.android.ui.components.TopBarBackIcon
import dev.medzik.librepass.android.ui.screens.Welcome
import dev.medzik.librepass.android.ui.screens.WelcomeScreen
import dev.medzik.librepass.android.ui.screens.auth.Unlock
Expand Down Expand Up @@ -123,6 +123,6 @@ fun DefaultScaffold(
fun TopBarWithBack(@StringRes title: Int, navController: NavController) {
TopBar(
title = stringResource(title),
navigationIcon = { TopBarBackIcon(navController) }
navigationIcon = { TopAppBarBackIcon(navController) }
)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package dev.medzik.librepass.android.ui.components

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.MoreHoriz
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
Expand All @@ -16,6 +13,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import dev.medzik.android.components.icons.TopAppBarBackIcon

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -42,7 +40,7 @@ fun TopBarPreview() {
TopBar(
title = "Title",
navigationIcon = {
TopBarBackIcon(navController = NavController(LocalContext.current))
TopAppBarBackIcon(navController = NavController(LocalContext.current))
},
actions = {
IconButton(onClick = {}) {
Expand All @@ -54,57 +52,3 @@ fun TopBarPreview() {
}
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TopBarTwoColor(
firstText: String,
secondText: String,
actions: @Composable (RowScope.() -> Unit) = {}
) {
TopAppBar(
title = {
Row {
Text(
text = firstText,
color = MaterialTheme.colorScheme.secondary,
style = MaterialTheme.typography.titleLarge
)

Text(
text = secondText,
color = MaterialTheme.colorScheme.primary,
style = MaterialTheme.typography.titleLarge
)
}
},
actions = actions
)
}

@Preview
@Composable
fun TopBarTwoColorPreview() {
TopBarTwoColor(
firstText = "First",
secondText = "Second",
actions = {
IconButton(onClick = {}) {
Icon(
imageVector = Icons.Default.MoreHoriz,
contentDescription = null
)
}
}
)
}

@Composable
fun TopBarBackIcon(navController: NavController) {
IconButton(onClick = { navController.popBackStack() }) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = null
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.google.accompanist.drawablepainter.DrawablePainter
import dev.medzik.android.components.ui.TopAppBarMultiColor
import dev.medzik.librepass.android.R
import dev.medzik.librepass.android.ui.components.TopBarTwoColor
import dev.medzik.librepass.android.ui.screens.auth.Login
import dev.medzik.librepass.android.ui.screens.auth.Register
import kotlinx.serialization.Serializable
Expand All @@ -31,7 +31,7 @@ fun WelcomeScreen(navController: NavController) {
val icon = context.packageManager.getApplicationIcon(context.packageName)

Scaffold(
topBar = { TopBarTwoColor("Libre", "Pass") }
topBar = { TopAppBarMultiColor(firstText = "Libre", secondText = "Pass") }
) { innerPadding ->
Column(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import dev.medzik.android.components.icons.TopAppBarBackIcon
import dev.medzik.android.components.rememberMutable
import dev.medzik.android.components.rememberMutableBoolean
import dev.medzik.android.components.ui.LoadingButton
Expand All @@ -30,7 +31,6 @@ import dev.medzik.librepass.android.ui.components.CipherEditFieldsCard
import dev.medzik.librepass.android.ui.components.CipherEditFieldsLogin
import dev.medzik.librepass.android.ui.components.CipherEditFieldsSecureNote
import dev.medzik.librepass.android.ui.components.TopBar
import dev.medzik.librepass.android.ui.components.TopBarBackIcon
import dev.medzik.librepass.android.utils.showErrorToast
import dev.medzik.librepass.types.cipher.Cipher
import dev.medzik.librepass.types.cipher.CipherType
Expand Down Expand Up @@ -118,7 +118,7 @@ fun CipherAddScreen(
topBar = {
TopBar(
title = stringResource(R.string.AddNewCipher),
navigationIcon = { TopBarBackIcon(navController) }
navigationIcon = { TopAppBarBackIcon(navController) }
)
}
) { innerPadding ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import dev.medzik.android.components.icons.TopAppBarBackIcon
import dev.medzik.android.components.rememberMutable
import dev.medzik.android.components.rememberMutableBoolean
import dev.medzik.android.components.ui.LoadingButton
Expand All @@ -28,7 +29,6 @@ import dev.medzik.librepass.android.ui.components.CipherEditFieldsCard
import dev.medzik.librepass.android.ui.components.CipherEditFieldsLogin
import dev.medzik.librepass.android.ui.components.CipherEditFieldsSecureNote
import dev.medzik.librepass.android.ui.components.TopBar
import dev.medzik.librepass.android.ui.components.TopBarBackIcon
import dev.medzik.librepass.android.utils.showErrorToast
import dev.medzik.librepass.types.cipher.Cipher
import dev.medzik.librepass.types.cipher.CipherType
Expand Down Expand Up @@ -119,7 +119,7 @@ fun CipherEditScreen(
topBar = {
TopBar(
title = stringResource(R.string.AddNewCipher),
navigationIcon = { TopBarBackIcon(navController) }
navigationIcon = { TopAppBarBackIcon(navController) }
)
}
) { innerPadding ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import dev.medzik.android.components.TextFieldValue
import dev.medzik.android.components.colorizePasswordTransformation
import dev.medzik.android.components.icons.TopAppBarBackIcon
import dev.medzik.android.components.icons.VisibilityIcon
import dev.medzik.android.components.rememberMutable
import dev.medzik.android.components.rememberMutableBoolean
Expand All @@ -61,7 +62,6 @@ import dev.medzik.android.utils.showToast
import dev.medzik.librepass.android.R
import dev.medzik.librepass.android.ui.LibrePassViewModel
import dev.medzik.librepass.android.ui.components.TopBar
import dev.medzik.librepass.android.ui.components.TopBarBackIcon
import dev.medzik.librepass.android.utils.SHORTEN_NAME_LENGTH
import dev.medzik.librepass.android.utils.shorten
import dev.medzik.librepass.types.cipher.CipherType
Expand Down Expand Up @@ -378,7 +378,7 @@ fun CipherViewScreen(
CipherType.SecureNote -> cipher.secureNoteData!!.title
CipherType.Card -> cipher.cardData!!.cardholderName
}.shorten(SHORTEN_NAME_LENGTH),
navigationIcon = { TopBarBackIcon(navController) }
navigationIcon = { TopAppBarBackIcon(navController) }
)
},
floatingActionButton = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import dev.medzik.android.components.Permission
import dev.medzik.android.components.icons.TopAppBarBackIcon
import dev.medzik.android.components.rememberMutable
import dev.medzik.android.components.ui.ComboBoxDropdown
import dev.medzik.librepass.android.R
import dev.medzik.librepass.android.ui.LibrePassViewModel
import dev.medzik.librepass.android.ui.components.QrCodeScanner
import dev.medzik.librepass.android.ui.components.TextInputFieldBase
import dev.medzik.librepass.android.ui.components.TopBar
import dev.medzik.librepass.android.ui.components.TopBarBackIcon
import dev.medzik.otp.OTPParameters
import dev.medzik.otp.OTPType
import dev.medzik.otp.TOTPGenerator
Expand All @@ -54,7 +54,7 @@ fun OtpConfigureScreen(
topBar = {
TopBar(
title = stringResource(R.string.ConfigureTwoFactor),
navigationIcon = { TopBarBackIcon(navController) }
navigationIcon = { TopAppBarBackIcon(navController) }
)
}
) { innerPadding ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import dev.medzik.android.components.icons.TopAppBarBackIcon
import dev.medzik.android.components.rememberMutableString
import dev.medzik.librepass.android.ui.LibrePassViewModel
import dev.medzik.librepass.android.ui.components.CipherCard
import dev.medzik.librepass.android.ui.components.TopBarBackIcon
import dev.medzik.librepass.types.cipher.CipherType
import kotlinx.serialization.Serializable

Expand Down Expand Up @@ -66,7 +66,7 @@ fun SearchScreen(
.heightIn(min = 56.dp)
)
},
navigationIcon = { TopBarBackIcon(navController) }
navigationIcon = { TopAppBarBackIcon(navController) }
)
}
) { innerPadding ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ fun VaultScreen(
)
}

// Prevent covering fields with floating action button
// Prevent covering ciphers with floating action button
item {
Spacer(
modifier = Modifier.size(72.dp)
Expand Down

0 comments on commit 5934f04

Please sign in to comment.