Skip to content

Instantly share code, notes, and snippets.

View surajsau's full-sized avatar
🙇‍♂️
よろしくお願いします!

Suraj Kumar Sau surajsau

🙇‍♂️
よろしくお願いします!
View GitHub Profile
@Composable
fun SlotText(
state: TransitionState,
modifier: Modifier = Modifier
) {
val current = state[currentSlotValue].toInt() % 10
val delta = state[currentSlotValue] - state[currentSlotValue].toInt()
@Composable
fun Slot(
from: Int,
to: Int,
..
) {
SlotText(
state = transition(
definition = transitionDefinition {
state(0) { this[currentTickerValue] = from.toFloat() }
@Composable
fun Slot(
from: Int,
to: Int,
modifier: Modifier = Modifier,
) {
SlotText(
state = transition(
definition = transitionDefinition {
// [1]
val currentSlotValue = FloatPropKey()
@Composable
fun SlotText(
state: TransitionState,
modifier: Modifier = Modifier
) {
// [1]
var current = state[currentSlotValue].toInt()
@Composable
fun CircleNeomorph(
state: TransitionState,
modifier: Modifier = Modifier,
) {
// [1]
val bias = (3 - 2f * state[buttonStateProgress]) * 0.1f
Box(modifier = modifier.size(size = 200.dp)) {
@Composable
fun NeomorphButton(
modifier: Modifier = Modifier
) {
// [1]
val buttonState = remember { mutableStateOf(ButtonState.IDLE) }
// [2]
val fromState = if(buttonState.value == ButtonState.IDLE) {
ButtonState.PRESSED
val items = listOf<Item>(..)
@Composable
fun Parallax(modifier: Modifier = Modifier) {
// [1]
val scrollState = rememberScrollState()
// [2]
ScrollableRow(
@Composable
fun ItemCard(
item: Item,
scrollX: Float,
modifier: Modifier = Modifier,
) {
Card(
modifier = modifier.size(width = 320.dp, height = 500.dp)
.padding(start = 16.dp, top = 16.dp, bottom = 16.dp),
) {
@surajsau
surajsau / NeomorphButton.kt
Created December 7, 2020 11:06
Neomorph Button using Jetpack Compose
val buttonStateProgress = FloatPropKey()
@Composable
fun NeomorphButton(
modifier: Modifier = Modifier
) {
// [1]
val buttonState = remember { mutableStateOf(ButtonState.IDLE) }
// [2]
@surajsau
surajsau / Toolbar#setTitleTextAppearance.java
Last active August 6, 2020 16:38
Toolbar.setTitleTextAppearance implementation in AOSP
/**
* Sets the text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*/
public void setTitleTextAppearance(Context context, @StyleRes int resId) {
mTitleTextAppearance = resId;
if (mTitleTextView != null) {
mTitleTextView.setTextAppearance(context, resId);
}
}