Skip to content

Commit

Permalink
feat: update example project
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderEggers committed Apr 9, 2024
1 parent 1e333c4 commit 34087b3
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.github.alexandereggers.ksecurestorage.example

import io.github.alexandereggers.ksecurestorage.KSecureStorage
import io.github.alexandereggers.ksecurestorage.getBoolean
import io.github.alexandereggers.ksecurestorage.hasItem
import io.github.alexandereggers.ksecurestorage.setItem

const val TEST_STORAGE_KEY = "hasDisplayedBefore"

Expand All @@ -10,13 +12,13 @@ class Greeting {
private val kSecureStorage = KSecureStorage()

fun greet(): String {
val hasDisplayedBefore = kSecureStorage.hasItem(TEST_STORAGE_KEY)
val hasDisplayedBefore = kSecureStorage.getBoolean(TEST_STORAGE_KEY) ?: false

return if (hasDisplayedBefore) {
kSecureStorage.removeItem(TEST_STORAGE_KEY)
"Welcome back, ${platform.name}!"
} else {
kSecureStorage.setItem(TEST_STORAGE_KEY, "${true}")
kSecureStorage.setItem(TEST_STORAGE_KEY, true)
"Hello, ${platform.name}!"
}
}
Expand Down

0 comments on commit 34087b3

Please sign in to comment.