@momo-kits/calculator-keyboard 0.150.2-beta.13 → 0.150.2-beta.14

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.
@@ -9,12 +9,12 @@ import android.widget.Button
9
9
  import android.widget.ImageButton
10
10
  import androidx.appcompat.app.AppCompatActivity
11
11
  import androidx.constraintlayout.widget.ConstraintLayout
12
- import androidx.core.graphics.ColorUtils
13
12
  import com.facebook.react.uimanager.ThemedReactContext
14
13
  import org.mariuszgromada.math.mxparser.Expression
15
14
  import androidx.core.graphics.toColorInt
16
- import com.facebook.react.uimanager.PixelUtil.dpToPx
17
-
15
+ import com.calculatorkeyboard.RCTInputCalculator.Companion.calculatorHeight
16
+ import com.facebook.react.bridge.Arguments
17
+ import com.facebook.react.uimanager.events.RCTEventEmitter
18
18
 
19
19
  @SuppressLint("SetTextI18n", "ViewConstructor")
20
20
  class CustomKeyboardView(
@@ -22,22 +22,26 @@ class CustomKeyboardView(
22
22
  private val editText: CalculatorEditText
23
23
  ) : ConstraintLayout(context) {
24
24
  private val keys = listOf(
25
- listOf("AC", "÷", "×", "back"),
26
- listOf("7", "8", "9", "-"),
27
- listOf("4", "5", "6", "+"),
28
- listOf("1", "2", "3", "="),
29
- listOf("000", "0")
25
+ listOf("1", "2", "3", "÷", "back"),
26
+ listOf("4", "5", "6", "×", "="),
27
+ listOf("7", "8", "9", "-", "Xong"),
28
+ listOf("000", "0", "+")
30
29
  )
31
- private val specialKeys = listOf("=", "-", "×", "÷", "AC", "back", "+")
30
+ private val specialKeys = listOf("=", "-", "×", "÷", "back", "+")
32
31
  private val separatorWidth = 8f
33
32
  private var specialButtonColor: Int = "#D8D8D8".toColorInt()
34
33
 
34
+ private var customKeyButton: Button? = null
35
+ private var customKeyButtonBackground: Int = "#D8D8D8".toColorInt()
36
+ private var customKeyButtonTextColor: Int = Color.BLACK
37
+ private var customKeyButtonState: Int = 0
38
+
35
39
  init {
36
40
  val activity = context.currentActivity as? AppCompatActivity
37
41
  if (activity != null) {
38
42
  val displayMetrics = resources.displayMetrics
39
- val widthButton = (displayMetrics.widthPixels - separatorWidth * 2 - 3 * separatorWidth) / 4f
40
- val heightButton = (290.dpToPx() - separatorWidth * 2 - 4 * separatorWidth) / 5
43
+ val widthButton = (displayMetrics.widthPixels - separatorWidth * 2 - 4 * separatorWidth) / 5f
44
+ val heightButton = (calculatorHeight - separatorWidth * 2 - 3 * separatorWidth) / 4
41
45
 
42
46
  renderUI(widthButton, heightButton)
43
47
  }
@@ -46,16 +50,19 @@ class CustomKeyboardView(
46
50
 
47
51
  private fun renderUI(buttonWidth: Float, buttonHeight: Float) {
48
52
  var yOffset = separatorWidth
49
- for ((_, row) in keys.withIndex()) {
53
+ for ((rowIndex, row) in keys.withIndex()) {
50
54
  var xOffset = separatorWidth
51
- for ((_, key) in row.withIndex()) {
55
+ for ((colIndex, key) in row.withIndex()) {
56
+ val isCustomKey = rowIndex == 2 && colIndex == 4
52
57
  val width = if (key == "000") buttonWidth * 2 + separatorWidth else buttonWidth
53
- val height = if (key == "=") buttonWidth + separatorWidth else buttonHeight
58
+ val height = if (isCustomKey) buttonHeight * 2 + separatorWidth else buttonHeight
54
59
 
55
60
  val button = if (key == "back") {
56
61
  createImageButton(key, xOffset, yOffset, buttonWidth.toInt(), buttonHeight.toInt())
57
62
  } else {
58
- createButton(key, xOffset, yOffset, width.toInt(), height.toInt())
63
+ createButton(key, xOffset, yOffset, width.toInt(), height.toInt(), isCustomKey).also { b ->
64
+ if (isCustomKey) customKeyButton = b
65
+ }
59
66
  }
60
67
 
61
68
  addView(button)
@@ -72,8 +79,8 @@ class CustomKeyboardView(
72
79
  yOffset: Float,
73
80
  buttonWidth: Int,
74
81
  buttonHeight: Int,
82
+ isCustomKey: Boolean
75
83
  ): Button {
76
- val specialKeys = listOf("=", "-", "×", "÷", "AC", "back", "+")
77
84
  return Button(context).apply {
78
85
  val shapeInit = GradientDrawable().apply {
79
86
  shape = GradientDrawable.RECTANGLE
@@ -85,9 +92,11 @@ class CustomKeyboardView(
85
92
  background = shapeInit
86
93
  text = key
87
94
  setTypeface(typeface)
88
- textSize = 24.toFloat()
95
+ textSize = (if (isCustomKey) 18 else 24).toFloat()
89
96
  setTextColor(Color.BLACK)
90
97
  stateListAnimator = null
98
+ maxLines = 1
99
+ isAllCaps = false
91
100
  layoutParams = LayoutParams(
92
101
  buttonWidth,
93
102
  buttonHeight
@@ -107,7 +116,7 @@ class CustomKeyboardView(
107
116
 
108
117
  translationX = xOffset.toInt().toFloat()
109
118
  translationY = yOffset.toInt().toFloat()
110
- setOnClickListener { onKeyPress(key) }
119
+ setOnClickListener { onKeyPress(key, isCustomKey) }
111
120
  }
112
121
  }
113
122
 
@@ -136,7 +145,7 @@ class CustomKeyboardView(
136
145
  translationY = yOffset
137
146
  setImageResource(android.R.drawable.ic_input_delete)
138
147
  setImageTintList(ColorStateList.valueOf(Color.BLACK))
139
- setOnClickListener { onKeyPress(key) }
148
+ setOnClickListener { onKeyPress(key, false) }
140
149
  }
141
150
  }
142
151
 
@@ -172,25 +181,18 @@ class CustomKeyboardView(
172
181
  }
173
182
  }
174
183
 
175
- private fun onKeyPress(key: String) {
176
- when (key) {
177
- "AC" -> {
178
- clearText()
179
- }
180
-
181
- "back" -> {
182
- onBackSpace()
183
- }
184
-
185
- "=" -> {
186
- calculateResult()
187
- }
184
+ private fun onKeyPress(key: String, isCustomKey: Boolean) {
185
+ if (isCustomKey) {
186
+ emitCustomKey()
187
+ return
188
+ }
188
189
 
190
+ emitKeyPress(key)
191
+ when (key) {
192
+ "back" -> onBackSpace()
193
+ "=" -> calculateResult()
189
194
  "×", "+", "-", "÷" -> keyDidPress(" $key ")
190
-
191
- else -> {
192
- editText.text?.insert(editText.selectionStart, key)
193
- }
195
+ else -> editText.text?.insert(editText.selectionStart, key)
194
196
  }
195
197
  }
196
198
 
@@ -199,10 +201,6 @@ class CustomKeyboardView(
199
201
  editText.text?.replace(editText.selectionStart, editText.selectionEnd, key)
200
202
  }
201
203
 
202
- private fun clearText() {
203
- editText.text?.clear()
204
- }
205
-
206
204
  private fun onBackSpace() {
207
205
  val start = editText.selectionStart
208
206
  val end = editText.selectionEnd
@@ -239,4 +237,52 @@ class CustomKeyboardView(
239
237
  }
240
238
  }
241
239
 
240
+ private fun emitKeyPress(key: String) {
241
+ val reactContext = context as ThemedReactContext
242
+ val params = Arguments.createMap().apply {
243
+ putString("key", key)
244
+ }
245
+ reactContext.getJSModule(RCTEventEmitter::class.java)
246
+ .receiveEvent(editText.id, "onKeyPress", params)
247
+ }
248
+
249
+ private fun emitCustomKey() {
250
+ val reactContext = context as ThemedReactContext
251
+ reactContext.getJSModule(RCTEventEmitter::class.java)
252
+ .receiveEvent(editText.id, "onCustomKeyEvent", null)
253
+ }
254
+
255
+ fun setCustomKeyText(text: String) {
256
+ customKeyButton?.text = text
257
+ }
258
+
259
+ fun setCustomKeyBackground(background: Int) {
260
+ customKeyButtonBackground = background
261
+ updateCustomKeyUI(background, customKeyButtonTextColor, customKeyButtonState)
262
+ }
263
+
264
+ fun setCustomKeyTextColor(textColor: Int) {
265
+ customKeyButtonTextColor = textColor
266
+ updateCustomKeyUI(customKeyButtonBackground, textColor, customKeyButtonState)
267
+ }
268
+
269
+
270
+ fun setCustomKeyState(state: Int) {
271
+ customKeyButtonState = state
272
+ customKeyButton?.isEnabled = state == 0
273
+ updateCustomKeyUI(customKeyButtonBackground, customKeyButtonTextColor, state)
274
+ }
275
+
276
+ private fun updateCustomKeyUI(background: Int, textColor: Int, state: Int){
277
+ val backgroundColor = if(state == 1) "#EBEBF2".toColorInt() else background
278
+ val textColor = if (state == 1) Color.WHITE else textColor
279
+
280
+ customKeyButton?.background = GradientDrawable().apply {
281
+ shape = GradientDrawable.RECTANGLE
282
+ cornerRadius = 24f
283
+ setColor(backgroundColor)
284
+ }
285
+ customKeyButton?.setTextColor(textColor)
286
+ }
287
+
242
288
  }
@@ -2,40 +2,49 @@ package com.calculatorkeyboard
2
2
 
3
3
  import android.annotation.SuppressLint
4
4
  import android.app.Activity
5
- import android.graphics.PixelFormat
6
- import android.graphics.drawable.ColorDrawable
5
+ import android.content.Context
6
+ import android.content.ContextWrapper
7
+ import android.graphics.Color
7
8
  import android.view.Gravity
8
9
  import android.view.KeyEvent
9
10
  import android.view.View
10
- import android.view.WindowInsets
11
11
  import android.view.WindowManager
12
+ import android.view.animation.DecelerateInterpolator
13
+ import android.view.inputmethod.InputMethodManager
12
14
  import android.widget.PopupWindow
13
- import androidx.constraintlayout.widget.ConstraintLayout
15
+ import androidx.core.graphics.Insets
16
+ import androidx.core.graphics.drawable.toDrawable
14
17
  import androidx.core.graphics.toColorInt
18
+ import androidx.core.view.OnApplyWindowInsetsListener
19
+ import androidx.core.view.ViewCompat
20
+ import androidx.core.view.WindowInsetsCompat
15
21
  import com.facebook.react.bridge.ReadableArray
16
22
  import com.facebook.react.bridge.UiThreadUtil
23
+ import com.facebook.react.uimanager.PixelUtil.dpToPx
17
24
  import com.facebook.react.uimanager.ThemedReactContext
18
25
  import com.facebook.react.uimanager.annotations.ReactProp
19
26
  import com.facebook.react.views.textinput.ReactEditText
20
27
  import com.facebook.react.views.textinput.ReactTextInputManager
21
- import androidx.core.graphics.drawable.toDrawable
22
- import androidx.core.view.ViewCompat
23
- import androidx.core.view.WindowInsetsCompat
24
- import com.facebook.react.uimanager.PixelUtil.dpToPx
25
28
 
26
29
  class RCTInputCalculator : ReactTextInputManager() {
27
30
 
28
31
  private var keyboardView: CustomKeyboardView? = null
29
- private var calculatorHeight: Int = 290.dpToPx().toInt()
30
32
  private var popup: PopupWindow? = null
31
33
  private val animationDuration = 250L
32
34
 
33
35
  private lateinit var editText: CalculatorEditText
34
36
 
37
+ private var fakeImeListener: OnApplyWindowInsetsListener? = null
38
+ private var fakeImeAttachedTo: View? = null
39
+
40
+ private lateinit var imm: InputMethodManager
41
+
42
+
35
43
  override fun getName() = REACT_CLASS
36
44
 
37
45
  companion object {
38
46
  const val REACT_CLASS = "RCTInputCalculator"
47
+ val calculatorHeight: Int = 240.dpToPx().toInt()
39
48
  }
40
49
 
41
50
  @ReactProp(name = "value")
@@ -56,6 +65,27 @@ class RCTInputCalculator : ReactTextInputManager() {
56
65
  }
57
66
  }
58
67
 
68
+ @ReactProp(name = "customKeyText")
69
+ fun setCustomKeyText(view: ReactEditText, text: String?) {
70
+ keyboardView?.setCustomKeyText(text ?: "Xong")
71
+ }
72
+
73
+ @ReactProp(name = "customKeyBackground")
74
+ fun setCustomKeyBackground(view: ReactEditText, background: String?) {
75
+ keyboardView?.setCustomKeyBackground((background?: "#d8d8d8").toColorInt())
76
+ }
77
+
78
+ @ReactProp(name = "customKeyTextColor")
79
+ fun setCustomKeyTextColor(view: ReactEditText, textColor: String?) {
80
+ keyboardView?.setCustomKeyTextColor(textColor?.toColorInt() ?: Color.BLACK)
81
+ }
82
+
83
+
84
+ @ReactProp(name = "customKeyState")
85
+ fun setCustomKeyState(view: ReactEditText, state: Int?) {
86
+ keyboardView?.setCustomKeyState(state ?: 0)
87
+ }
88
+
59
89
  @ReactProp(name = "keyboardColor")
60
90
  fun setKeyboardColor(view: ReactEditText, color: String) {
61
91
  keyboardView?.updateButtonColors(color.toColorInt())
@@ -63,8 +93,10 @@ class RCTInputCalculator : ReactTextInputManager() {
63
93
 
64
94
  @SuppressLint("ClickableViewAccessibility")
65
95
  override fun createViewInstance(context: ThemedReactContext): ReactEditText {
96
+ imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
97
+
66
98
  editText = CalculatorEditText(context).apply {
67
- showSoftInputOnFocus = false
99
+ showSoftInputOnFocus = true
68
100
  }
69
101
 
70
102
  keyboardView = CustomKeyboardView(context, editText).apply {
@@ -107,6 +139,24 @@ class RCTInputCalculator : ReactTextInputManager() {
107
139
  }
108
140
  }
109
141
 
142
+ override fun getExportedCustomBubblingEventTypeConstants(): MutableMap<String, Any> {
143
+ val base = super.getExportedCustomBubblingEventTypeConstants().toMutableMap()
144
+
145
+ base["onKeyPress"] = mapOf(
146
+ "phasedRegistrationNames" to mapOf(
147
+ "bubbled" to "onKeyPress"
148
+ )
149
+ )
150
+
151
+ return base
152
+ }
153
+
154
+ override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
155
+ val base = super.getExportedCustomDirectEventTypeConstants().toMutableMap()
156
+ base["onCustomKeyEvent"] = mapOf("registrationName" to "onCustomKeyEvent")
157
+ return base
158
+ }
159
+
110
160
  private fun ensurePopup() {
111
161
  if (popup != null) return
112
162
  val content = keyboardView ?: return
@@ -136,33 +186,143 @@ class RCTInputCalculator : ReactTextInputManager() {
136
186
  val p = popup ?: return
137
187
  if (p.isShowing) return
138
188
 
139
- val root = keyboardView ?: return
189
+ disableSystemImeFor(editText)
140
190
 
141
- root.translationY = calculatorHeight.toFloat()
191
+ p.animationStyle = 0
192
+ p.height = calculatorHeight + bottomInsetFrom(anchor.rootView)
142
193
  p.showAtLocation(anchor.rootView, Gravity.BOTTOM or Gravity.START, 0, 0)
143
194
 
144
- root.animate()
145
- ?.translationY(0f)
146
- ?.setDuration(animationDuration)
147
- ?.start()
195
+ val content = p.contentView
196
+
197
+ val h = content.height.takeIf { it > 0 } ?: p.height
198
+ content.translationY = h.toFloat()
199
+
200
+ content.post {
201
+ content.animate()
202
+ .translationY(0f)
203
+ .setDuration(animationDuration)
204
+ .setInterpolator(DecelerateInterpolator())
205
+ .withStartAction { content.setLayerType(View.LAYER_TYPE_HARDWARE, null) }
206
+ .withEndAction { content.setLayerType(View.LAYER_TYPE_NONE, null) }
207
+ .start()
208
+ }
209
+
210
+ content.post {
211
+ findActivityFrom(content)?.let { act ->
212
+ setFakeIme(act.window.decorView, true, calculatorHeight)
213
+ }
214
+ }
148
215
  }
149
216
 
150
217
  private fun hideKeyboardPopup() {
151
- val p = popup ?: return
152
- if (!p.isShowing) return
153
- val root = keyboardView ?: return
218
+ val p = popup ?: run {
219
+ enableSystemImeFor(editText, requestShow = false)
220
+ return
221
+ }
222
+ if (!p.isShowing) {
223
+ enableSystemImeFor(editText, requestShow = false)
224
+ popup = null
225
+ return
226
+ }
227
+ val content = p.contentView
228
+
229
+ content.animate().cancel()
154
230
 
155
- root.animate()
156
- .translationY(calculatorHeight.toFloat())
231
+ val distance = (content.height.takeIf { it > 0 } ?: p.height).toFloat()
232
+
233
+ content.animate()
234
+ .translationY(distance)
157
235
  .setDuration(animationDuration)
236
+ .setInterpolator(DecelerateInterpolator())
158
237
  .withEndAction {
159
- try {
160
- if (p.isShowing) p.dismiss()
161
- } catch (_: Throwable) { }
238
+ try { if (p.isShowing) p.dismiss() } catch (_: Throwable) {}
239
+ popup = null
240
+ content.translationY = 0f
241
+ content.setLayerType(View.LAYER_TYPE_NONE, null)
242
+
243
+ findActivityFrom(content)?.let { act ->
244
+ setFakeIme(act.window.decorView, false, 0)
245
+ }
246
+ enableSystemImeFor(editText, requestShow = false)
247
+
162
248
  }
163
249
  .start()
250
+ }
251
+
252
+ private fun disableSystemImeFor(v: ReactEditText) {
253
+ v.showSoftInputOnFocus = false
254
+ if (android.os.Build.VERSION.SDK_INT >= 30) {
255
+ ViewCompat.getWindowInsetsController(v)?.hide(WindowInsetsCompat.Type.ime())
256
+ }
257
+ imm.hideSoftInputFromWindow(v.windowToken, 0)
258
+ }
164
259
 
165
- popup = null
260
+
261
+ private fun enableSystemImeFor(v: ReactEditText, requestShow: Boolean) {
262
+ v.showSoftInputOnFocus = true
263
+ if (requestShow && v.isFocused) {
264
+ v.post {
265
+ if (android.os.Build.VERSION.SDK_INT >= 30) {
266
+ ViewCompat.getWindowInsetsController(v)?.show(WindowInsetsCompat.Type.ime())
267
+ } else {
268
+ imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT)
269
+ }
270
+ }
271
+ }
272
+ }
273
+
274
+ private fun setFakeIme(rootView: View, show: Boolean, heightPx: Int) {
275
+ if (show) {
276
+ if (fakeImeListener != null && fakeImeAttachedTo === rootView) {
277
+ ViewCompat.requestApplyInsets(rootView)
278
+ return
279
+ }
280
+ fakeImeAttachedTo?.let { ViewCompat.setOnApplyWindowInsetsListener(it, null) }
281
+ fakeImeAttachedTo = rootView
282
+
283
+ val listener = OnApplyWindowInsetsListener { _, insets ->
284
+ val curBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
285
+ val newBarsBottom = maxOf(curBars.bottom, heightPx)
286
+
287
+ WindowInsetsCompat.Builder(insets)
288
+ .setInsets(WindowInsetsCompat.Type.ime(), Insets.of(0, 0, 0, heightPx))
289
+ .setVisible(WindowInsetsCompat.Type.ime(), true)
290
+ .setInsets(
291
+ WindowInsetsCompat.Type.systemBars(),
292
+ Insets.of(curBars.left, curBars.top, curBars.right, newBarsBottom)
293
+ )
294
+ .build()
295
+ }
296
+
297
+ fakeImeListener = listener
298
+ ViewCompat.setOnApplyWindowInsetsListener(rootView, listener)
299
+ ViewCompat.requestApplyInsets(rootView)
300
+ } else {
301
+ fakeImeAttachedTo?.let { ViewCompat.setOnApplyWindowInsetsListener(it, null) }
302
+ fakeImeListener = null
303
+ fakeImeAttachedTo = null
304
+
305
+ ViewCompat.requestApplyInsets(rootView)
306
+
307
+ if (android.os.Build.VERSION.SDK_INT >= 30) {
308
+ rootView.rootWindowInsets?.let { wi ->
309
+ rootView.dispatchApplyWindowInsets(wi)
310
+ }
311
+ }
312
+ }
313
+ }
314
+
315
+ private fun findActivityFrom(view: View): Activity? {
316
+ var ctx: Context? = view.context
317
+ if (ctx is ThemedReactContext) {
318
+ ctx.currentActivity?.let { return it }
319
+ ctx = ctx.baseContext
320
+ }
321
+ while (ctx is ContextWrapper) {
322
+ if (ctx is Activity) return ctx
323
+ ctx = ctx.baseContext
324
+ }
325
+ return null
166
326
  }
167
327
 
168
328
  private fun focus() {
@@ -8,14 +8,20 @@ class CalculatorKeyboardView: UIView {
8
8
  weak var input: InputCalculator?
9
9
 
10
10
  private let keys: [[String]] = [
11
- ["AC", "÷", "×", "back"],
12
- ["7", "8", "9", "-"],
13
- ["4", "5", "6", "+"],
14
- ["1", "2", "3", "="],
15
- ["000", "0"]
11
+ ["1", "2", "3", "÷", "back"],
12
+ ["4", "5", "6", "×", "="],
13
+ ["7", "8", "9", "-", "Xong"],
14
+ ["000", "0", "+"],
16
15
  ]
17
16
  private let SEPARATOR_WIDTH: CGFloat = 4
18
- private let specialKeys: Set<String> = ["=", "-", "×", "÷", "AC", "back", "+"]
17
+ private let specialKeys: Set<String> = ["=", "-", "×", "÷", "back", "+"]
18
+
19
+ var customKeyText: String? { didSet { updateCustomKeyTitle() } }
20
+ var customKeyBackground: String? { didSet { updateCustomKeyBackground() } }
21
+ var customKeyTextColor: String? { didSet { updateCustomKeyBackground() } }
22
+ var customKeyState: Int? { didSet { updateCustomKeyBackground() } }
23
+ private weak var customKeyButton: UIButton?
24
+
19
25
 
20
26
  override init(frame: CGRect) {
21
27
  super.init(frame: frame)
@@ -34,8 +40,8 @@ class CalculatorKeyboardView: UIView {
34
40
  self.subviews.forEach { $0.removeFromSuperview() }
35
41
 
36
42
  backgroundColor = UIColor(hex: "#f2f2f6")
37
- let buttonWidth = (UIScreen.main.bounds.width - SEPARATOR_WIDTH * 2 - 3 * SEPARATOR_WIDTH) / 4
38
- let buttonHeight: CGFloat = (290 - SEPARATOR_WIDTH * 2 - 4 * SEPARATOR_WIDTH) / 5
43
+ let buttonWidth = (UIScreen.main.bounds.width - SEPARATOR_WIDTH * 2 - 4 * SEPARATOR_WIDTH) / 5
44
+ let buttonHeight: CGFloat = (240 - SEPARATOR_WIDTH * 2 - 3 * SEPARATOR_WIDTH) / 4
39
45
 
40
46
  // Create a wrapper view
41
47
  let contentView = UIView()
@@ -52,19 +58,22 @@ class CalculatorKeyboardView: UIView {
52
58
 
53
59
  // Add buttons to the wrapper view
54
60
  var yOffset: CGFloat = 0
55
- for row in keys {
61
+ for (rowIndex, row) in keys.enumerated() {
56
62
  var xOffset: CGFloat = 0
57
- for key in row {
63
+ for (colIndex, key) in row.enumerated() {
64
+ let isCustomKey = colIndex == 4 && rowIndex == 2
58
65
  let button = UIButton(type: .system)
59
66
  button.backgroundColor = UIColor.white
60
67
  button.layer.cornerRadius = 8
61
- button.setTitle(key, for: .normal)
68
+ let title = isCustomKey ? (customKeyText ?? key) : key
69
+ button.setTitle(title, for: .normal)
62
70
  button.setTitleColor(.black, for: .normal)
63
- button.titleLabel?.font = UIFont.systemFont(ofSize: 24, weight: .medium)
71
+ button.titleLabel?.font = UIFont.systemFont(ofSize: isCustomKey ? 18 : 24, weight: .medium)
64
72
  button.nativeID = key
73
+ button.tag = isCustomKey ? 1 : 0
65
74
 
66
75
  var buttonFrame = CGRect(x: xOffset, y: yOffset, width: buttonWidth, height: buttonHeight)
67
- if key == "=" {
76
+ if isCustomKey {
68
77
  buttonFrame.size.height = buttonHeight * 2 + SEPARATOR_WIDTH
69
78
  }
70
79
  if key == "000" {
@@ -85,6 +94,10 @@ class CalculatorKeyboardView: UIView {
85
94
  button.backgroundColor = color
86
95
  }
87
96
 
97
+ if isCustomKey {
98
+ self.customKeyButton = button
99
+ }
100
+
88
101
  button.addTarget(self, action: #selector(keyPressed(_:)), for: .touchUpInside)
89
102
  contentView.addSubview(button)
90
103
 
@@ -96,12 +109,49 @@ class CalculatorKeyboardView: UIView {
96
109
  }
97
110
  }
98
111
 
112
+ private func updateCustomKeyTitle() {
113
+ guard let btn = customKeyButton, let title = customKeyText else { return }
114
+ btn.setTitle(title, for: .normal)
115
+ btn.setImage(nil, for: .normal)
116
+ }
117
+
118
+ private func updateCustomKeyBackground() {
119
+ guard let btn = customKeyButton,
120
+ let background = customKeyBackground,
121
+ let textColor = customKeyTextColor,
122
+ let state = customKeyState else { return }
123
+
124
+ let bgColor: String
125
+ if state == 1 {
126
+ bgColor = "#EBEBF2"
127
+ } else {
128
+ bgColor = background
129
+ }
130
+
131
+ let txtColor: UIColor
132
+ if state == 1 {
133
+ txtColor = .white
134
+ } else {
135
+ txtColor = UIColor(hex: textColor)
136
+ }
137
+
138
+ btn.isEnabled = state == 0
139
+ btn.backgroundColor = UIColor(hex: bgColor)
140
+ btn.setTitleColor(txtColor, for: .normal)
141
+
142
+ }
143
+
99
144
 
100
145
  @objc private func keyPressed(_ sender: UIButton) {
101
146
  guard let key = sender.nativeID else { return }
147
+ let isCustomKey = sender.tag == 1
148
+ if (isCustomKey) {
149
+ input?.emitCustomKey()
150
+ return
151
+ }
152
+
153
+ input?.emitKeyPress(key)
102
154
  switch key {
103
- case "AC":
104
- input?.clearText()
105
155
  case "back":
106
156
  input?.onBackSpace()
107
157
  case "=":
@@ -56,6 +56,8 @@ RCT_EXPORT_SHADOW_PROPERTY(onContentSizeChange, RCTDirectEventBlock)
56
56
  RCT_EXPORT_VIEW_PROPERTY(value, NSString)
57
57
  RCT_EXPORT_VIEW_PROPERTY(onFocus, RCTBubblingEventBlock)
58
58
  RCT_EXPORT_VIEW_PROPERTY(onBlur, RCTBubblingEventBlock)
59
+ RCT_EXPORT_VIEW_PROPERTY(onKeyPress, RCTBubblingEventBlock)
60
+ RCT_EXPORT_VIEW_PROPERTY(onCustomKeyEvent, RCTDirectEventBlock)
59
61
 
60
62
  RCT_EXPORT_METHOD(focus : (nonnull NSNumber *)viewTag)
61
63
  {
@@ -74,6 +76,10 @@ RCT_EXPORT_METHOD(blur : (nonnull NSNumber *)viewTag)
74
76
  }
75
77
 
76
78
  RCT_EXPORT_VIEW_PROPERTY(keyboardColor, UIColor)
79
+ RCT_EXPORT_VIEW_PROPERTY(customKeyText, NSString)
80
+ RCT_EXPORT_VIEW_PROPERTY(customKeyBackground, NSString)
81
+ RCT_EXPORT_VIEW_PROPERTY(customKeyTextColor, NSString)
82
+ RCT_EXPORT_VIEW_PROPERTY(customKeyState, NSNumber)
77
83
 
78
84
  @end
79
85
 
@@ -19,6 +19,24 @@ class InputCalculator: RCTSinglelineTextInputView {
19
19
 
20
20
  @objc var onFocus: RCTBubblingEventBlock?
21
21
  @objc var onBlur: RCTBubblingEventBlock?
22
+ @objc var onKeyPress: RCTBubblingEventBlock?
23
+ @objc var onCustomKeyEvent: RCTDirectEventBlock?
24
+
25
+ @objc var customKeyText: String? {
26
+ didSet { keyboardView?.customKeyText = customKeyText as String? }
27
+ }
28
+
29
+ @objc var customKeyBackground: String? {
30
+ didSet { keyboardView?.customKeyBackground = customKeyBackground }
31
+ }
32
+
33
+ @objc var customKeyTextColor: String? {
34
+ didSet { keyboardView?.customKeyTextColor = customKeyTextColor }
35
+ }
36
+
37
+ @objc var customKeyState: NSNumber? {
38
+ didSet { keyboardView?.customKeyState = customKeyState?.intValue }
39
+ }
22
40
 
23
41
  @objc func beginEditingInput(_ note: Notification) { onFocus?([:]) }
24
42
  @objc func endEditingInput(_ note: Notification) { onBlur?([:]) }
@@ -50,7 +68,7 @@ class InputCalculator: RCTSinglelineTextInputView {
50
68
  super.init(bridge: bridge)
51
69
  self.bridge = bridge
52
70
  self.keyboardView = CalculatorKeyboardView()
53
- self.keyboardView!.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 290 + getbottomInset())
71
+ self.keyboardView!.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 240 + getbottomInset())
54
72
  self.keyboardView!.input = self
55
73
 
56
74
  backedTextInputView.inputView = self.keyboardView
@@ -79,19 +97,12 @@ class InputCalculator: RCTSinglelineTextInputView {
79
97
  func keyDidPress(_ key: String) {
80
98
  backedTextInputView.insertText(key)
81
99
  value += key
100
+
82
101
  if let bridge = bridge {
83
102
  bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "\(key)", eventCount: 1)
84
103
  }
85
104
  }
86
105
 
87
- func clearText() {
88
- value = ""
89
- (backedTextInputView as? UITextField)?.text = ""
90
- if let bridge = bridge {
91
- bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "clear", eventCount: 1)
92
- }
93
- }
94
-
95
106
  func onBackSpace() {
96
107
  value = value.dropLast().description
97
108
  DispatchQueue.main.async {
@@ -102,7 +113,7 @@ class InputCalculator: RCTSinglelineTextInputView {
102
113
  self.backedTextInputView.replace(newRange, withText: "")
103
114
  }
104
115
  }
105
-
116
+
106
117
  if let bridge = bridge {
107
118
  bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "back", eventCount: 1)
108
119
  }
@@ -124,6 +135,7 @@ class InputCalculator: RCTSinglelineTextInputView {
124
135
  if let result = expression.expressionValue(with: nil, context: nil) as? NSNumber {
125
136
  textField.text = result.stringValue
126
137
  value = result.stringValue
138
+
127
139
  if let bridge = bridge {
128
140
  bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "=", eventCount: 1)
129
141
  }
@@ -133,6 +145,14 @@ class InputCalculator: RCTSinglelineTextInputView {
133
145
  print("Invalid expression")
134
146
  }
135
147
  }
148
+
149
+ func emitCustomKey() {
150
+ onCustomKeyEvent?([:])
151
+ }
152
+
153
+ func emitKeyPress(_ key: String) {
154
+ onKeyPress?(["key": key])
155
+ }
136
156
 
137
157
  }
138
158
 
@@ -3,14 +3,44 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.CustomKeyState = exports.CustomKeyBackground = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  const NAME = 'RCTInputCalculator';
12
12
  const NativeInput = (0, _reactNative.requireNativeComponent)(NAME);
13
- const InputCalculator = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
13
+ let CustomKeyBackground = exports.CustomKeyBackground = /*#__PURE__*/function (CustomKeyBackground) {
14
+ CustomKeyBackground[CustomKeyBackground["Default"] = 0] = "Default";
15
+ CustomKeyBackground[CustomKeyBackground["Primary"] = 1] = "Primary";
16
+ return CustomKeyBackground;
17
+ }({});
18
+ /**
19
+ * export enum CustomKeyBackground {
20
+ * Default = 'default',
21
+ * Primary = 'primary',
22
+ * }
23
+ */
24
+ let CustomKeyState = exports.CustomKeyState = /*#__PURE__*/function (CustomKeyState) {
25
+ CustomKeyState[CustomKeyState["Default"] = 0] = "Default";
26
+ CustomKeyState[CustomKeyState["Disabled"] = 1] = "Disabled";
27
+ return CustomKeyState;
28
+ }({});
29
+ /**
30
+ * export enum CustomKeyState {
31
+ * Default = 'default',
32
+ * Disable = 'disable',
33
+ * }
34
+ */
35
+ const InputCalculator = /*#__PURE__*/_react.default.forwardRef(({
36
+ customKeyBackground = 'default',
37
+ keyboardColor = '',
38
+ customKeyText,
39
+ onKeyPress,
40
+ customKeyState = CustomKeyState.Default,
41
+ onCustomKeyEvent,
42
+ ...props
43
+ }, ref) => {
14
44
  const nativeRef = _react.default.useRef(null);
15
45
  const _onChange = event => {
16
46
  const currentText = event.nativeEvent.text;
@@ -18,6 +48,16 @@ const InputCalculator = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
18
48
  props.onChangeText && props.onChangeText(currentText);
19
49
  };
20
50
  const text = props.text ?? props.defaultValue ?? '';
51
+ let keyBackground = '#D8D8D8';
52
+ let textKeyColor = '#000000';
53
+ if (customKeyBackground === CustomKeyBackground.Primary) {
54
+ keyBackground = '#EB2F96';
55
+ textKeyColor = '#FFFFFF';
56
+ }
57
+
58
+ /**
59
+ * expose methods to parent component
60
+ */
21
61
  _react.default.useImperativeHandle(ref, () => ({
22
62
  focus() {
23
63
  const node = (0, _reactNative.findNodeHandle)(nativeRef.current);
@@ -40,8 +80,14 @@ const InputCalculator = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
40
80
  ...props,
41
81
  ref: nativeRef,
42
82
  onChange: _onChange,
83
+ onKeyPress: onKeyPress,
43
84
  value: text,
44
- keybardColor: (0, _reactNative.processColor)(props.keyboardColor)
85
+ keybardColor: (0, _reactNative.processColor)(keyboardColor),
86
+ customKeyText: customKeyText,
87
+ customKeyBackground: keyBackground,
88
+ customKeyTextColor: textKeyColor,
89
+ customKeyState: customKeyState,
90
+ onCustomKeyEvent: onCustomKeyEvent
45
91
  });
46
92
  });
47
93
  var _default = exports.default = InputCalculator;
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","e","__esModule","default","NAME","NativeInput","requireNativeComponent","InputCalculator","React","forwardRef","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","useImperativeHandle","focus","node","findNodeHandle","current","config","UIManager","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","jsx","value","keybardColor","processColor","keyboardColor","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQsB,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGtB,MAAMG,IAAI,GAAG,oBAAoB;AACjC,MAAMC,WAAW,GAAG,IAAAC,mCAAsB,EAAMF,IAAI,CAAC;AAYrD,MAAMG,eAAe,gBAAGC,cAAK,CAACC,UAAU,CACtC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACd,MAAMC,SAAS,GAAGJ,cAAK,CAACK,MAAM,CAAM,IAAI,CAAC;EAEzC,MAAMC,SAAS,GACbC,KAAqD,IAClD;IACH,MAAMC,WAAW,GAAGD,KAAK,CAACE,WAAW,CAACC,IAAI;IAC1CR,KAAK,CAACS,QAAQ,IAAIT,KAAK,CAACS,QAAQ,CAACJ,KAAK,CAAC;IACvCL,KAAK,CAACU,YAAY,IAAIV,KAAK,CAACU,YAAY,CAACJ,WAAW,CAAC;EACvD,CAAC;EAED,MAAME,IAAI,GAAGR,KAAK,CAACQ,IAAI,IAAIR,KAAK,CAACW,YAAY,IAAI,EAAE;EAEnDb,cAAK,CAACc,mBAAmB,CAACX,GAAG,EAAE,OAAO;IACpCY,KAAKA,CAAA,EAAG;MACN,MAAMC,IAAI,GAAG,IAAAC,2BAAc,EAACb,SAAS,CAACc,OAAO,CAAC;MAC9C,IAAI,CAACF,IAAI,EAAE;MACX,MAAMG,MAAM,GAAGC,sBAAS,CAACC,oBAAoB,CAACzB,IAAI,CAAC;MACnD,IAAIuB,MAAM,EAAEG,QAAQ,EAAEP,KAAK,IAAI,IAAI,EAAE;QACnCK,sBAAS,CAACG,0BAA0B,CAACP,IAAI,EAAEG,MAAM,CAACG,QAAQ,CAACP,KAAK,EAAE,EAAE,CAAC;MACvE;IACF,CAAC;IACDS,IAAIA,CAAA,EAAG;MACL,MAAMR,IAAI,GAAG,IAAAC,2BAAc,EAACb,SAAS,CAACc,OAAO,CAAC;MAC9C,IAAI,CAACF,IAAI,EAAE;MACX,MAAMG,MAAM,GAAGC,sBAAS,CAACC,oBAAoB,CAACzB,IAAI,CAAC;MACnD,IAAIuB,MAAM,EAAEG,QAAQ,EAAEE,IAAI,IAAI,IAAI,EAAE;QAClCJ,sBAAS,CAACG,0BAA0B,CAACP,IAAI,EAAEG,MAAM,CAACG,QAAQ,CAACE,IAAI,EAAE,EAAE,CAAC;MACtE;IACF;EACF,CAAC,CAAC,CAAC;EAEH,oBACE,IAAAhC,WAAA,CAAAiC,GAAA,EAAC5B,WAAW;IAAA,GACNK,KAAK;IACTC,GAAG,EAAEC,SAAU;IACfO,QAAQ,EAAEL,SAAU;IACpBoB,KAAK,EAAEhB,IAAK;IACZiB,YAAY,EAAE,IAAAC,yBAAY,EAAC1B,KAAK,CAAC2B,aAAa;EAAE,CACjD,CAAC;AAEN,CACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAApC,OAAA,GAEaI,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","e","__esModule","default","NAME","NativeInput","requireNativeComponent","CustomKeyBackground","exports","CustomKeyState","InputCalculator","React","forwardRef","customKeyBackground","keyboardColor","customKeyText","onKeyPress","customKeyState","Default","onCustomKeyEvent","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","keyBackground","textKeyColor","Primary","useImperativeHandle","focus","node","findNodeHandle","current","config","UIManager","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","jsx","value","keybardColor","processColor","customKeyTextColor","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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","ignoreList":[]}
@@ -1,12 +1,45 @@
1
1
  "use strict";
2
2
 
3
3
  import React from 'react';
4
- import { processColor, UIManager, findNodeHandle } from 'react-native';
5
- import { requireNativeComponent } from 'react-native';
4
+ import { findNodeHandle, processColor, requireNativeComponent, UIManager } from 'react-native';
6
5
  import { jsx as _jsx } from "react/jsx-runtime";
7
6
  const NAME = 'RCTInputCalculator';
8
7
  const NativeInput = requireNativeComponent(NAME);
9
- const InputCalculator = /*#__PURE__*/React.forwardRef((props, ref) => {
8
+ export let CustomKeyBackground = /*#__PURE__*/function (CustomKeyBackground) {
9
+ CustomKeyBackground[CustomKeyBackground["Default"] = 0] = "Default";
10
+ CustomKeyBackground[CustomKeyBackground["Primary"] = 1] = "Primary";
11
+ return CustomKeyBackground;
12
+ }({});
13
+
14
+ /**
15
+ * export enum CustomKeyBackground {
16
+ * Default = 'default',
17
+ * Primary = 'primary',
18
+ * }
19
+ */
20
+
21
+ export let CustomKeyState = /*#__PURE__*/function (CustomKeyState) {
22
+ CustomKeyState[CustomKeyState["Default"] = 0] = "Default";
23
+ CustomKeyState[CustomKeyState["Disabled"] = 1] = "Disabled";
24
+ return CustomKeyState;
25
+ }({});
26
+
27
+ /**
28
+ * export enum CustomKeyState {
29
+ * Default = 'default',
30
+ * Disable = 'disable',
31
+ * }
32
+ */
33
+
34
+ const InputCalculator = /*#__PURE__*/React.forwardRef(({
35
+ customKeyBackground = 'default',
36
+ keyboardColor = '',
37
+ customKeyText,
38
+ onKeyPress,
39
+ customKeyState = CustomKeyState.Default,
40
+ onCustomKeyEvent,
41
+ ...props
42
+ }, ref) => {
10
43
  const nativeRef = React.useRef(null);
11
44
  const _onChange = event => {
12
45
  const currentText = event.nativeEvent.text;
@@ -14,6 +47,16 @@ const InputCalculator = /*#__PURE__*/React.forwardRef((props, ref) => {
14
47
  props.onChangeText && props.onChangeText(currentText);
15
48
  };
16
49
  const text = props.text ?? props.defaultValue ?? '';
50
+ let keyBackground = '#D8D8D8';
51
+ let textKeyColor = '#000000';
52
+ if (customKeyBackground === CustomKeyBackground.Primary) {
53
+ keyBackground = '#EB2F96';
54
+ textKeyColor = '#FFFFFF';
55
+ }
56
+
57
+ /**
58
+ * expose methods to parent component
59
+ */
17
60
  React.useImperativeHandle(ref, () => ({
18
61
  focus() {
19
62
  const node = findNodeHandle(nativeRef.current);
@@ -36,8 +79,14 @@ const InputCalculator = /*#__PURE__*/React.forwardRef((props, ref) => {
36
79
  ...props,
37
80
  ref: nativeRef,
38
81
  onChange: _onChange,
82
+ onKeyPress: onKeyPress,
39
83
  value: text,
40
- keybardColor: processColor(props.keyboardColor)
84
+ keybardColor: processColor(keyboardColor),
85
+ customKeyText: customKeyText,
86
+ customKeyBackground: keyBackground,
87
+ customKeyTextColor: textKeyColor,
88
+ customKeyState: customKeyState,
89
+ onCustomKeyEvent: onCustomKeyEvent
41
90
  });
42
91
  });
43
92
  export default InputCalculator;
@@ -1 +1 @@
1
- {"version":3,"names":["React","processColor","UIManager","findNodeHandle","requireNativeComponent","jsx","_jsx","NAME","NativeInput","InputCalculator","forwardRef","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","useImperativeHandle","focus","node","current","config","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","value","keybardColor","keyboardColor"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAKEC,YAAY,EACZC,SAAS,EACTC,cAAc,QACT,cAAc;AACrB,SAASC,sBAAsB,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEtD,MAAMC,IAAI,GAAG,oBAAoB;AACjC,MAAMC,WAAW,GAAGJ,sBAAsB,CAAMG,IAAI,CAAC;AAYrD,MAAME,eAAe,gBAAGT,KAAK,CAACU,UAAU,CACtC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACd,MAAMC,SAAS,GAAGb,KAAK,CAACc,MAAM,CAAM,IAAI,CAAC;EAEzC,MAAMC,SAAS,GACbC,KAAqD,IAClD;IACH,MAAMC,WAAW,GAAGD,KAAK,CAACE,WAAW,CAACC,IAAI;IAC1CR,KAAK,CAACS,QAAQ,IAAIT,KAAK,CAACS,QAAQ,CAACJ,KAAK,CAAC;IACvCL,KAAK,CAACU,YAAY,IAAIV,KAAK,CAACU,YAAY,CAACJ,WAAW,CAAC;EACvD,CAAC;EAED,MAAME,IAAI,GAAGR,KAAK,CAACQ,IAAI,IAAIR,KAAK,CAACW,YAAY,IAAI,EAAE;EAEnDtB,KAAK,CAACuB,mBAAmB,CAACX,GAAG,EAAE,OAAO;IACpCY,KAAKA,CAAA,EAAG;MACN,MAAMC,IAAI,GAAGtB,cAAc,CAACU,SAAS,CAACa,OAAO,CAAC;MAC9C,IAAI,CAACD,IAAI,EAAE;MACX,MAAME,MAAM,GAAGzB,SAAS,CAAC0B,oBAAoB,CAACrB,IAAI,CAAC;MACnD,IAAIoB,MAAM,EAAEE,QAAQ,EAAEL,KAAK,IAAI,IAAI,EAAE;QACnCtB,SAAS,CAAC4B,0BAA0B,CAACL,IAAI,EAAEE,MAAM,CAACE,QAAQ,CAACL,KAAK,EAAE,EAAE,CAAC;MACvE;IACF,CAAC;IACDO,IAAIA,CAAA,EAAG;MACL,MAAMN,IAAI,GAAGtB,cAAc,CAACU,SAAS,CAACa,OAAO,CAAC;MAC9C,IAAI,CAACD,IAAI,EAAE;MACX,MAAME,MAAM,GAAGzB,SAAS,CAAC0B,oBAAoB,CAACrB,IAAI,CAAC;MACnD,IAAIoB,MAAM,EAAEE,QAAQ,EAAEE,IAAI,IAAI,IAAI,EAAE;QAClC7B,SAAS,CAAC4B,0BAA0B,CAACL,IAAI,EAAEE,MAAM,CAACE,QAAQ,CAACE,IAAI,EAAE,EAAE,CAAC;MACtE;IACF;EACF,CAAC,CAAC,CAAC;EAEH,oBACEzB,IAAA,CAACE,WAAW;IAAA,GACNG,KAAK;IACTC,GAAG,EAAEC,SAAU;IACfO,QAAQ,EAAEL,SAAU;IACpBiB,KAAK,EAAEb,IAAK;IACZc,YAAY,EAAEhC,YAAY,CAACU,KAAK,CAACuB,aAAa;EAAE,CACjD,CAAC;AAEN,CACF,CAAC;AAED,eAAezB,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["React","findNodeHandle","processColor","requireNativeComponent","UIManager","jsx","_jsx","NAME","NativeInput","CustomKeyBackground","CustomKeyState","InputCalculator","forwardRef","customKeyBackground","keyboardColor","customKeyText","onKeyPress","customKeyState","Default","onCustomKeyEvent","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","keyBackground","textKeyColor","Primary","useImperativeHandle","focus","node","current","config","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","value","keybardColor","customKeyTextColor"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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","ignoreList":[]}
@@ -1,8 +1,38 @@
1
1
  import React from 'react';
2
- import { type TextInputProps, type ColorValue } from 'react-native';
2
+ import { type ColorValue, type TextInputProps } from 'react-native';
3
+ type KeyPressEvent = {
4
+ nativeEvent: {
5
+ key: string;
6
+ };
7
+ };
8
+ export declare enum CustomKeyBackground {
9
+ Default = 0,
10
+ Primary = 1
11
+ }
12
+ /**
13
+ * export enum CustomKeyBackground {
14
+ * Default = 'default',
15
+ * Primary = 'primary',
16
+ * }
17
+ */
18
+ export declare enum CustomKeyState {
19
+ Default = 0,
20
+ Disabled = 1
21
+ }
22
+ /**
23
+ * export enum CustomKeyState {
24
+ * Default = 'default',
25
+ * Disable = 'disable',
26
+ * }
27
+ */
3
28
  interface InputCalculatorProps extends TextInputProps {
4
29
  text?: string | undefined;
5
30
  keyboardColor?: ColorValue;
31
+ onKeyPress?: (e: KeyPressEvent) => void;
32
+ customKeyText?: string | undefined;
33
+ customKeyBackground?: CustomKeyBackground;
34
+ customKeyState?: CustomKeyState;
35
+ onCustomKeyEvent?: () => void;
6
36
  }
7
37
  export type InputCalculatorRef = {
8
38
  focus: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,UAAU,EAIhB,MAAM,cAAc,CAAC;AAMtB,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGA2CpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,UAAU,EAMf,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAC;AAKtB,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,oBAAY,mBAAmB;IAC7B,OAAO,IAAI;IACX,OAAO,IAAI;CACZ;AAED;;;;;GAKG;AAEH,oBAAY,cAAc;IACxB,OAAO,IAAI;IACX,QAAQ,IAAI;CACb;AAED;;;;;GAKG;AAEH,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGAyEpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,8 +1,38 @@
1
1
  import React from 'react';
2
- import { type TextInputProps, type ColorValue } from 'react-native';
2
+ import { type ColorValue, type TextInputProps } from 'react-native';
3
+ type KeyPressEvent = {
4
+ nativeEvent: {
5
+ key: string;
6
+ };
7
+ };
8
+ export declare enum CustomKeyBackground {
9
+ Default = 0,
10
+ Primary = 1
11
+ }
12
+ /**
13
+ * export enum CustomKeyBackground {
14
+ * Default = 'default',
15
+ * Primary = 'primary',
16
+ * }
17
+ */
18
+ export declare enum CustomKeyState {
19
+ Default = 0,
20
+ Disabled = 1
21
+ }
22
+ /**
23
+ * export enum CustomKeyState {
24
+ * Default = 'default',
25
+ * Disable = 'disable',
26
+ * }
27
+ */
3
28
  interface InputCalculatorProps extends TextInputProps {
4
29
  text?: string | undefined;
5
30
  keyboardColor?: ColorValue;
31
+ onKeyPress?: (e: KeyPressEvent) => void;
32
+ customKeyText?: string | undefined;
33
+ customKeyBackground?: CustomKeyBackground;
34
+ customKeyState?: CustomKeyState;
35
+ onCustomKeyEvent?: () => void;
6
36
  }
7
37
  export type InputCalculatorRef = {
8
38
  focus: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,UAAU,EAIhB,MAAM,cAAc,CAAC;AAMtB,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGA2CpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,UAAU,EAMf,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAC;AAKtB,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,oBAAY,mBAAmB;IAC7B,OAAO,IAAI;IACX,OAAO,IAAI;CACZ;AAED;;;;;GAKG;AAEH,oBAAY,cAAc;IACxB,OAAO,IAAI;IACX,QAAQ,IAAI;CACb;AAED;;;;;GAKG;AAEH,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGAyEpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/calculator-keyboard",
3
- "version": "0.150.2-beta.13",
3
+ "version": "0.150.2-beta.14",
4
4
  "description": "react native calculator keyboard",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
package/src/index.tsx CHANGED
@@ -1,21 +1,52 @@
1
1
  import React from 'react';
2
2
  import {
3
+ type ColorValue,
4
+ findNodeHandle,
3
5
  type NativeSyntheticEvent,
6
+ processColor,
7
+ requireNativeComponent,
4
8
  type TextInputChangeEventData,
5
9
  type TextInputProps,
6
- type ColorValue,
7
- processColor,
8
10
  UIManager,
9
- findNodeHandle,
10
11
  } from 'react-native';
11
- import { requireNativeComponent } from 'react-native';
12
12
 
13
13
  const NAME = 'RCTInputCalculator';
14
14
  const NativeInput = requireNativeComponent<any>(NAME);
15
15
 
16
+ type KeyPressEvent = { nativeEvent: { key: string } };
17
+
18
+ export enum CustomKeyBackground {
19
+ Default = 0,
20
+ Primary = 1,
21
+ }
22
+
23
+ /**
24
+ * export enum CustomKeyBackground {
25
+ * Default = 'default',
26
+ * Primary = 'primary',
27
+ * }
28
+ */
29
+
30
+ export enum CustomKeyState {
31
+ Default = 0,
32
+ Disabled = 1,
33
+ }
34
+
35
+ /**
36
+ * export enum CustomKeyState {
37
+ * Default = 'default',
38
+ * Disable = 'disable',
39
+ * }
40
+ */
41
+
16
42
  interface InputCalculatorProps extends TextInputProps {
17
43
  text?: string | undefined;
18
44
  keyboardColor?: ColorValue;
45
+ onKeyPress?: (e: KeyPressEvent) => void;
46
+ customKeyText?: string | undefined;
47
+ customKeyBackground?: CustomKeyBackground;
48
+ customKeyState?: CustomKeyState;
49
+ onCustomKeyEvent?: () => void;
19
50
  }
20
51
 
21
52
  export type InputCalculatorRef = {
@@ -23,8 +54,22 @@ export type InputCalculatorRef = {
23
54
  blur: () => void;
24
55
  };
25
56
 
26
- const InputCalculator = React.forwardRef<InputCalculatorRef, InputCalculatorProps>(
27
- (props, ref) => {
57
+ const InputCalculator = React.forwardRef<
58
+ InputCalculatorRef,
59
+ InputCalculatorProps
60
+ >(
61
+ (
62
+ {
63
+ customKeyBackground = 'default',
64
+ keyboardColor = '',
65
+ customKeyText,
66
+ onKeyPress,
67
+ customKeyState = CustomKeyState.Default,
68
+ onCustomKeyEvent,
69
+ ...props
70
+ },
71
+ ref
72
+ ) => {
28
73
  const nativeRef = React.useRef<any>(null);
29
74
 
30
75
  const _onChange = (
@@ -36,7 +81,17 @@ const InputCalculator = React.forwardRef<InputCalculatorRef, InputCalculatorProp
36
81
  };
37
82
 
38
83
  const text = props.text ?? props.defaultValue ?? '';
84
+ let keyBackground = '#D8D8D8';
85
+ let textKeyColor = '#000000';
86
+
87
+ if (customKeyBackground === CustomKeyBackground.Primary) {
88
+ keyBackground = '#EB2F96';
89
+ textKeyColor = '#FFFFFF';
90
+ }
39
91
 
92
+ /**
93
+ * expose methods to parent component
94
+ */
40
95
  React.useImperativeHandle(ref, () => ({
41
96
  focus() {
42
97
  const node = findNodeHandle(nativeRef.current);
@@ -61,8 +116,14 @@ const InputCalculator = React.forwardRef<InputCalculatorRef, InputCalculatorProp
61
116
  {...props}
62
117
  ref={nativeRef}
63
118
  onChange={_onChange}
119
+ onKeyPress={onKeyPress}
64
120
  value={text}
65
- keybardColor={processColor(props.keyboardColor)}
121
+ keybardColor={processColor(keyboardColor)}
122
+ customKeyText={customKeyText}
123
+ customKeyBackground={keyBackground}
124
+ customKeyTextColor={textKeyColor}
125
+ customKeyState={customKeyState}
126
+ onCustomKeyEvent={onCustomKeyEvent}
66
127
  />
67
128
  );
68
129
  }