(ui): Optimize layout and FABs for Android landscape orientation
This commit is contained in:
parent
f3b5ec4a91
commit
089a27767b
5 changed files with 1577 additions and 1089 deletions
|
|
@ -15,6 +15,7 @@ import androidx.activity.compose.setContent
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
|
|
@ -112,8 +113,7 @@ class MainActivity : ComponentActivity() {
|
||||||
|
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
if (isFullScreen) {
|
if (isFullScreen) {
|
||||||
windowInsetsController.hide(WindowInsetsCompat.Type.navigationBars())
|
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
|
||||||
windowInsetsController.show(WindowInsetsCompat.Type.statusBars())
|
|
||||||
windowInsetsController.systemBarsBehavior =
|
windowInsetsController.systemBarsBehavior =
|
||||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ fun TUODetailDialog(
|
||||||
|
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
keyboardState.isDialogActive = true
|
keyboardState.isDialogActive = true
|
||||||
|
keyboardState.dialogPosition = menuPosition
|
||||||
onDispose {
|
onDispose {
|
||||||
keyboardState.hide()
|
keyboardState.hide()
|
||||||
keyboardState.isDialogActive = false
|
keyboardState.isDialogActive = false
|
||||||
|
|
@ -201,6 +202,12 @@ fun TUODetailDialog(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isEditMode by sharedScreenModel.modeEditor.collectAsState()
|
||||||
|
LaunchedEffect(isEditMode) {
|
||||||
|
if (!isEditMode) {
|
||||||
|
onDismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Popup(
|
Popup(
|
||||||
offset = menuPosition,
|
offset = menuPosition,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,9 @@ fun CustomKeyboard(
|
||||||
onDeleteClick: () -> Unit,
|
onDeleteClick: () -> Unit,
|
||||||
onClearClick: () -> Unit,
|
onClearClick: () -> Unit,
|
||||||
onPrefixClick: (String) -> Unit,
|
onPrefixClick: (String) -> Unit,
|
||||||
|
onToggleKeyboardClick: () -> Unit,
|
||||||
isFullScreen: Boolean,
|
isFullScreen: Boolean,
|
||||||
|
isAndroidLandscape: Boolean,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
Surface(
|
Surface(
|
||||||
|
|
@ -46,6 +48,7 @@ fun CustomKeyboard(
|
||||||
),
|
),
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
) {
|
) {
|
||||||
|
val keyboardButtonHeight = if (isAndroidLandscape) 35.dp else 44.dp
|
||||||
val prefixes = listOf("EWS", "FFPM", "FF", "Antema", "Tsanta", "Salamo")
|
val prefixes = listOf("EWS", "FFPM", "FF", "Antema", "Tsanta", "Salamo")
|
||||||
LazyRow(
|
LazyRow(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
|
@ -55,7 +58,7 @@ fun CustomKeyboard(
|
||||||
items(prefixes) { prefix ->
|
items(prefixes) { prefix ->
|
||||||
Button(
|
Button(
|
||||||
onClick = { onPrefixClick("$prefix ") },
|
onClick = { onPrefixClick("$prefix ") },
|
||||||
modifier = Modifier.height(38.dp),
|
modifier = Modifier.height(keyboardButtonHeight-6.dp),
|
||||||
shape = RoundedCornerShape(10.dp),
|
shape = RoundedCornerShape(10.dp),
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(
|
||||||
containerColor = MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.15f),
|
containerColor = MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.15f),
|
||||||
|
|
@ -85,35 +88,83 @@ fun CustomKeyboard(
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
) {
|
) {
|
||||||
for (key in row) {
|
for (key in row) {
|
||||||
val isActionKey = key == "⌫" || key == "↓"
|
if (key == "⌫") {
|
||||||
Button(
|
Row(
|
||||||
onClick = {
|
modifier = Modifier.weight(1f),
|
||||||
when (key) {
|
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
"⌫" -> onDeleteClick()
|
) {
|
||||||
"↓" -> onClearClick()
|
Button(
|
||||||
else -> onDigitClick(key)
|
onClick = onDeleteClick,
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.height(keyboardButtonHeight),
|
||||||
|
shape = RoundedCornerShape(10.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.errorContainer.copy(alpha = 0.6f),
|
||||||
|
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||||
|
),
|
||||||
|
contentPadding = PaddingValues(0.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "⌫",
|
||||||
|
fontSize = MaterialTheme.typography.headlineMedium.fontSize,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
maxLines = 1,
|
||||||
|
softWrap = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
Button(
|
||||||
modifier = Modifier
|
onClick = onToggleKeyboardClick,
|
||||||
.weight(1f)
|
modifier = Modifier
|
||||||
.height(44.dp),
|
.weight(1f)
|
||||||
shape = RoundedCornerShape(10.dp),
|
.height(keyboardButtonHeight),
|
||||||
colors = ButtonDefaults.buttonColors(
|
shape = RoundedCornerShape(10.dp),
|
||||||
containerColor = if (isActionKey)
|
colors = ButtonDefaults.buttonColors(
|
||||||
MaterialTheme.colorScheme.errorContainer.copy(alpha = 0.6f)
|
containerColor = MaterialTheme.colorScheme.tertiary,
|
||||||
else
|
contentColor = MaterialTheme.colorScheme.onTertiary
|
||||||
MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.2f),
|
),
|
||||||
contentColor = if (isActionKey)
|
contentPadding = PaddingValues(0.dp)
|
||||||
MaterialTheme.colorScheme.onErrorContainer
|
) {
|
||||||
else
|
Text(
|
||||||
Color.White
|
text = "ABC",
|
||||||
)
|
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
||||||
) {
|
fontWeight = FontWeight.Bold,
|
||||||
Text(
|
maxLines = 1,
|
||||||
text = key,
|
softWrap = false
|
||||||
fontSize = MaterialTheme.typography.headlineLarge.fontSize,
|
)
|
||||||
fontWeight = FontWeight.Bold
|
}
|
||||||
)
|
}
|
||||||
|
} else {
|
||||||
|
val isActionKey = key == "↓"
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
when (key) {
|
||||||
|
"⌫" -> onDeleteClick()
|
||||||
|
"↓" -> onClearClick()
|
||||||
|
else -> onDigitClick(key)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.height(keyboardButtonHeight),
|
||||||
|
shape = RoundedCornerShape(10.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
containerColor = if (isActionKey)
|
||||||
|
MaterialTheme.colorScheme.errorContainer.copy(alpha = 0.6f)
|
||||||
|
else
|
||||||
|
MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.2f),
|
||||||
|
contentColor = if (isActionKey)
|
||||||
|
MaterialTheme.colorScheme.onErrorContainer
|
||||||
|
else
|
||||||
|
Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = key,
|
||||||
|
fontSize = if(isAndroidLandscape) MaterialTheme.typography.labelLarge.fontSize else MaterialTheme.typography.headlineLarge.fontSize,
|
||||||
|
fontWeight = FontWeight.Bold
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -18,8 +18,10 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.IntOffset
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import mg.dot.feufaro.provideSettings
|
||||||
import mg.dot.feufaro.solfa.Transpose
|
import mg.dot.feufaro.solfa.Transpose
|
||||||
|
|
||||||
enum class OctaveMode {
|
enum class OctaveMode {
|
||||||
|
|
@ -29,6 +31,7 @@ val SOLFA_NOTES = Transpose.noteToNumber
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SolfaKeyboard(
|
fun SolfaKeyboard(
|
||||||
|
isAndroidLandscape: Boolean,
|
||||||
currentVoiceIndex: Int,
|
currentVoiceIndex: Int,
|
||||||
currentValue: String = "",
|
currentValue: String = "",
|
||||||
onNoteClick: (String) -> Unit,
|
onNoteClick: (String) -> Unit,
|
||||||
|
|
@ -39,7 +42,7 @@ fun SolfaKeyboard(
|
||||||
onCustomSymbolClick: (String) -> Unit,
|
onCustomSymbolClick: (String) -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
var selectedOctave by remember { mutableStateOf("") }
|
val selectedOctave by remember { mutableStateOf("") }
|
||||||
val voiceLabels = listOf("S", "A", "T", "B")
|
val voiceLabels = listOf("S", "A", "T", "B")
|
||||||
|
|
||||||
Surface(
|
Surface(
|
||||||
|
|
@ -49,6 +52,7 @@ fun SolfaKeyboard(
|
||||||
color = Color(0xFF232323),
|
color = Color(0xFF232323),
|
||||||
tonalElevation = 8.dp
|
tonalElevation = 8.dp
|
||||||
) {
|
) {
|
||||||
|
val firstLineKeyboardheight = if(isAndroidLandscape) 25.dp else 36.dp
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(6.dp)
|
.padding(6.dp)
|
||||||
|
|
@ -69,7 +73,7 @@ fun SolfaKeyboard(
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primary),
|
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primary),
|
||||||
shape = RoundedCornerShape(4.dp),
|
shape = RoundedCornerShape(4.dp),
|
||||||
contentPadding = PaddingValues(horizontal = 6.dp, vertical = 2.dp),
|
contentPadding = PaddingValues(horizontal = 6.dp, vertical = 2.dp),
|
||||||
modifier = Modifier.height(36.dp)
|
modifier = Modifier.height(firstLineKeyboardheight)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.AutoMirrored.Default.KeyboardTab,
|
imageVector = Icons.AutoMirrored.Default.KeyboardTab,
|
||||||
|
|
@ -95,30 +99,22 @@ fun SolfaKeyboard(
|
||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.weight(1.5f)
|
.weight(1.5f)
|
||||||
.height(36.dp)
|
.height(firstLineKeyboardheight)
|
||||||
.background(Color.Black.copy(alpha = 0.4f), RoundedCornerShape(4.dp))
|
.background(Color.Black.copy(alpha = 0.4f), RoundedCornerShape(4.dp))
|
||||||
.padding(horizontal = 8.dp, vertical = 8.dp)
|
.padding(horizontal = 8.dp, vertical = 8.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
OutlinedButton(
|
OutlinedButton(
|
||||||
onClick = {
|
onClick = { onNoteClick(",") },
|
||||||
onNoteClick(",")
|
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF383838)),
|
||||||
},
|
modifier = Modifier.height(firstLineKeyboardheight).weight(0.7f)
|
||||||
colors = ButtonDefaults.buttonColors(
|
|
||||||
containerColor = Color(0xFF383838)
|
|
||||||
),
|
|
||||||
modifier = Modifier.height(36.dp).weight(0.7f)
|
|
||||||
) {
|
) {
|
||||||
Text(",", fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
Text(",", fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
||||||
}
|
}
|
||||||
OutlinedButton(
|
OutlinedButton(
|
||||||
onClick = {
|
onClick = { onNoteClick("'") },
|
||||||
onNoteClick("'")
|
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF383838)),
|
||||||
},
|
modifier = Modifier.height(firstLineKeyboardheight)
|
||||||
colors = ButtonDefaults.buttonColors(
|
|
||||||
containerColor = Color(0xFF383838)
|
|
||||||
),
|
|
||||||
modifier = Modifier.height(36.dp)
|
|
||||||
) {
|
) {
|
||||||
Text("'", fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
Text("'", fontSize = 14.sp, fontWeight = FontWeight.Bold)
|
||||||
}
|
}
|
||||||
|
|
@ -129,12 +125,12 @@ fun SolfaKeyboard(
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
) {
|
) {
|
||||||
Spacer(modifier = Modifier.weight(0.5f))
|
Spacer(modifier = Modifier.weight(0.5f))
|
||||||
KeyButton("di", Modifier.weight(1f)) { onNoteClick("di") }
|
KeyButton("di", Modifier.weight(1f), isAndroidLandscape = isAndroidLandscape) { onNoteClick("di") }
|
||||||
KeyButton("ri", Modifier.weight(1f)) { onNoteClick("ri") }
|
KeyButton("ri", Modifier.weight(1f), isAndroidLandscape = isAndroidLandscape) { onNoteClick("ri") }
|
||||||
Spacer(modifier = Modifier.weight(1.3f))
|
Spacer(modifier = Modifier.weight(1.3f))
|
||||||
KeyButton("fi", Modifier.weight(1f)) { onNoteClick("fi") }
|
KeyButton("fi", Modifier.weight(1f), isAndroidLandscape = isAndroidLandscape) { onNoteClick("fi") }
|
||||||
KeyButton("si", Modifier.weight(1f)) { onNoteClick("si") }
|
KeyButton("si", Modifier.weight(1f), isAndroidLandscape = isAndroidLandscape) { onNoteClick("si") }
|
||||||
KeyButton("ta", Modifier.weight(1f)) { onNoteClick("ta") }
|
KeyButton("ta", Modifier.weight(1f), isAndroidLandscape = isAndroidLandscape) { onNoteClick("ta") }
|
||||||
Spacer(modifier = Modifier.weight(0.5f))
|
Spacer(modifier = Modifier.weight(0.5f))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,7 +140,7 @@ fun SolfaKeyboard(
|
||||||
) {
|
) {
|
||||||
val diatonicNotes = listOf("d", "r", "m", "f", "s", "l", "t")
|
val diatonicNotes = listOf("d", "r", "m", "f", "s", "l", "t")
|
||||||
for (note in diatonicNotes) {
|
for (note in diatonicNotes) {
|
||||||
KeyButton(note, Modifier.weight(1f)) { onNoteClick(note) }
|
KeyButton(note, Modifier.weight(1f), isAndroidLandscape = isAndroidLandscape) { onNoteClick(note) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,70 +148,51 @@ fun SolfaKeyboard(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
) {
|
) {
|
||||||
KeyButton("―", Modifier.weight(1f)) { onCustomSymbolClick("-") }
|
KeyButton("―", Modifier.weight(1f), isAndroidLandscape = isAndroidLandscape) { onCustomSymbolClick("-") }
|
||||||
KeyButton("• ,", Modifier.weight(1f)) { onCustomSymbolClick(";") }
|
KeyButton("• ,", Modifier.weight(1f), isAndroidLandscape = isAndroidLandscape) { onCustomSymbolClick(";") }
|
||||||
KeyButton("•", Modifier.weight(0.5f)) { onCustomSymbolClick(".") }
|
KeyButton("•", Modifier.weight(0.5f), isAndroidLandscape = isAndroidLandscape) { onCustomSymbolClick(".") }
|
||||||
KeyButton(",", Modifier.weight(0.5f)) { onCustomSymbolClick(" ,") }
|
KeyButton(",", Modifier.weight(0.5f), isAndroidLandscape = isAndroidLandscape) { onCustomSymbolClick(" ,") }
|
||||||
KeyButton("Espace", Modifier.weight(1.6f)) { onCustomSymbolClick(" ") }
|
KeyButton("Espace", Modifier.weight(1.6f), isAndroidLandscape = isAndroidLandscape) { onCustomSymbolClick(" ") }
|
||||||
KeyButton("(", Modifier.weight(0.6f)) { onCustomSymbolClick("(") }
|
KeyButton("(", Modifier.weight(0.6f), isAndroidLandscape = isAndroidLandscape) { onCustomSymbolClick("(") }
|
||||||
KeyButton(")", Modifier.weight(0.6f)) { onCustomSymbolClick(")") }
|
KeyButton(")", Modifier.weight(0.6f), isAndroidLandscape = isAndroidLandscape) { onCustomSymbolClick(")") }
|
||||||
KeyButton("<", Modifier.weight(0.5f)) { onCustomSymbolClick("<") }
|
KeyButton("<", Modifier.weight(0.5f), isAndroidLandscape = isAndroidLandscape) { onCustomSymbolClick("<") }
|
||||||
KeyButton(">", Modifier.weight(0.5f)) { onCustomSymbolClick(">") }
|
KeyButton(">", Modifier.weight(0.5f), isAndroidLandscape = isAndroidLandscape) { onCustomSymbolClick(">") }
|
||||||
KeyButton("z", Modifier.weight(1f)) { onNoteClick("z") }
|
KeyButton("z", Modifier.weight(1f), isAndroidLandscape = isAndroidLandscape) { onNoteClick("z") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier.width(48.dp),
|
||||||
.width(48.dp),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
) {
|
) {
|
||||||
Button(
|
Button(
|
||||||
onClick = onCloseClick,
|
onClick = onCloseClick,
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth().weight(1f),
|
||||||
.fillMaxWidth()
|
|
||||||
.weight(1f),
|
|
||||||
shape = RoundedCornerShape(4.dp),
|
shape = RoundedCornerShape(4.dp),
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.errorContainer),
|
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.errorContainer),
|
||||||
contentPadding = PaddingValues(0.dp)
|
contentPadding = PaddingValues(0.dp)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(imageVector = Icons.Default.Close, contentDescription = "Solfakey close", tint = MaterialTheme.colorScheme.onErrorContainer)
|
||||||
imageVector = Icons.Default.Close,
|
|
||||||
contentDescription = "Solfakey close",
|
|
||||||
tint = MaterialTheme.colorScheme.onErrorContainer
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(
|
Button(
|
||||||
onClick = onBackspaceClick,
|
onClick = onBackspaceClick,
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth().weight(1f),
|
||||||
.fillMaxWidth()
|
|
||||||
.weight(1f),
|
|
||||||
shape = RoundedCornerShape(4.dp),
|
shape = RoundedCornerShape(4.dp),
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF4A4A4A)),
|
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF4A4A4A)),
|
||||||
contentPadding = PaddingValues(0.dp)
|
contentPadding = PaddingValues(0.dp)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(imageVector = Icons.AutoMirrored.Default.KeyboardBackspace, contentDescription = "Solfakey backspace", tint = Color.White)
|
||||||
imageVector = Icons.AutoMirrored.Default.KeyboardBackspace,
|
|
||||||
contentDescription = "Solfakey backspace",
|
|
||||||
tint = Color.White
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(
|
Button(
|
||||||
onClick = onBuildClick,
|
onClick = onBuildClick,
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth().weight(1.2f),
|
||||||
.fillMaxWidth()
|
|
||||||
.weight(1.2f),
|
|
||||||
shape = RoundedCornerShape(4.dp),
|
shape = RoundedCornerShape(4.dp),
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primary),
|
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primary),
|
||||||
contentPadding = PaddingValues(0.dp)
|
contentPadding = PaddingValues(0.dp)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(imageVector = Icons.Default.Save, contentDescription = "Solfakey save", tint = Color.White)
|
||||||
imageVector = Icons.Default.Save,
|
|
||||||
contentDescription = "Solfakey save",
|
|
||||||
tint = Color.White
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -227,11 +204,13 @@ private fun KeyButton(
|
||||||
text: String,
|
text: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
containerColor: Color = Color(0xFF383838),
|
containerColor: Color = Color(0xFF383838),
|
||||||
|
isAndroidLandscape: Boolean,
|
||||||
onClick: () -> Unit
|
onClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
|
val keyboardHeight = if(isAndroidLandscape) 30.dp else 49.dp
|
||||||
Button(
|
Button(
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
modifier = modifier.height(49.dp),
|
modifier = modifier.height(keyboardHeight),
|
||||||
shape = RoundedCornerShape(4.dp),
|
shape = RoundedCornerShape(4.dp),
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = containerColor),
|
colors = ButtonDefaults.buttonColors(containerColor = containerColor),
|
||||||
contentPadding = PaddingValues(0.dp)
|
contentPadding = PaddingValues(0.dp)
|
||||||
|
|
@ -239,7 +218,7 @@ private fun KeyButton(
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text,
|
||||||
color = Color.White,
|
color = Color.White,
|
||||||
fontSize = 14.sp,
|
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
||||||
fontWeight = FontWeight.Bold
|
fontWeight = FontWeight.Bold
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -261,6 +240,24 @@ class SolfaKeyboardState {
|
||||||
var onCustomSymbol: ((String) -> Unit)? = null
|
var onCustomSymbol: ((String) -> Unit)? = null
|
||||||
var onTabNextVoice: (() -> Unit)? = null
|
var onTabNextVoice: (() -> Unit)? = null
|
||||||
var onMarker: (() -> Unit)? = null
|
var onMarker: (() -> Unit)? = null
|
||||||
|
var dialogPosition by mutableStateOf(IntOffset.Max)
|
||||||
|
|
||||||
|
var customOffset by mutableStateOf<androidx.compose.ui.unit.DpOffset?>(null)
|
||||||
|
private val prefs = provideSettings()
|
||||||
|
|
||||||
|
init {
|
||||||
|
val savedX = prefs.getFloat("solfa_keyboard_x", -1f)
|
||||||
|
val savedY = prefs.getFloat("solfa_keyboard_y", -1f)
|
||||||
|
if (savedX != -1f && savedY != -1f) {
|
||||||
|
customOffset = androidx.compose.ui.unit.DpOffset(savedX.dp, savedY.dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateCustomOffset(newOffset: androidx.compose.ui.unit.DpOffset) {
|
||||||
|
customOffset = newOffset
|
||||||
|
prefs.putFloat("solfa_keyboard_x", newOffset.x.value)
|
||||||
|
prefs.putFloat("solfa_keyboard_y", newOffset.y.value)
|
||||||
|
}
|
||||||
|
|
||||||
fun show(
|
fun show(
|
||||||
initialVoice: Int = 0,
|
initialVoice: Int = 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue