-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement NumericKeyboard and SymbolicKeyboard
- Loading branch information
1 parent
98c127e
commit dd48b1a
Showing
5 changed files
with
206 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
app/src/main/java/org/jyutping/jyutping/keyboard/NumericKeyboard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package org.jyutping.jyutping.keyboard | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import org.jyutping.jyutping.JyutpingInputMethodService | ||
import org.jyutping.jyutping.presets.PresetColor | ||
import org.jyutping.jyutping.presets.PresetConstant | ||
|
||
@Composable | ||
fun NumericKeyboard(keyHeight: Dp) { | ||
val context = LocalContext.current as JyutpingInputMethodService | ||
val isDarkMode = remember { context.isDarkMode } | ||
Column( | ||
modifier = Modifier | ||
.background(if (isDarkMode.value) PresetColor.keyboardDarkBackground else PresetColor.keyboardLightBackground) | ||
.fillMaxWidth() | ||
) { | ||
Box( | ||
modifier = Modifier | ||
.height(PresetConstant.ToolBarHeight.dp) | ||
.fillMaxWidth(), | ||
contentAlignment = Alignment.Center | ||
) { | ||
if (isDarkMode.value) PresetColor.keyboardDarkBackground else PresetColor.keyboardLightBackground | ||
ToolBar() | ||
} | ||
Row( | ||
modifier = Modifier | ||
.height(keyHeight) | ||
.fillMaxWidth() | ||
) { | ||
SymbolKey(symbol = "1", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "2", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "3", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "4", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "5", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "6", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "7", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "8", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "9", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "0", modifier = Modifier.weight(1f)) | ||
} | ||
Row( | ||
modifier = Modifier | ||
.height(keyHeight) | ||
.fillMaxWidth() | ||
) { | ||
SymbolKey(symbol = "-", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "/", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = ":", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = ";", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "(", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = ")", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "$", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "&", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "@", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "\"", modifier = Modifier.weight(1f)) | ||
} | ||
Row( | ||
modifier = Modifier | ||
.height(keyHeight) | ||
.fillMaxWidth() | ||
) { | ||
TransformKey(destination = KeyboardForm.Symbolic, modifier = Modifier.weight(1.3f)) | ||
Spacer(modifier = Modifier.weight(0.22f)) | ||
SymbolKey(symbol = ".", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = ",", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = "?", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = "!", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = "*", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = "'", modifier = Modifier.weight(1.16f)) | ||
Spacer(modifier = Modifier.weight(0.22f)) | ||
BackspaceKey(modifier = Modifier.weight(1.3f)) | ||
} | ||
Row( | ||
modifier = Modifier | ||
.height(keyHeight) | ||
.fillMaxWidth() | ||
) { | ||
TransformKey(destination = KeyboardForm.Alphabetic, modifier = Modifier.weight(2f)) | ||
LeftKey(modifier = Modifier.weight(1f)) | ||
SpaceKey(modifier = Modifier.weight(4f)) | ||
RightKey(modifier = Modifier.weight(1f)) | ||
ReturnKey(modifier = Modifier.weight(2f)) | ||
} | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
app/src/main/java/org/jyutping/jyutping/keyboard/SymbolicKeyboard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package org.jyutping.jyutping.keyboard | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import org.jyutping.jyutping.JyutpingInputMethodService | ||
import org.jyutping.jyutping.presets.PresetColor | ||
import org.jyutping.jyutping.presets.PresetConstant | ||
|
||
@Composable | ||
fun SymbolicKeyboard(keyHeight: Dp) { | ||
val context = LocalContext.current as JyutpingInputMethodService | ||
val isDarkMode = remember { context.isDarkMode } | ||
Column( | ||
modifier = Modifier | ||
.background(if (isDarkMode.value) PresetColor.keyboardDarkBackground else PresetColor.keyboardLightBackground) | ||
.fillMaxWidth() | ||
) { | ||
Box( | ||
modifier = Modifier | ||
.height(PresetConstant.ToolBarHeight.dp) | ||
.fillMaxWidth(), | ||
contentAlignment = Alignment.Center | ||
) { | ||
if (isDarkMode.value) PresetColor.keyboardDarkBackground else PresetColor.keyboardLightBackground | ||
ToolBar() | ||
} | ||
Row( | ||
modifier = Modifier | ||
.height(keyHeight) | ||
.fillMaxWidth() | ||
) { | ||
SymbolKey(symbol = "[", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "]", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "{", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "}", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "#", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "%", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "^", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "*", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "+", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "=", modifier = Modifier.weight(1f)) | ||
} | ||
Row( | ||
modifier = Modifier | ||
.height(keyHeight) | ||
.fillMaxWidth() | ||
) { | ||
SymbolKey(symbol = "_", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "\\", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "|", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "~", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "<", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = ">", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "€", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "£", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "¥", modifier = Modifier.weight(1f)) | ||
SymbolKey(symbol = "•", modifier = Modifier.weight(1f)) | ||
} | ||
Row( | ||
modifier = Modifier | ||
.height(keyHeight) | ||
.fillMaxWidth() | ||
) { | ||
TransformKey(destination = KeyboardForm.Numeric, modifier = Modifier.weight(1.3f)) | ||
Spacer(modifier = Modifier.weight(0.22f)) | ||
SymbolKey(symbol = ".", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = ",", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = "?", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = "!", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = "&", modifier = Modifier.weight(1.16f)) | ||
SymbolKey(symbol = "'", modifier = Modifier.weight(1.16f)) | ||
Spacer(modifier = Modifier.weight(0.22f)) | ||
BackspaceKey(modifier = Modifier.weight(1.3f)) | ||
} | ||
Row( | ||
modifier = Modifier | ||
.height(keyHeight) | ||
.fillMaxWidth() | ||
) { | ||
TransformKey(destination = KeyboardForm.Alphabetic, modifier = Modifier.weight(2f)) | ||
LeftKey(modifier = Modifier.weight(1f)) | ||
SpaceKey(modifier = Modifier.weight(4f)) | ||
RightKey(modifier = Modifier.weight(1f)) | ||
ReturnKey(modifier = Modifier.weight(2f)) | ||
} | ||
} | ||
} |