Skip to content

Commit 27e7719

Browse files
authored
feat: persistent map serialize (#498)
* feat: persistent map serialize * feat: update changelog * feat: concise map serializer
1 parent 3190a0d commit 27e7719

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Release Notes
2+
## 10.3.
3+
4+
* Fixed extraPartnerParams serialization issues
25

36
## 10.3.6
47

lib/src/main/java/com/smileidentity/compose/nav/NavRoutesParams.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ data class SelfieCaptureParams(
6767
val allowAgentMode: Boolean = false,
6868
val showAttribution: Boolean = true,
6969
val showInstructions: Boolean = true,
70+
@Serializable(with = PersistentMapSerializer::class)
7071
val extraPartnerParams: ImmutableMap<String, String> = persistentMapOf(),
7172
val isEnroll: Boolean = true,
7273
val skipApiSubmission: Boolean = false,
@@ -99,6 +100,7 @@ data class DocumentCaptureParams(
99100
val allowAgentMode: Boolean = false,
100101
val showAttribution: Boolean = true,
101102
val showInstructions: Boolean = true,
103+
@Serializable(with = PersistentMapSerializer::class)
102104
val extraPartnerParams: ImmutableMap<String, String> = persistentMapOf(),
103105
val allowGallerySelection: Boolean = false,
104106
val showSkipButton: Boolean = false,
@@ -148,6 +150,7 @@ data class BiometricKYCParams(
148150
val showAttribution: Boolean = true,
149151
val showInstructions: Boolean = true,
150152
val skipApiSubmission: Boolean = false,
153+
@Serializable(with = PersistentMapSerializer::class)
151154
val extraPartnerParams: ImmutableMap<String, String> = persistentMapOf(),
152155
) : Parcelable
153156

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.smileidentity.compose.nav
2+
3+
import kotlinx.collections.immutable.ImmutableMap
4+
import kotlinx.collections.immutable.toPersistentMap
5+
import kotlinx.serialization.ExperimentalSerializationApi
6+
import kotlinx.serialization.KSerializer
7+
import kotlinx.serialization.builtins.MapSerializer
8+
import kotlinx.serialization.descriptors.SerialDescriptor
9+
import kotlinx.serialization.encoding.Decoder
10+
import kotlinx.serialization.encoding.Encoder
11+
12+
@OptIn(ExperimentalSerializationApi::class)
13+
class PersistentMapSerializer<K, V>(
14+
keySerializer: KSerializer<K>,
15+
valueSerializer: KSerializer<V>,
16+
) : KSerializer<ImmutableMap<K, V>> {
17+
private val mapSerializer = MapSerializer(keySerializer, valueSerializer)
18+
19+
override val descriptor = SerialDescriptor(
20+
"kotlinx.serialization.immutable.persistentMap",
21+
mapSerializer.descriptor,
22+
)
23+
24+
override fun serialize(encoder: Encoder, value: ImmutableMap<K, V>) =
25+
mapSerializer.serialize(encoder, value)
26+
27+
override fun deserialize(decoder: Decoder): ImmutableMap<K, V> =
28+
mapSerializer.deserialize(decoder).toPersistentMap()
29+
}

0 commit comments

Comments
 (0)