Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redesign keyboard theme #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/java/com/elliot00/liushu/input/InputView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private fun InputScreen(
) {
val screenHeight = LocalConfiguration.current.screenHeightDp.dp

Surface(tonalElevation = 5.dp, modifier = Modifier.height(screenHeight / 3)) {
Surface(modifier = Modifier.height(screenHeight / 3)) {
InputTokensPopup(state.segmentedTokens.joinToString(separator = " "))

Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.sp
import com.elliot00.liushu.input.keyboard.key.VariantKeyLabel
Expand All @@ -59,10 +60,10 @@ fun RowScope.AlphabetKey(
Box(
modifier = Modifier
.background(
color = MaterialTheme.colorScheme.surface,
shape = MaterialTheme.shapes.medium
color = MaterialTheme.colorScheme.surfaceContainerLowest,
shape = MaterialTheme.shapes.small
)
.clip(shape = MaterialTheme.shapes.medium)
.clip(shape = MaterialTheme.shapes.small)
.weight(1f)
.fillMaxHeight()
.pointerInput(Unit) {
Expand Down Expand Up @@ -114,11 +115,16 @@ fun RowScope.AlphabetKey(
},
contentAlignment = Alignment.Center
) {
Text(text = swipeUpText, fontSize = 8.sp, modifier = Modifier.align(Alignment.TopEnd))
Text(
text = swipeUpText,
fontSize = 12.sp,
fontFamily = FontFamily.Monospace,
modifier = Modifier.align(Alignment.TopEnd)
)
Text(
text = text,
color = MaterialTheme.colorScheme.onSurface,
fontSize = 28.sp,
fontSize = 26.sp,
fontFamily = FontFamily.Monospace,
textAlign = TextAlign.Center
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ fun RowScope.BackspaceKey(
Icon(
painter = painterResource(id = R.drawable.ic_outline_backspace_24),
contentDescription = "Backspace key",
tint = MaterialTheme.colorScheme.onSecondaryContainer
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun RowScope.EnterKey(
onClick = onClick,
modifier = Modifier
.background(
color = MaterialTheme.colorScheme.primaryContainer,
color = MaterialTheme.colorScheme.inversePrimary,
shape = MaterialTheme.shapes.extraLarge
)
.clip(shape = MaterialTheme.shapes.extraLarge)
Expand All @@ -46,7 +46,6 @@ fun RowScope.EnterKey(
Icon(
painter = painterResource(id = R.drawable.ic_baseline_keyboard_return_24),
contentDescription = "Enter key",
tint = MaterialTheme.colorScheme.onPrimaryContainer
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ fun RowScope.LanguageKey(
onLongClick = null,
modifier = Modifier
.background(
color = MaterialTheme.colorScheme.surface, shape = MaterialTheme.shapes.medium
color = MaterialTheme.colorScheme.surfaceContainerLowest,
shape = MaterialTheme.shapes.medium
)
.clip(shape = MaterialTheme.shapes.medium)
.weight(1f),
) {
Icon(
painter = painterResource(id = R.drawable.ic_baseline_language_24),
contentDescription = "Enter key",
tint = MaterialTheme.colorScheme.onSurface
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ fun RowScope.LayoutSwitchKey(
onClick = onClick,
modifier = Modifier
.background(
color = MaterialTheme.colorScheme.tertiaryContainer,
color = MaterialTheme.colorScheme.outlineVariant,
shape = MaterialTheme.shapes.extraLarge
)
.clip(shape = MaterialTheme.shapes.extraLarge)
.weight(1.5f),
) {
Text(
text = label,
color = MaterialTheme.colorScheme.onTertiaryContainer,
fontSize = 18.sp,
textAlign = TextAlign.Center
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.sp
import com.elliot00.liushu.input.keyboard.key.Key
Expand All @@ -50,8 +51,8 @@ fun RowScope.PunctuationKey(
) {
Text(
text = text,
color = MaterialTheme.colorScheme.onSecondaryContainer,
fontSize = 28.sp,
fontSize = 26.sp,
fontFamily = FontFamily.Monospace,
textAlign = TextAlign.Center
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ import com.elliot00.liushu.input.keyboard.key.BaseKey

@Composable
fun RowScope.ShiftKey(
onClick: () -> Unit
onClick: () -> Unit,
onLongClick: () -> Unit,
) {

BaseKey(
onClick = onClick,
onLongClick = onLongClick,
modifier = Modifier
.background(
color = MaterialTheme.colorScheme.secondaryContainer,
Expand All @@ -46,7 +48,6 @@ fun RowScope.ShiftKey(
Icon(
painter = painterResource(id = R.drawable.ic_capslock_none),
contentDescription = "Shift key",
tint = MaterialTheme.colorScheme.onSecondaryContainer
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.sp
import com.elliot00.liushu.input.keyboard.key.BaseKey
Expand All @@ -37,16 +38,16 @@ fun RowScope.SpaceKey(
onClick = onClick,
modifier = Modifier
.background(
color = MaterialTheme.colorScheme.surface,
color = MaterialTheme.colorScheme.surfaceContainerLowest,
shape = MaterialTheme.shapes.medium
)
.clip(shape = MaterialTheme.shapes.medium)
.weight(weight),
) {
Text(
text = "⎵",
color = MaterialTheme.colorScheme.onSurface,
fontSize = 28.sp,
fontSize = 26.sp,
fontFamily = FontFamily.Monospace,
textAlign = TextAlign.Center
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ fun QwertyKeyboardLayout(
Box(modifier = Modifier.weight(0.5f))
}
KeyboardRow {
ShiftKey(onClick = { onAction(InputMethodAction.Shift) })
ShiftKey(
onClick = { onAction(InputMethodAction.Shift) },
onLongClick = { onAction(InputMethodAction.CapsLock) })
AlphabetKey(
label = VariantKeyLabel(text = "z", textInCapsLock = "Z"),
isAsciiMode = isAsciiMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ class LiushuInputMethodService : LifecycleInputMethodService(), SavedStateRegist
private fun handleEnter() {
if (_state.value.input.isNotEmpty()) {
commitText(_state.value.input)
_state.update {
it.copy(
input = "",
segmentedTokens = emptyList(),
candidates = emptyList()
)
}
} else {
val inputType = currentInputEditorInfo.inputType
if ((inputType and InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0) {
Expand Down