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

Commit

Permalink
Remember some values in cipher view/add/edit screens
Browse files Browse the repository at this point in the history
Not needed to re-setup with re-composable and fixes back animation
  • Loading branch information
M3DZIK committed Mar 18, 2024
1 parent 0ed6bcd commit a722a6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -47,10 +48,10 @@ fun CipherAddScreen(
) {
val context = LocalContext.current

val cipherTypeArg = navController.getString(Argument.CipherType) ?: return
val cipherType = CipherType.from(cipherTypeArg.toInt())
val cipherTypeArg = remember { navController.getString(Argument.CipherType) } ?: return
val cipherType = remember { CipherType.from(cipherTypeArg.toInt()) }

val credentials = viewModel.credentialRepository.get() ?: return
val credentials = remember { viewModel.credentialRepository.get() } ?: return

var cipher by rememberMutable(
Cipher(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -47,8 +48,8 @@ fun CipherEditScreen(
) {
val context = LocalContext.current

val cipherId = navController.getString(Argument.CipherId) ?: return
val oldCipher = viewModel.vault.find(cipherId) ?: return
val cipherId = remember { navController.getString(Argument.CipherId) } ?: return
val oldCipher = remember { viewModel.vault.find(cipherId) } ?: return
var cipher by rememberMutable(oldCipher)

var loading by rememberMutableBoolean()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ fun CipherViewScreen(
navController: NavController,
viewModel: LibrePassViewModel = hiltViewModel()
) {
val cipherId = navController.getString(Argument.CipherId) ?: return
val cipher = viewModel.vault.find(cipherId) ?: return
val cipherId = remember { navController.getString(Argument.CipherId) } ?: return
val cipher = remember { viewModel.vault.find(cipherId) } ?: return

var totpCode by rememberMutable("")
var totpElapsed by rememberMutable(0)
Expand Down

0 comments on commit a722a6b

Please sign in to comment.