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/fix text command UI #70

Merged
merged 3 commits into from
Jun 1, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package jp.kaleidot725.adbpad.domain.usecase.refresh

import jp.kaleidot725.adbpad.domain.repository.EventRepository
import jp.kaleidot725.adbpad.domain.repository.NormalCommandRepository
import jp.kaleidot725.adbpad.domain.repository.ScreenshotCommandRepository
import jp.kaleidot725.adbpad.domain.repository.TextCommandRepository

class RefreshUseCase(
private val commandRepository: NormalCommandRepository,
private val screenshotCommandRepository: ScreenshotCommandRepository,
private val textCommandRepository: TextCommandRepository
private val textCommandRepository: TextCommandRepository,
) {
operator fun invoke() {
commandRepository.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import jp.kaleidot725.adbpad.domain.model.UserColor.getSplitterColor

@Composable
fun Modifier.selectedBackground(isSelected: Boolean): Modifier {
Expand All @@ -18,6 +19,6 @@ fun Modifier.selectedBackground(isSelected: Boolean): Modifier {
}

@Composable
fun Modifier.selectorBorder(): Modifier {
return this.border(shape = RoundedCornerShape(8.dp), color = MaterialTheme.colors.primary, width = 1.dp)
fun Modifier.defaultBorder(): Modifier {
return this.border(shape = RoundedCornerShape(8.dp), color = getSplitterColor(), width = 1.dp)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

@Composable
fun RunningIndicator() {
fun RunningIndicator(color: Color = MaterialTheme.colors.onPrimary) {
CircularProgressIndicator(
color = MaterialTheme.colors.onPrimary,
color = color,
strokeWidth = 2.dp,
modifier = Modifier.size(20.dp),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.compose.ui.unit.dp
import jp.kaleidot725.adbpad.domain.model.device.Device
import jp.kaleidot725.adbpad.domain.model.device.DeviceState
import jp.kaleidot725.adbpad.domain.model.language.Language
import jp.kaleidot725.adbpad.view.common.resource.selectorBorder
import jp.kaleidot725.adbpad.view.common.resource.defaultBorder

@Composable
fun DeviceSelector(
Expand All @@ -27,7 +27,7 @@ fun DeviceSelector(
Box(
modifier =
Modifier
.selectorBorder()
.defaultBorder()
.padding(vertical = 8.dp, horizontal = 16.dp),
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import jp.kaleidot725.adbpad.domain.model.language.Language
import jp.kaleidot725.adbpad.view.common.resource.selectorBorder
import jp.kaleidot725.adbpad.view.common.resource.defaultBorder

@Composable
fun LanguageDropButton(
Expand All @@ -37,7 +37,7 @@ fun LanguageDropButton(
modifier =
Modifier
.width(200.dp)
.selectorBorder()
.defaultBorder()
.clickable { expanded = true }
.padding(vertical = 8.dp, horizontal = 12.dp),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,31 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.material.Button
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.KeyboardTab
import androidx.compose.material.icons.automirrored.filled.Send
import androidx.compose.material.icons.filled.KeyboardTab
import androidx.compose.material.icons.filled.Save
import androidx.compose.material.icons.filled.Send
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import jp.kaleidot725.adbpad.domain.model.language.Language
import androidx.compose.ui.unit.sp
import jp.kaleidot725.adbpad.view.common.resource.defaultBorder
import jp.kaleidot725.adbpad.view.component.RunningIndicator

@Composable
Expand All @@ -30,57 +46,71 @@ fun InputTextActionMenu(
canSave: Boolean,
modifier: Modifier = Modifier,
) {
var text by remember { mutableStateOf(inputText) }
Row(
modifier = modifier,
modifier =
modifier
.clip(RoundedCornerShape(4.dp))
.defaultBorder()
.padding(horizontal = 12.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
OutlinedTextField(
value = inputText,
onValueChange = { onTextChange(it) },
BasicTextField(
value = text,
onValueChange = {
text = it
onTextChange(it)
},
cursorBrush = SolidColor(MaterialTheme.colors.onBackground),
textStyle =
TextStyle(
fontSize = 20.sp,
color = MaterialTheme.colors.onBackground,
),
modifier =
Modifier
.weight(0.9f, true)
.fillMaxHeight(),
.align(Alignment.CenterVertically),
)

Button(
IconButton(
enabled = canSave,
onClick = { onSave() },
modifier = Modifier.fillMaxHeight().width(85.dp),
modifier = Modifier.fillMaxHeight(),
) {
Text(
text = Language.save,
textAlign = TextAlign.Center,
Icon(
imageVector = Icons.Default.Save,
contentDescription = "Save",
)
}

Button(
IconButton(
enabled = canSendTab,
onClick = { onSendTab() },
modifier = Modifier.fillMaxHeight().width(85.dp),
modifier = Modifier.fillMaxHeight(),
) {
when (isSendingTag) {
true -> RunningIndicator()
true -> RunningIndicator(color = MaterialTheme.colors.primary)
else -> {
Text(
text = Language.tab,
textAlign = TextAlign.Center,
Icon(
imageVector = Icons.AutoMirrored.Default.KeyboardTab,
contentDescription = "Save",
)
}
}
}

Button(
IconButton(
enabled = canSend,
onClick = { onSend() },
modifier = Modifier.fillMaxHeight().width(85.dp),
modifier = Modifier.fillMaxHeight(),
) {
when (isSending) {
true -> RunningIndicator()
true -> RunningIndicator(color = MaterialTheme.colors.primary)
else -> {
Text(
text = Language.send,
textAlign = TextAlign.Center,
Icon(
imageVector = Icons.AutoMirrored.Default.Send,
contentDescription = "Save",
)
}
}
Expand Down
Loading