@@ -178,14 +178,14 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
178178 }, smallplugPartnerProps = SmallplugPartnerProps (headerColor = " #2F363F" , backIconColor = " ffffff" ))
179179 }
180180
181- @ReactMethod
182- fun launchSmallplugWithBranding (targetEndpoint : String , params : String , headerColor : String? , headerOpacity : Double? , backIconColor : String? , backIconOpacity : Double? , promise : Promise
183- ) {
181+ @ReactMethod
182+ fun launchSmallplugWithBranding (targetEndpoint : String , params : String , headerColor : String? , headerOpacity : Double? , backIconColor : String? , backIconOpacity : Double? , promise : Promise
183+ ) {
184184 val readableMap = Arguments .createMap().apply {
185- putString(" headerColor" , headerColor)
186- putDouble(" headerOpacity" , headerOpacity ? : 1.0 )
187- putString(" backIconColor" , backIconColor)
188- putDouble(" backIconOpacity" , backIconOpacity ? : 1.0 )
185+ headerColor?. let { putString(" headerColor" , it) }
186+ headerOpacity?. let { putDouble(" headerOpacity" , it) }
187+ backIconColor?. let { putString(" backIconColor" , it) }
188+ backIconOpacity?. let { putDouble(" backIconOpacity" , it) }
189189 }
190190
191191 fun getColorValue (value : Any? , defaultValue : String ): String {
@@ -203,7 +203,7 @@ fun launchSmallplugWithBranding(targetEndpoint: String, params: String, headerCo
203203 var partnerProps: SmallplugPartnerProps ? = SmallplugPartnerProps (headerColor = " #2F363F" , backIconColor = " ffffff" )
204204
205205 try {
206- partnerProps = readableMap? .toHashMap()? .let { map ->
206+ partnerProps = readableMap.toHashMap().let { map ->
207207 val hc = getColorValue(map[" headerColor" ], " #2F363F" )
208208 val ho = map[" headerOpacity" ]?.let { if (it is Double ) it else 1.0 } ? : 1.0
209209 val bc = getColorValue(map[" backIconColor" ], " #ffffff" )
@@ -213,19 +213,16 @@ fun launchSmallplugWithBranding(targetEndpoint: String, params: String, headerCo
213213 } catch (e: Throwable ) {
214214 }
215215
216-
217216 SmallcaseGatewaySdk .launchSmallPlug(currentActivity!! , SmallplugData (targetEndpoint, params), object : SmallPlugResponseListener {
218217 override fun onFailure (errorCode : Int , errorMessage : String ) {
219218 val err = createErrorJSON(errorCode, errorMessage, null )
220-
221219 promise.reject(" error" , err)
222220 }
223221
224222 override fun onSuccess (smallPlugResult : SmallPlugResult ) {
225223 val res = resultToWritableMap(smallPlugResult)
226224 promise.resolve(res)
227225 }
228-
229226 }, partnerProps)
230227 }
231228
0 commit comments