-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from uncrack-vault/persist_data
Persist username in Vault Screen & added animation in SearchBar
- Loading branch information
Showing
4 changed files
with
127 additions
and
6 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
app/src/main/java/com/aritradas/uncrack/components/TypeWritingText.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,63 @@ | ||
package com.aritradas.uncrack.components | ||
|
||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableIntStateOf | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import com.aritradas.uncrack.ui.theme.OnSurfaceVariantLight | ||
import com.aritradas.uncrack.ui.theme.normal16 | ||
import kotlinx.coroutines.delay | ||
import kotlin.streams.toList | ||
|
||
@Composable | ||
fun TypewriterText( | ||
texts: List<String>, | ||
modifier: Modifier = Modifier, | ||
) { | ||
var textIndex by remember { | ||
mutableIntStateOf(0) | ||
} | ||
var textToDisplay by remember { | ||
mutableStateOf("") | ||
} | ||
val textCharsList: List<List<String>> = remember { | ||
texts.map { | ||
it.splitToCodePoints() | ||
} | ||
} | ||
|
||
LaunchedEffect(key1 = texts) { | ||
while (textIndex < textCharsList.size) { | ||
textCharsList[textIndex].forEachIndexed { charIndex, _ -> | ||
textToDisplay = textCharsList[textIndex] | ||
.take( | ||
n = charIndex + 1 | ||
).joinToString( | ||
separator = "" | ||
) | ||
delay(160) | ||
} | ||
textIndex = (textIndex + 1) % texts.size | ||
delay(1000) | ||
} | ||
} | ||
|
||
Text( | ||
modifier = modifier, | ||
text = textToDisplay, | ||
style = normal16.copy(OnSurfaceVariantLight), | ||
) | ||
} | ||
|
||
fun String.splitToCodePoints(): List<String> { | ||
return codePoints() | ||
.toList() | ||
.map { | ||
String(Character.toChars(it)) | ||
} | ||
} |
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
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