Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Change keyboard anims
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitSuda committed Nov 15, 2022
1 parent c2dbab9 commit c7199a7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import android.text.TextUtils
import android.view.inputmethod.ExtractedTextRequest
import android.view.inputmethod.InputConnection
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.*
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
Expand Down Expand Up @@ -73,7 +72,20 @@ fun ReboundSetKeyboardComponent(
}

Box {
AnimatedContent(targetState = currentMode) { mCurrentMode ->
AnimatedContent(
targetState = currentMode,
transitionSpec = {
if (targetState == KeyboardModeType.NUMBERS) {
slideInVertically { height -> -height } + fadeIn() with
slideOutVertically { height -> height } + fadeOut()
} else {
slideInVertically { height -> height } + fadeIn() with
slideOutVertically { height -> -height } + fadeOut()
}.using(
SizeTransform(clip = false)
)
}
) { mCurrentMode ->
when (mCurrentMode) {
KeyboardModeType.NUMBERS -> {
NumKeysContainerComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package com.ankitsuda.rebound.ui.keyboard

import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
Expand All @@ -30,6 +32,7 @@ import com.ankitsuda.rebound.ui.keyboard.enums.KeyboardModeType
import com.ankitsuda.rebound.ui.keyboard.enums.ReboundKeyboardType
import com.ankitsuda.rebound.ui.theme.LocalThemeState

@OptIn(ExperimentalAnimationApi::class)
@Composable
internal fun RightLayoutComponent(
modifier: Modifier,
Expand Down Expand Up @@ -60,19 +63,23 @@ internal fun RightLayoutComponent(
}
)
}) {
Icon(
imageVector = if (currentLayoutMode == KeyboardModeType.NUMBERS) {
Icons.Filled.Plates
} else {
Icons.Outlined.Dialpad
}, contentDescription = if (currentLayoutMode == KeyboardModeType.NUMBERS) {
stringResource(R.string.plate_calculator)
} else {
stringResource(R.string.keyboard)
},
tint = theme.keyboardContentColor
)

AnimatedContent(targetState = currentLayoutMode) {
Icon(
imageVector = if (it == KeyboardModeType.NUMBERS) {
Icons.Filled.Plates
} else {
Icons.Outlined.Dialpad
}, contentDescription = if (it == KeyboardModeType.NUMBERS) {
stringResource(R.string.plate_calculator)
} else {
stringResource(R.string.keyboard)
},
tint = theme.keyboardContentColor
)
}
}
}
}

}

0 comments on commit c7199a7

Please sign in to comment.