@primer-io/react-native 2.23.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +2 -1
- package/android/src/main/java/com/primerioreactnative/components/manager/klarna/PrimerRNHeadlessUniversalCheckoutKlarnaComponent.kt +3 -5
- package/android/src/main/java/com/primerioreactnative/datamodels/PrimerSettingsRN.kt +62 -0
- package/android/src/main/java/com/primerioreactnative/extensions/PrimerUIOptionsRN.kt +1 -2
- package/ios/Sources/DataModels/PrimerThemeRN.swift +42 -9
- package/ios/Sources/version.swift +1 -1
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -31,6 +31,7 @@ def getExtOrIntegerDefault(name) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
android {
|
|
34
|
+
group 'io.primer'
|
|
34
35
|
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
35
36
|
buildToolsVersion getExtOrDefault('buildToolsVersion')
|
|
36
37
|
defaultConfig {
|
|
@@ -147,7 +148,7 @@ dependencies {
|
|
|
147
148
|
api 'com.facebook.react:react-native:+'
|
|
148
149
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
149
150
|
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
|
|
150
|
-
implementation 'io.primer:android:2.27.
|
|
151
|
+
implementation 'io.primer:android:2.27.3'
|
|
151
152
|
|
|
152
153
|
testImplementation 'io.mockk:mockk:1.13.10'
|
|
153
154
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
|
|
@@ -259,12 +259,12 @@ class PrimerRNHeadlessUniversalCheckoutKlarnaComponent(
|
|
|
259
259
|
val returnIntentUrl = readableMap.getString("returnIntentUrl")
|
|
260
260
|
val paymentCategory = readableMap.getMap("paymentCategory") as ReadableMap
|
|
261
261
|
val json = Json { ignoreUnknownKeys = true }
|
|
262
|
-
val
|
|
262
|
+
val klarnaPaymentCategoryRN =
|
|
263
263
|
json.decodeFromString<KlarnaPaymentCategoryRN>(
|
|
264
264
|
Json.encodeToString(paymentCategory.toHashMap() as Map<String, String>)
|
|
265
265
|
)
|
|
266
266
|
|
|
267
|
-
val activity =
|
|
267
|
+
val activity = currentActivity
|
|
268
268
|
|
|
269
269
|
if (activity == null) {
|
|
270
270
|
val exception = ErrorTypeRN.NativeBridgeFailed errorTo MISSING_ACTIVITY_ERROR
|
|
@@ -277,7 +277,7 @@ class PrimerRNHeadlessUniversalCheckoutKlarnaComponent(
|
|
|
277
277
|
KlarnaPaymentCollectableData.PaymentOptions(
|
|
278
278
|
context = activity,
|
|
279
279
|
returnIntentUrl = requireNotNull(returnIntentUrl),
|
|
280
|
-
paymentCategory =
|
|
280
|
+
paymentCategory = klarnaPaymentCategoryRN.toKlarnaPaymentCategory()
|
|
281
281
|
)
|
|
282
282
|
)
|
|
283
283
|
promise.resolve(null)
|
|
@@ -327,8 +327,6 @@ class PrimerRNHeadlessUniversalCheckoutKlarnaComponent(
|
|
|
327
327
|
Could not retrieve running activity from context.
|
|
328
328
|
"""
|
|
329
329
|
|
|
330
|
-
val TAG = PrimerRNHeadlessUniversalCheckoutKlarnaComponent::class.simpleName
|
|
331
|
-
|
|
332
330
|
val json by lazy { Json { encodeDefaults = true } }
|
|
333
331
|
}
|
|
334
332
|
}
|
|
@@ -7,6 +7,7 @@ import com.primerioreactnative.extensions.toPrimerUIOptions
|
|
|
7
7
|
import io.primer.android.data.settings.GooglePayButtonStyle
|
|
8
8
|
import io.primer.android.data.settings.PrimerPaymentHandling
|
|
9
9
|
import io.primer.android.data.settings.PrimerSettings
|
|
10
|
+
import io.primer.android.ui.settings.PrimerTheme
|
|
10
11
|
import kotlinx.serialization.SerialName
|
|
11
12
|
import kotlinx.serialization.Serializable
|
|
12
13
|
|
|
@@ -44,8 +45,69 @@ data class PrimerUIOptionsRN(
|
|
|
44
45
|
var isInitScreenEnabled: Boolean = true,
|
|
45
46
|
var isSuccessScreenEnabled: Boolean = true,
|
|
46
47
|
var isErrorScreenEnabled: Boolean = true,
|
|
48
|
+
var theme: PrimerThemeRN = PrimerThemeRN()
|
|
47
49
|
)
|
|
48
50
|
|
|
51
|
+
@Serializable
|
|
52
|
+
data class PrimerThemeRN(
|
|
53
|
+
val colors: ColorThemeRN? = null,
|
|
54
|
+
val darkModeColors: ColorThemeRN? = null
|
|
55
|
+
) {
|
|
56
|
+
fun toPrimerTheme(): PrimerTheme {
|
|
57
|
+
val isDarkMode = false
|
|
58
|
+
|
|
59
|
+
return PrimerTheme.buildWithDynamicValues(
|
|
60
|
+
isDarkMode = isDarkMode,
|
|
61
|
+
mainColor = when {
|
|
62
|
+
isDarkMode -> darkModeColors?.mainColor?.toHexStrColor()
|
|
63
|
+
else -> colors?.mainColor?.toHexStrColor()
|
|
64
|
+
},
|
|
65
|
+
backgroundColor = when {
|
|
66
|
+
isDarkMode -> darkModeColors?.background?.toHexStrColor()
|
|
67
|
+
else -> colors?.background?.toHexStrColor()
|
|
68
|
+
},
|
|
69
|
+
disabledColor = when {
|
|
70
|
+
isDarkMode -> darkModeColors?.disabled?.toHexStrColor()
|
|
71
|
+
else -> colors?.disabled?.toHexStrColor()
|
|
72
|
+
},
|
|
73
|
+
textColor = when {
|
|
74
|
+
isDarkMode -> darkModeColors?.text?.toHexStrColor()
|
|
75
|
+
else -> colors?.text?.toHexStrColor()
|
|
76
|
+
},
|
|
77
|
+
bordersColor = when {
|
|
78
|
+
isDarkMode -> darkModeColors?.borders?.toHexStrColor()
|
|
79
|
+
else -> colors?.borders?.toHexStrColor()
|
|
80
|
+
},
|
|
81
|
+
errorColor = when {
|
|
82
|
+
isDarkMode -> darkModeColors?.error?.toHexStrColor()
|
|
83
|
+
else -> colors?.error?.toHexStrColor()
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@Serializable
|
|
90
|
+
data class ColorThemeRN(
|
|
91
|
+
val mainColor: ColorRN? = null,
|
|
92
|
+
val contrastingColor: ColorRN? = null,
|
|
93
|
+
val background: ColorRN? = null,
|
|
94
|
+
val text: ColorRN? = null,
|
|
95
|
+
val contrastingText: ColorRN? = null,
|
|
96
|
+
val borders: ColorRN? = null, // or main color
|
|
97
|
+
val disabled: ColorRN? = null,
|
|
98
|
+
val error: ColorRN? = null,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
@Serializable
|
|
102
|
+
data class ColorRN(
|
|
103
|
+
val alpha: Int = 0,
|
|
104
|
+
val red: Int = 0,
|
|
105
|
+
val green: Int = 0,
|
|
106
|
+
val blue: Int = 0
|
|
107
|
+
) {
|
|
108
|
+
fun toHexStrColor() = String.format("#%02X%02X%02X%02X", alpha, red, green, blue)
|
|
109
|
+
}
|
|
110
|
+
|
|
49
111
|
@Serializable
|
|
50
112
|
data class PrimerDebugOptionsRN(val is3DSSanityCheckEnabled: Boolean = true)
|
|
51
113
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.primerioreactnative.extensions
|
|
2
2
|
|
|
3
3
|
import com.primerioreactnative.datamodels.PrimerUIOptionsRN
|
|
4
|
-
import io.primer.android.ui.settings.PrimerTheme
|
|
5
4
|
import io.primer.android.ui.settings.PrimerUIOptions
|
|
6
5
|
|
|
7
6
|
internal fun PrimerUIOptionsRN.toPrimerUIOptions() =
|
|
@@ -9,5 +8,5 @@ internal fun PrimerUIOptionsRN.toPrimerUIOptions() =
|
|
|
9
8
|
isInitScreenEnabled,
|
|
10
9
|
isSuccessScreenEnabled,
|
|
11
10
|
isErrorScreenEnabled,
|
|
12
|
-
|
|
11
|
+
theme.toPrimerTheme()
|
|
13
12
|
)
|
|
@@ -7,19 +7,52 @@ struct PrimerThemeRN: Decodable {
|
|
|
7
7
|
|
|
8
8
|
extension PrimerThemeRN {
|
|
9
9
|
func asPrimerTheme() -> PrimerTheme {
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
let isDarkMode = UITraitCollection.current.userInterfaceStyle == .dark
|
|
12
|
+
|
|
13
|
+
let _colors = isDarkMode ? darkModeColors : colors
|
|
14
|
+
|
|
15
|
+
guard let colors = _colors else {
|
|
16
|
+
return PrimerTheme()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let data = PrimerThemeData()
|
|
20
|
+
data.colors = PrimerThemeData.ColorSwatch()
|
|
21
|
+
|
|
22
|
+
if let mainColor = colors.text?.uiColor ?? colors.mainColor?.uiColor {
|
|
23
|
+
data.colors.primary = mainColor
|
|
24
|
+
data.colors.dark = mainColor
|
|
25
|
+
data.colors.gray = mainColor
|
|
26
|
+
}
|
|
27
|
+
if let disabledColor = colors.disabled?.uiColor {
|
|
28
|
+
data.colors.lightGray = disabledColor
|
|
29
|
+
data.buttons.main.disabledColor = disabledColor
|
|
30
|
+
}
|
|
31
|
+
if let errorColor = colors.error?.uiColor {
|
|
32
|
+
data.colors.error = errorColor
|
|
33
|
+
}
|
|
34
|
+
if let borderColor = colors.borders?.uiColor {
|
|
35
|
+
data.buttons.main.border.defaultColor = borderColor
|
|
36
|
+
data.input.border.defaultColor = borderColor
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if let backgroundColor = colors.background?.uiColor {
|
|
40
|
+
data.view.backgroundColor = backgroundColor
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return PrimerTheme(with: data)
|
|
11
44
|
}
|
|
12
45
|
}
|
|
13
46
|
|
|
14
47
|
struct ColorThemeRN: Decodable {
|
|
15
|
-
let mainColor: ColorRN?
|
|
16
|
-
let contrastingColor: ColorRN?
|
|
17
|
-
let background: ColorRN?
|
|
18
|
-
let text: ColorRN?
|
|
19
|
-
let contrastingText: ColorRN?
|
|
20
|
-
let borders: ColorRN?
|
|
21
|
-
let disabled: ColorRN?
|
|
22
|
-
let error: ColorRN?
|
|
48
|
+
let mainColor: ColorRN? // primary
|
|
49
|
+
let contrastingColor: ColorRN? // ???
|
|
50
|
+
let background: ColorRN? // light
|
|
51
|
+
let text: ColorRN? // primary
|
|
52
|
+
let contrastingText: ColorRN? // ??
|
|
53
|
+
let borders: ColorRN? // ??
|
|
54
|
+
let disabled: ColorRN? // lightGray
|
|
55
|
+
let error: ColorRN? // error
|
|
23
56
|
}
|
|
24
57
|
|
|
25
58
|
extension ColorThemeRN {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// swiftlint:disable:next identifier_name
|
|
2
|
-
public let PrimerReactNativeSDKVersion = "2.
|
|
2
|
+
public let PrimerReactNativeSDKVersion = "2.24.0"
|