Animate keyboard fadein/fadeout.
All checks were successful
Build Android / build (push) Successful in 3m32s
All checks were successful
Build Android / build (push) Successful in 3m32s
Closes #27
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
package me.zobrist.tichucounter.ui.counter
|
package me.zobrist.tichucounter.ui.counter
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.core.tween
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.scaleIn
|
||||||
|
import androidx.compose.animation.scaleOut
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
@@ -17,6 +23,7 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
|
import androidx.compose.ui.graphics.TransformOrigin
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
@@ -75,10 +82,21 @@ fun Landscape(viewModel: ICounterViewModel) {
|
|||||||
Modifier.weight(1f)
|
Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (!viewModel.keyboardHidden) {
|
AnimatedVisibility(
|
||||||
Column(Modifier.weight(1f)) {
|
visible = !viewModel.keyboardHidden,
|
||||||
KeyBoardView(viewModel = viewModel)
|
enter = fadeIn(animationSpec = tween(100)) + scaleIn(
|
||||||
}
|
animationSpec = tween(100),
|
||||||
|
initialScale = 0.8f,
|
||||||
|
transformOrigin = TransformOrigin(1f, 1f)
|
||||||
|
),
|
||||||
|
exit = fadeOut(animationSpec = tween(100)) + scaleOut(
|
||||||
|
animationSpec = tween(100),
|
||||||
|
targetScale = 0.8f,
|
||||||
|
transformOrigin = TransformOrigin(1f, 1f)
|
||||||
|
),
|
||||||
|
modifier = Modifier.weight(1f)
|
||||||
|
) {
|
||||||
|
KeyBoardView(viewModel = viewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,7 +124,19 @@ fun Portrait(viewModel: ICounterViewModel) {
|
|||||||
Modifier.weight(1f)
|
Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!viewModel.keyboardHidden) {
|
AnimatedVisibility(
|
||||||
|
visible = !viewModel.keyboardHidden,
|
||||||
|
enter = fadeIn(animationSpec = tween(100)) + scaleIn(
|
||||||
|
animationSpec = tween(100),
|
||||||
|
initialScale = 0.8f,
|
||||||
|
transformOrigin = TransformOrigin(1f, 1f)
|
||||||
|
),
|
||||||
|
exit = fadeOut(animationSpec = tween(100)) + scaleOut(
|
||||||
|
animationSpec = tween(100),
|
||||||
|
targetScale = 0.8f,
|
||||||
|
transformOrigin = TransformOrigin(1f, 1f)
|
||||||
|
)
|
||||||
|
) {
|
||||||
KeyBoardView(viewModel = viewModel)
|
KeyBoardView(viewModel = viewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user