Skip to content

Commit

Permalink
Merge pull request #37 from angrezichatterbox/feature-making-keyboard…
Browse files Browse the repository at this point in the history
…-similar-to-Scribe-IOS

feat:Added Shadow to the keys and reduced border radius
  • Loading branch information
andrewtavis authored Jul 2, 2024
2 parents 42d8a6c + 88fa9ed commit ee8e1a0
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions app/src/main/kotlin/org/scribe/views/MyKeyboardView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
private fun onBufferDraw() {
val keyMargin = 8
val shadowOffset = 3
val shadowPaint = Paint().apply {
style = Paint.Style.STROKE
strokeWidth = 2f
color = Color.BLACK
}
if (mBuffer == null || mKeyboardChanged) {
if (mBuffer == null || mKeyboardChanged && (mBuffer!!.width != width || mBuffer!!.height != height)) {
// Make sure our bitmap is at least 1x1
Expand Down Expand Up @@ -467,10 +462,18 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
typeface = Typeface.DEFAULT
}

val borderPaint = Paint().apply {
style = Paint.Style.STROKE
strokeWidth = 0.5f
color = Color.BLACK



val keyBackgroundPaint = Paint().apply {
color = Color.WHITE
style = Paint.Style.FILL
}

val shadowPaint = Paint().apply {
color = Color.GRAY
alpha = 100
style = Paint.Style.FILL
}

canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR)
Expand Down Expand Up @@ -505,15 +508,26 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut

val padding = 5

val rectRadius = 25f
val rectRadius = 15f
val shadowOffsetY = 9f

val shadowRect = RectF(
(key.x + keyMargin + padding).toFloat(),
(key.y + keyMargin + padding + shadowOffsetY).toFloat(),
(key.x + key.width - keyMargin - padding).toFloat(),
(key.y + key.height - keyMargin - padding + shadowOffsetY).toFloat()
)

val keyRect = RectF(
(key.x + keyMargin - shadowOffset + padding).toFloat(),
(key.y + keyMargin - shadowOffset + padding).toFloat(),
(key.x + key.width - keyMargin + shadowOffset - padding).toFloat(),
(key.y + key.height - keyMargin + shadowOffset - padding).toFloat()
)
canvas.drawRoundRect(keyRect, rectRadius, rectRadius, shadowPaint)
canvas.drawRoundRect(shadowRect, rectRadius, rectRadius, shadowPaint)

canvas.drawRoundRect(keyRect, rectRadius, rectRadius, keyBackgroundPaint)


keyBackground!!.setBounds(
keyMargin, keyMargin,
Expand Down Expand Up @@ -860,7 +874,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
}

override fun hasTextBeforeCursor(): Boolean {
return mOnKeyboardActionListener!!.hasTextBeforeCursor()
return mOnKeyboardActionListener!!.hasTextBeforeCursor()
}

override fun commitPeriodAfterSpace() {
Expand Down

0 comments on commit ee8e1a0

Please sign in to comment.