-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Us1762585 - iOS Refactor Native components (#81)
* US1762570: create view manager to native AccessCheckoutEditText component; override onTextChange to support the react native onChangeText event; implement component in react native * US1762550: update card details field to use new component; update RN module to use reference to AccessCheckoutEditText and not the text value * US1762550: move AccessCheckoutEditTextManager to correct file path; update local android sdk files to most up-to-date version of master; update AccessCheckoutReactPackageTest * US1782181: add unit tests for AccessCheckoutEditTextManagerTest; add mockito to build.gradle for unit tests * US1762551: Expose AccessCheckoutUITextField to be able to use native components via the ios Bridge Simplify ReactNativeViewLocator and implement/expose specific POC methods to avoid disruptions with previous implementation Add POC toggle to demo app to be able to switch implementations Expose new POC validation and sessionGeneration methods to avoid diruptions with previous implementations * US1762551: Point client to npe environment * US1762585: Refactor ios Bridge and demo application Avoids having to handle inputs in states Uses native components Only a input field id is needed in order to configure validation and session generation for a field Integrate the latest AccessCheckoutUITextField changes Updates and renames cvcValue to cvcId Updates and renames panValue to panId Updates and renames expiryDateValue to expiryDateId * US1762585: Rebuild lib and clean up files * US1762585: Minor cleanup * US1762585: Rebuild lib files Rename AccessCheckoutEditText to AccessCheckoutInputText as EditText was specific to Android Minor renaming of fields like panUITextField to panACUITextField to improve readability and make it known that we are dealing with AccessCheckoutUITextField in the iOS bridge * US1762585: Rename AccessCheckoutEditText to AccessCheckoutInputText in Android bridge * US1762585: Rename AccessCheckoutInputText to AccessCheckoutTextInput Rebuild lib files * US1762585: Update bitrise-step to use xcode-test v5 and update e2e tests (#82) * US1762585: Update bitrise-step to use xcode-test v5 * US1762585: Use Optionals to mantain compatibility in both Xcode 13 and Xcode 15 * US1762585: Update e2e tests * US1762585: Improve matcher based on platform using type * US1762585: Remove TextInputPO as it is no longer used --------- Co-authored-by: e5661323 <jason.dzelamensah@fisglobal.com>
- Loading branch information
1 parent
f2efc30
commit 9ea989b
Showing
83 changed files
with
999 additions
and
661 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...c/main/java/com/worldpay/access/checkout/reactnative/ui/AccessCheckoutTextInputManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.worldpay.access.checkout.reactnative.ui | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
import com.facebook.react.uimanager.ViewProps | ||
import com.facebook.react.uimanager.annotations.ReactProp | ||
import com.worldpay.access.checkout.ui.AccessCheckoutEditText | ||
|
||
class AccessCheckoutTextInputManager(private val callerContext: ReactApplicationContext) : | ||
SimpleViewManager<AccessCheckoutEditText>() { | ||
|
||
override fun getName() = REACT_CLASS | ||
|
||
companion object { | ||
const val REACT_CLASS = "AccessCheckoutTextInput" | ||
} | ||
|
||
override fun createViewInstance(context: ThemedReactContext) = AccessCheckoutEditText(context) | ||
|
||
/** | ||
* Properties | ||
*/ | ||
@ReactProp(name = ViewProps.COLOR) | ||
fun setRTCTextColor(accessCheckoutEditText: AccessCheckoutEditText, color: Int) { | ||
accessCheckoutEditText.setTextColor(color) | ||
} | ||
|
||
@ReactProp(name = "placeholder") | ||
fun setRTCPlaceholder(accessCheckoutEditText: AccessCheckoutEditText, placeholder: String) { | ||
accessCheckoutEditText.setHint(placeholder) | ||
} | ||
|
||
@ReactProp(name = "editable") | ||
fun setRTCEditable(accessCheckoutEditText: AccessCheckoutEditText, editable: Boolean) { | ||
accessCheckoutEditText.isEnabled = editable | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...st/java/com/worldpay/access/checkout/reactnative/ui/AccessCheckoutTextInputManagerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.worldpay.access.checkout.reactnative.ui | ||
|
||
import android.content.Context | ||
import android.graphics.Color | ||
import androidx.test.core.app.ApplicationProvider | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.worldpay.access.checkout.ui.AccessCheckoutEditText | ||
import org.assertj.core.api.AssertionsForClassTypes.assertThat | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.Mockito.mock | ||
import org.mockito.Mockito.verify | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
internal class AccessCheckoutTextInputManagerTest { | ||
private val manager = AccessCheckoutTextInputManager(reactApplicationContext()) | ||
private val accessCheckoutEditTextMock = mock(AccessCheckoutEditText::class.java) | ||
|
||
@Test | ||
fun `getName() should return the name of the react class`() { | ||
val expectedName = "AccessCheckoutTextInput" | ||
|
||
assertThat(manager.name).isEqualTo(expectedName) | ||
} | ||
|
||
@Test | ||
fun `setRTCTextColour() should call setTextColour on AccessEditText`() { | ||
manager.setRTCTextColor(accessCheckoutEditTextMock, Color.RED) | ||
|
||
verify(accessCheckoutEditTextMock).setTextColor(Color.RED) | ||
} | ||
|
||
@Test | ||
fun `setRTCPlaceholder() should call setHint on AccessEditText`() { | ||
manager.setRTCPlaceholder(accessCheckoutEditTextMock, "placeholder") | ||
|
||
verify(accessCheckoutEditTextMock).setHint("placeholder") | ||
} | ||
|
||
@Test | ||
fun `setRTCEditable() should call isEnabled on AccessEditText`() { | ||
manager.setRTCEditable(accessCheckoutEditTextMock, true) | ||
|
||
verify(accessCheckoutEditTextMock).isEnabled = true | ||
} | ||
|
||
|
||
private fun reactApplicationContext(): ReactApplicationContext { | ||
val applicationContext: Context = ApplicationProvider.getApplicationContext() | ||
return ReactApplicationContext(applicationContext) | ||
} | ||
} |
Oops, something went wrong.