Skip to content

Commit 7ae95ac

Browse files
committed
improve bottom nav bar on home
1 parent a918b29 commit 7ae95ac

File tree

22 files changed

+168
-189
lines changed

22 files changed

+168
-189
lines changed

app/src/main/java/com/yogeshpaliyal/keypass/MyApplication.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class MyApplication : CommonMyApplication() {
1717

1818
private var timeToLaunchActivity : Long? = null
1919

20-
fun activityLaunchTriggered() {
20+
fun knownActivityLaunchTriggered() {
2121
timeToLaunchActivity = SystemClock.uptimeMillis()
2222
}
2323

24-
fun isActivityLaunchTriggered() : Boolean {
24+
fun isKnownActivityLaunchTriggered() : Boolean {
2525
val mTimeToLaunchActivity = timeToLaunchActivity ?: return false
2626
timeToLaunchActivity = null
2727
return SystemClock.uptimeMillis() - mTimeToLaunchActivity < 1000

app/src/main/java/com/yogeshpaliyal/keypass/ui/about/AboutScreen.kt

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ import androidx.compose.material3.MaterialTheme
3030
import androidx.compose.material3.Scaffold
3131
import androidx.compose.material3.Surface
3232
import androidx.compose.material3.Text
33+
import androidx.compose.material3.TopAppBarDefaults
3334
import androidx.compose.runtime.Composable
3435
import androidx.compose.ui.Alignment
3536
import androidx.compose.ui.Modifier
3637
import androidx.compose.ui.draw.clip
3738
import androidx.compose.ui.graphics.vector.rememberVectorPainter
39+
import androidx.compose.ui.input.nestedscroll.nestedScroll
3840
import androidx.compose.ui.platform.LocalContext
3941
import androidx.compose.ui.res.painterResource
4042
import androidx.compose.ui.res.stringResource
@@ -47,22 +49,20 @@ import com.yogeshpaliyal.common.utils.openLink
4749
import com.yogeshpaliyal.keypass.BuildConfig
4850
import com.yogeshpaliyal.keypass.R
4951
import com.yogeshpaliyal.keypass.ui.commonComponents.DefaultBottomAppBar
52+
import com.yogeshpaliyal.keypass.ui.commonComponents.DefaultTopAppBar
5053
import com.yogeshpaliyal.keypass.ui.commonComponents.PreferenceItem
5154
import com.yogeshpaliyal.keypass.ui.redux.actions.Action
5255
import com.yogeshpaliyal.keypass.ui.redux.actions.GoBackAction
5356
import org.reduxkotlin.compose.rememberTypedDispatcher
5457

5558
@Composable
5659
fun AboutScreen() {
57-
val dispatchAction = rememberTypedDispatcher<Action>()
58-
60+
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
5961
Scaffold(
60-
bottomBar = {
61-
// Add back button to bottom bar
62-
DefaultBottomAppBar(
63-
showBackButton = true
64-
)
65-
}
62+
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
63+
topBar = {
64+
DefaultTopAppBar(title = R.string.app_name, scrollBehavior = scrollBehavior)
65+
},
6666
) { contentPadding ->
6767
Surface(
6868
modifier = Modifier
@@ -98,9 +98,11 @@ private fun MainContent() {
9898
horizontalAlignment = Alignment.CenterHorizontally
9999
) {
100100
// App Info Card
101-
ElevatedCard(
101+
Card(
102102
modifier = Modifier.fillMaxWidth(),
103-
elevation = CardDefaults.elevatedCardElevation(defaultElevation = 2.dp),
103+
colors = CardDefaults.cardColors(
104+
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
105+
),
104106
shape = RoundedCornerShape(16.dp)
105107
) {
106108
Column(
@@ -124,13 +126,13 @@ private fun MainContent() {
124126

125127
Spacer(modifier = Modifier.height(16.dp))
126128

127-
// App Name
128-
Text(
129-
text = stringResource(id = R.string.app_name),
130-
style = MaterialTheme.typography.headlineMedium,
131-
fontWeight = FontWeight.Bold,
132-
color = MaterialTheme.colorScheme.primary
133-
)
129+
// // App Name
130+
// Text(
131+
// text = stringResource(id = R.string.app_name),
132+
// style = MaterialTheme.typography.headlineMedium,
133+
// fontWeight = FontWeight.Bold,
134+
// color = MaterialTheme.colorScheme.primary
135+
// )
134136

135137
Spacer(modifier = Modifier.height(4.dp))
136138

@@ -203,9 +205,11 @@ private fun MainContent() {
203205
textAlign = TextAlign.Start
204206
)
205207

206-
ElevatedCard(
208+
Card(
207209
modifier = Modifier.fillMaxWidth(),
208-
elevation = CardDefaults.elevatedCardElevation(defaultElevation = 2.dp),
210+
colors = CardDefaults.cardColors(
211+
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
212+
),
209213
shape = RoundedCornerShape(16.dp)
210214
) {
211215
Column(modifier = Modifier.fillMaxWidth()) {

app/src/main/java/com/yogeshpaliyal/keypass/ui/backup/KeyPassBackupDirectoryPick.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class KeyPassBackupDirectoryPick : ActivityResultContracts.OpenDocument() {
1515
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or
1616
Intent.FLAG_GRANT_READ_URI_PERMISSION
1717
)
18-
(context.applicationContext as? MyApplication)?.activityLaunchTriggered()
18+
(context.applicationContext as? MyApplication)?.knownActivityLaunchTriggered()
1919
return intent
2020
}
2121

app/src/main/java/com/yogeshpaliyal/keypass/ui/backupsImport/BackupImporter.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,13 @@ fun BackupImporter(state: BackupImporterState, mViewModel: DashboardViewModel =
197197
@Composable
198198
private fun ImportOptionCard(option: ImportOption, onClick: () -> Unit) {
199199
val desc = option.importer.getImporterDesc()
200-
ElevatedCard(
200+
Card(
201201
modifier = Modifier
202202
.fillMaxWidth()
203203
.padding(vertical = 8.dp),
204-
elevation = CardDefaults.elevatedCardElevation(defaultElevation = 1.dp),
204+
colors = CardDefaults.cardColors(
205+
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
206+
),
205207
onClick = onClick,
206208
shape = RoundedCornerShape(12.dp)
207209
) {

app/src/main/java/com/yogeshpaliyal/keypass/ui/changeDefaultPasswordLength/ChangeDefaultPasswordLengthScreen.kt

Lines changed: 29 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,24 @@
11
package com.yogeshpaliyal.keypass.ui.changeDefaultPasswordLength
22

3-
import androidx.compose.animation.AnimatedVisibility
4-
import androidx.compose.animation.fadeIn
5-
import androidx.compose.animation.fadeOut
63
import androidx.compose.foundation.layout.Arrangement
7-
import androidx.compose.foundation.layout.Box
84
import androidx.compose.foundation.layout.Column
95
import androidx.compose.foundation.layout.Row
106
import androidx.compose.foundation.layout.Spacer
117
import androidx.compose.foundation.layout.fillMaxSize
128
import androidx.compose.foundation.layout.fillMaxWidth
139
import androidx.compose.foundation.layout.height
1410
import androidx.compose.foundation.layout.padding
15-
import androidx.compose.foundation.layout.size
1611
import androidx.compose.material.icons.Icons
17-
import androidx.compose.material.icons.rounded.ArrowBackIosNew
1812
import androidx.compose.material.icons.rounded.Done
19-
import androidx.compose.material.icons.rounded.Info
20-
import androidx.compose.material3.BottomAppBar
2113
import androidx.compose.material3.Card
2214
import androidx.compose.material3.CardDefaults
23-
import androidx.compose.material3.ElevatedCard
2415
import androidx.compose.material3.FloatingActionButton
2516
import androidx.compose.material3.Icon
26-
import androidx.compose.material3.IconButton
2717
import androidx.compose.material3.LinearProgressIndicator
2818
import androidx.compose.material3.MaterialTheme
2919
import androidx.compose.material3.Scaffold
3020
import androidx.compose.material3.Surface
3121
import androidx.compose.material3.Text
32-
import androidx.compose.material3.TopAppBar
33-
import androidx.compose.material3.TopAppBarDefaults
3422
import androidx.compose.runtime.Composable
3523
import androidx.compose.runtime.collectAsState
3624
import androidx.compose.runtime.derivedStateOf
@@ -50,6 +38,7 @@ import androidx.compose.ui.tooling.preview.Preview
5038
import androidx.compose.ui.unit.dp
5139
import androidx.lifecycle.viewmodel.compose.viewModel
5240
import com.yogeshpaliyal.keypass.R
41+
import com.yogeshpaliyal.keypass.ui.commonComponents.DefaultTopAppBar
5342
import com.yogeshpaliyal.keypass.ui.generate.ui.components.PasswordLengthInput
5443
import com.yogeshpaliyal.keypass.ui.redux.actions.Action
5544
import com.yogeshpaliyal.keypass.ui.redux.actions.GoBackAction
@@ -66,7 +55,13 @@ fun ChangeDefaultPasswordLengthScreen(
6655
val state by viewModel.viewState.collectAsState()
6756

6857
Scaffold(
69-
bottomBar = { BottomBar(dispatchAction, viewModel) }
58+
topBar = {
59+
DefaultTopAppBar(
60+
title = R.string.choose_default_password_length,
61+
subtitle = R.string.choose_default_password_length_desc
62+
)
63+
},
64+
floatingActionButton = { FloatingActionButton(dispatchAction, viewModel) }
7065
) { contentPadding ->
7166
Surface(
7267
modifier = Modifier
@@ -97,16 +92,11 @@ private fun ChangeDefaultPasswordLengthContent(
9792
) {
9893
// Password length input with improved UI
9994

100-
Text(
101-
text = stringResource(R.string.choose_default_password_length),
102-
style = MaterialTheme.typography.headlineSmall,
103-
fontWeight = FontWeight.SemiBold,
104-
textAlign = TextAlign.Start
105-
)
106-
107-
ElevatedCard(
95+
Card(
10896
modifier = Modifier.fillMaxWidth(),
109-
elevation = CardDefaults.elevatedCardElevation(defaultElevation = 1.dp)
97+
colors = CardDefaults.cardColors(
98+
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
99+
)
110100
) {
111101
Column(
112102
modifier = Modifier.padding(16.dp),
@@ -130,38 +120,6 @@ private fun ChangeDefaultPasswordLengthContent(
130120
}
131121

132122
Spacer(modifier = Modifier.height(8.dp))
133-
134-
// Information card
135-
InfoCard()
136-
}
137-
}
138-
139-
@Composable
140-
private fun InfoCard() {
141-
Card(
142-
modifier = Modifier.fillMaxWidth(),
143-
colors = CardDefaults.cardColors(
144-
containerColor = MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.7f)
145-
)
146-
) {
147-
Row(
148-
modifier = Modifier.padding(16.dp),
149-
verticalAlignment = Alignment.CenterVertically
150-
) {
151-
Icon(
152-
imageVector = Icons.Rounded.Info,
153-
contentDescription = null,
154-
tint = MaterialTheme.colorScheme.onSecondaryContainer,
155-
modifier = Modifier.size(24.dp)
156-
)
157-
Text(
158-
text = "This length will be used as default when generating new passwords. " +
159-
"Longer passwords provide better security.",
160-
style = MaterialTheme.typography.bodyMedium,
161-
color = MaterialTheme.colorScheme.onSecondaryContainer,
162-
modifier = Modifier.padding(start = 12.dp)
163-
)
164-
}
165123
}
166124
}
167125

@@ -231,44 +189,29 @@ private fun PasswordStrengthIndicator(strength: PasswordStrength) {
231189
}
232190

233191
@Composable
234-
private fun BottomBar(
192+
private fun FloatingActionButton(
235193
dispatchAction: TypedDispatcher<Action>,
236194
viewModel: ChangeDefaultPasswordLengthViewModel
237195
) {
238196
val context = LocalContext.current
239-
BottomAppBar(
240-
actions = {
241-
// Add back button on the left side
242-
IconButton(
243-
onClick = { dispatchAction(GoBackAction) }
244-
) {
245-
Icon(
246-
painter = rememberVectorPainter(image = Icons.Rounded.ArrowBackIosNew),
247-
contentDescription = "Cancel",
248-
tint = MaterialTheme.colorScheme.onSurfaceVariant
249-
)
197+
198+
FloatingActionButton(
199+
modifier = Modifier.testTag("save"),
200+
onClick = {
201+
// Save new password length
202+
viewModel.updatePasswordLength(context) {
203+
// Close screen
204+
dispatchAction(GoBackAction)
250205
}
251206
},
252-
floatingActionButton = {
253-
FloatingActionButton(
254-
modifier = Modifier.testTag("save"),
255-
onClick = {
256-
// Save new password length
257-
viewModel.updatePasswordLength(context) {
258-
// Close screen
259-
dispatchAction(GoBackAction)
260-
}
261-
},
262-
containerColor = MaterialTheme.colorScheme.primaryContainer
263-
) {
264-
Icon(
265-
painter = rememberVectorPainter(image = Icons.Rounded.Done),
266-
contentDescription = "Save Changes",
267-
tint = MaterialTheme.colorScheme.onPrimaryContainer
268-
)
269-
}
270-
}
271-
)
207+
containerColor = MaterialTheme.colorScheme.primaryContainer
208+
) {
209+
Icon(
210+
painter = rememberVectorPainter(image = Icons.Rounded.Done),
211+
contentDescription = "Save Changes",
212+
tint = MaterialTheme.colorScheme.onPrimaryContainer
213+
)
214+
}
272215
}
273216

274217
@Preview(name = "ChangeDefaultPasswordLength", showBackground = true, showSystemUi = true)

app/src/main/java/com/yogeshpaliyal/keypass/ui/changePassword/ChangePassword.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fun ChangePassword(state: ChangeAppPasswordState) {
149149
Card(
150150
modifier = Modifier.fillMaxWidth(),
151151
colors = CardDefaults.cardColors(
152-
containerColor = MaterialTheme.colorScheme.secondaryContainer
152+
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
153153
)
154154
) {
155155
Column(
@@ -176,7 +176,10 @@ fun ChangePassword(state: ChangeAppPasswordState) {
176176

177177
// Password input fields in a card
178178
Card(
179-
modifier = Modifier.fillMaxWidth()
179+
modifier = Modifier.fillMaxWidth(),
180+
colors = CardDefaults.cardColors(
181+
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
182+
)
180183
) {
181184
Column(
182185
modifier = Modifier

app/src/main/java/com/yogeshpaliyal/keypass/ui/commonComponents/DefaultTopAppBar.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import androidx.compose.material3.IconButton
99
import androidx.compose.material3.LargeFlexibleTopAppBar
1010
import androidx.compose.material3.MaterialTheme
1111
import androidx.compose.material3.Text
12+
import androidx.compose.material3.TopAppBarDefaults
1213
import androidx.compose.material3.TopAppBarScrollBehavior
1314
import androidx.compose.runtime.Composable
1415
import androidx.compose.ui.Modifier
16+
import androidx.compose.ui.graphics.Color
1517
import androidx.compose.ui.graphics.vector.rememberVectorPainter
1618
import androidx.compose.ui.res.stringResource
1719
import com.yogeshpaliyal.keypass.ui.redux.actions.Action
@@ -36,12 +38,11 @@ fun DefaultTopAppBar(
3638
text = stringResource(id = subtitle),
3739
)
3840
}
39-
}, title = {
41+
}, colors = TopAppBarDefaults.topAppBarColors(containerColor = Color.Unspecified, scrolledContainerColor = MaterialTheme.colorScheme.surface),
42+
title = {
4043
Text(
4144
text = stringResource(id = title),
4245
)
43-
44-
4546
}, actions = {
4647
extraAction?.invoke(this)
4748
}, navigationIcon = {

app/src/main/java/com/yogeshpaliyal/keypass/ui/detail/AccountDetailPage.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.yogeshpaliyal.common.constants.ScannerType
3333
import com.yogeshpaliyal.common.utils.TOTPHelper
3434
import com.yogeshpaliyal.keypass.R
3535
import com.yogeshpaliyal.keypass.ui.detail.components.BottomBar
36+
import com.yogeshpaliyal.keypass.ui.detail.components.FABAddAccount
3637
import com.yogeshpaliyal.keypass.ui.detail.components.Fields
3738
import com.yogeshpaliyal.keypass.ui.redux.actions.CopyToClipboard
3839
import com.yogeshpaliyal.keypass.ui.redux.actions.GoBackAction
@@ -104,7 +105,7 @@ fun AccountDetailPage(
104105
}
105106
}
106107
Scaffold(
107-
bottomBar = {
108+
topBar = {
108109
BottomBar(
109110
accountModel,
110111
backPressed = goBack,
@@ -120,7 +121,10 @@ fun AccountDetailPage(
120121
openPasswordConfiguration = {
121122
dispatchAction(NavigationAction(PasswordGeneratorState()))
122123
}
123-
) {
124+
)
125+
},
126+
floatingActionButton = {
127+
FABAddAccount{
124128
viewModel.insertOrUpdate(accountModel, goBack)
125129
}
126130
}

app/src/main/java/com/yogeshpaliyal/keypass/ui/detail/QRScanner.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class QRScanner : ActivityResultContract<Int, QRScannerResult>() {
2020
} else {
2121
null
2222
}
23-
(context.applicationContext as? MyApplication)?.activityLaunchTriggered()
23+
(context.applicationContext as? MyApplication)?.knownActivityLaunchTriggered()
2424
return intentIntegration?.setPrompt("")?.createScanIntent() ?: Intent()
2525
}
2626

0 commit comments

Comments
 (0)