@@ -14,7 +14,7 @@ maven { url = uri("https://www.jitpack.io" ) }
14
14
```
15
15
Import the library
16
16
``` kotlin
17
- implementation(" com.github.rumboalla.kryptostore:core:0.1.1 " )
17
+ implementation(" com.github.rumboalla.kryptostore:core:0.1.2 " )
18
18
```
19
19
Use preferences
20
20
``` kotlin
@@ -60,7 +60,7 @@ suspend fun doSomething(context: Context) {
60
60
## Advanced Usage
61
61
Import the gson library for serialization
62
62
``` kotlin
63
- implementation(" com.github.rumboalla.kryptostore:gson:0.1.1 " )
63
+ implementation(" com.github.rumboalla.kryptostore:gson:0.1.2 " )
64
64
```
65
65
Use serialized preferences
66
66
``` kotlin
@@ -90,7 +90,7 @@ suspend fun doSomething(context: Context) {
90
90
## Encryption
91
91
Import the library for encryption
92
92
``` kotlin
93
- implementation(" com.github.rumboalla.kryptostore:keystore:0.1.1 " )
93
+ implementation(" com.github.rumboalla.kryptostore:keystore:0.1.2 " )
94
94
```
95
95
Use encrypted preferences
96
96
``` kotlin
@@ -117,6 +117,37 @@ suspend fun doSomething(context: Context) {
117
117
}
118
118
```
119
119
120
+ ## Compose
121
+ Extensions for compose. Import the library
122
+ ``` kotlin
123
+ implementation(" com.github.rumboalla.kryptostore:compose:0.1.2" )
124
+ ```
125
+ Use it
126
+ ``` kotlin
127
+ import android.content.Context
128
+ import androidx.compose.runtime.Composable
129
+ import androidx.datastore.core.DataStore
130
+ import androidx.datastore.preferences.core.Preferences
131
+ import androidx.datastore.preferences.preferencesDataStore
132
+ import com.github.rumboalla.kryptostore.preference.booleanPref
133
+
134
+ private val Context .store: DataStore <Preferences > by preferencesDataStore(name = " prefs" )
135
+
136
+ class Prefs (context : Context ) {
137
+ val boolean = booleanPref(context.store, " boolean" , true )
138
+ }
139
+
140
+ @Composable
141
+ fun Component (prefs : Prefs ) {
142
+ val state = prefs.boolean.collectAsStateWithLifecycle()
143
+ if (state.value) {
144
+ Text (" Pref is true." )
145
+ } else {
146
+ Text (" Pref is false." )
147
+ }
148
+ }
149
+ ```
150
+
120
151
## Roadmap
121
152
* More serialization options: Moshi, kotlinx.serialization.
122
153
* More encryption options.
0 commit comments