Improved rebase interactive design

This commit is contained in:
Abdelilah El Aissaoui 2022-06-23 19:28:21 +02:00
parent 17c0f50360
commit 32fae01e6e
3 changed files with 33 additions and 33 deletions

View File

@ -1,6 +1,5 @@
package app.ui.dialogs
package app.ui
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.items
@ -8,12 +7,11 @@ import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import app.theme.outlinedTextFieldColors
import app.theme.primaryTextColor
import app.theme.textButtonColors
import app.ui.components.AdjustableOutlinedTextField
import app.ui.components.PrimaryButton
import app.ui.components.ScrollableLazyColumn
import app.viewmodels.RebaseInteractiveState
@ -21,7 +19,6 @@ import app.viewmodels.RebaseInteractiveViewModel
import org.eclipse.jgit.lib.RebaseTodoLine
import org.eclipse.jgit.lib.RebaseTodoLine.Action
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun RebaseInteractive(
rebaseInteractiveViewModel: RebaseInteractiveViewModel,
@ -58,17 +55,19 @@ fun RebaseStateLoaded(
rebaseState: RebaseInteractiveState.Loaded,
onCancel: () -> Unit,
) {
val stepsList = rebaseState.stepsList
Column(
modifier = Modifier.fillMaxSize()
) {
Text(
text = "Rebase interactive",
color = MaterialTheme.colors.primaryTextColor,
modifier = Modifier.padding(all = 20.dp)
modifier = Modifier.padding(start = 16.dp, top = 16.dp),
fontSize = 20.sp,
)
ScrollableLazyColumn(modifier = Modifier.weight(1f)) {
val stepsList = rebaseState.stepsList
items(stepsList) { rebaseTodoLine ->
RebaseCommit(
rebaseLine = rebaseTodoLine,
@ -84,7 +83,7 @@ fun RebaseStateLoaded(
}
}
Row {
Row (modifier = Modifier.padding(bottom = 16.dp)) {
Spacer(modifier = Modifier.weight(1f))
TextButton(
modifier = Modifier.padding(end = 8.dp),
@ -97,6 +96,7 @@ fun RebaseStateLoaded(
}
PrimaryButton(
modifier = Modifier.padding(end = 16.dp),
enabled = stepsList.any { it.action != Action.PICK },
onClick = {
rebaseInteractiveViewModel.continueRebaseInteractive()
},
@ -120,11 +120,12 @@ fun RebaseCommit(
mutableStateOf(message ?: rebaseLine.shortMessage) /* if reword, use the value from the map (if possible)*/
} else
mutableStateOf(rebaseLine.shortMessage) // If it's not reword, use the original shortMessage
}
Row(
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
.height(IntrinsicSize.Min)
) {
ActionDropdown(
rebaseLine.action,
@ -132,18 +133,17 @@ fun RebaseCommit(
onActionChanged = onActionChanged,
)
OutlinedTextField(
AdjustableOutlinedTextField(
modifier = Modifier
.weight(1f)
.heightIn(min = 48.dp),
.height(40.dp),
enabled = rebaseLine.action == Action.REWORD,
value = newMessage,
onValueChange = {
newMessage = it
onMessageChanged(it)
},
colors = outlinedTextFieldColors(),
textStyle = TextStyle.Default.copy(fontSize = 14.sp, color = MaterialTheme.colors.primaryTextColor),
textStyle = LocalTextStyle.current.copy(fontSize = 12.sp),
)
}
@ -162,10 +162,11 @@ fun ActionDropdown(
onClick = { showDropDownMenu = true },
modifier = Modifier
.width(120.dp)
.height(48.dp)
.height(40.dp)
.padding(end = 8.dp),
text = action.toToken()
text = action.toToken().replaceFirstChar { it.uppercase() }
)
DropdownMenu(
expanded = showDropDownMenu,
onDismissRequest = { showDropDownMenu = false },
@ -183,7 +184,10 @@ fun ActionDropdown(
onActionChanged(dropDownOption)
}
) {
Text(dropDownOption.toToken())
Text(
text = dropDownOption.toToken().replaceFirstChar { it.uppercase() },
fontSize = 14.sp,
)
}
}
}

View File

@ -4,17 +4,14 @@ package app.ui
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import app.extensions.handMouseClickable
@ -22,7 +19,6 @@ import app.git.DiffEntryType
import app.theme.*
import app.ui.dialogs.AuthorDialog
import app.ui.dialogs.NewBranchDialog
import app.ui.dialogs.RebaseInteractive
import app.ui.dialogs.StashWithMessageDialog
import app.ui.log.Log
import app.viewmodels.BlameState
@ -83,12 +79,10 @@ fun RepositoryOpenPage(tabViewModel: TabViewModel) {
}
Column {
if (repositoryState == RepositoryState.REBASING_INTERACTIVE) {
val rebaseInteractiveViewModel = tabViewModel.rebaseInteractiveViewModel
if (rebaseInteractiveViewModel != null) {
if (repositoryState == RepositoryState.REBASING_INTERACTIVE && rebaseInteractiveViewModel != null) {
RebaseInteractive(rebaseInteractiveViewModel)
}
} else {
Column(modifier = Modifier.weight(1f)) {
Menu(

View File

@ -12,6 +12,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.text.TextStyle
@ -49,7 +50,7 @@ fun AdjustableOutlinedTextField(
keyboardOptions = keyboardOptions,
cursorBrush = SolidColor(cursorColor),
decorationBox = { innerTextField ->
Box (
Box(
modifier = Modifier
.border(
width = 1.dp,
@ -57,6 +58,7 @@ fun AdjustableOutlinedTextField(
shape = RoundedCornerShape(4.dp)
)
.padding(12.dp),
contentAlignment = Alignment.CenterStart,
) {
innerTextField()
}