Improved rebase interactive design
This commit is contained in:
parent
17c0f50360
commit
32fae01e6e
@ -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.background
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
@ -8,12 +7,11 @@ import androidx.compose.material.*
|
|||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.TextStyle
|
|
||||||
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 app.theme.outlinedTextFieldColors
|
|
||||||
import app.theme.primaryTextColor
|
import app.theme.primaryTextColor
|
||||||
import app.theme.textButtonColors
|
import app.theme.textButtonColors
|
||||||
|
import app.ui.components.AdjustableOutlinedTextField
|
||||||
import app.ui.components.PrimaryButton
|
import app.ui.components.PrimaryButton
|
||||||
import app.ui.components.ScrollableLazyColumn
|
import app.ui.components.ScrollableLazyColumn
|
||||||
import app.viewmodels.RebaseInteractiveState
|
import app.viewmodels.RebaseInteractiveState
|
||||||
@ -21,7 +19,6 @@ import app.viewmodels.RebaseInteractiveViewModel
|
|||||||
import org.eclipse.jgit.lib.RebaseTodoLine
|
import org.eclipse.jgit.lib.RebaseTodoLine
|
||||||
import org.eclipse.jgit.lib.RebaseTodoLine.Action
|
import org.eclipse.jgit.lib.RebaseTodoLine.Action
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RebaseInteractive(
|
fun RebaseInteractive(
|
||||||
rebaseInteractiveViewModel: RebaseInteractiveViewModel,
|
rebaseInteractiveViewModel: RebaseInteractiveViewModel,
|
||||||
@ -58,17 +55,19 @@ fun RebaseStateLoaded(
|
|||||||
rebaseState: RebaseInteractiveState.Loaded,
|
rebaseState: RebaseInteractiveState.Loaded,
|
||||||
onCancel: () -> Unit,
|
onCancel: () -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val stepsList = rebaseState.stepsList
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "Rebase interactive",
|
text = "Rebase interactive",
|
||||||
color = MaterialTheme.colors.primaryTextColor,
|
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)) {
|
ScrollableLazyColumn(modifier = Modifier.weight(1f)) {
|
||||||
val stepsList = rebaseState.stepsList
|
|
||||||
items(stepsList) { rebaseTodoLine ->
|
items(stepsList) { rebaseTodoLine ->
|
||||||
RebaseCommit(
|
RebaseCommit(
|
||||||
rebaseLine = rebaseTodoLine,
|
rebaseLine = rebaseTodoLine,
|
||||||
@ -84,7 +83,7 @@ fun RebaseStateLoaded(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row (modifier = Modifier.padding(bottom = 16.dp)) {
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
TextButton(
|
TextButton(
|
||||||
modifier = Modifier.padding(end = 8.dp),
|
modifier = Modifier.padding(end = 8.dp),
|
||||||
@ -97,6 +96,7 @@ fun RebaseStateLoaded(
|
|||||||
}
|
}
|
||||||
PrimaryButton(
|
PrimaryButton(
|
||||||
modifier = Modifier.padding(end = 16.dp),
|
modifier = Modifier.padding(end = 16.dp),
|
||||||
|
enabled = stepsList.any { it.action != Action.PICK },
|
||||||
onClick = {
|
onClick = {
|
||||||
rebaseInteractiveViewModel.continueRebaseInteractive()
|
rebaseInteractiveViewModel.continueRebaseInteractive()
|
||||||
},
|
},
|
||||||
@ -120,11 +120,12 @@ fun RebaseCommit(
|
|||||||
mutableStateOf(message ?: rebaseLine.shortMessage) /* if reword, use the value from the map (if possible)*/
|
mutableStateOf(message ?: rebaseLine.shortMessage) /* if reword, use the value from the map (if possible)*/
|
||||||
} else
|
} else
|
||||||
mutableStateOf(rebaseLine.shortMessage) // If it's not reword, use the original shortMessage
|
mutableStateOf(rebaseLine.shortMessage) // If it's not reword, use the original shortMessage
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||||
|
.height(IntrinsicSize.Min)
|
||||||
) {
|
) {
|
||||||
ActionDropdown(
|
ActionDropdown(
|
||||||
rebaseLine.action,
|
rebaseLine.action,
|
||||||
@ -132,18 +133,17 @@ fun RebaseCommit(
|
|||||||
onActionChanged = onActionChanged,
|
onActionChanged = onActionChanged,
|
||||||
)
|
)
|
||||||
|
|
||||||
OutlinedTextField(
|
AdjustableOutlinedTextField(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
.heightIn(min = 48.dp),
|
.height(40.dp),
|
||||||
enabled = rebaseLine.action == Action.REWORD,
|
enabled = rebaseLine.action == Action.REWORD,
|
||||||
value = newMessage,
|
value = newMessage,
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
newMessage = it
|
newMessage = it
|
||||||
onMessageChanged(it)
|
onMessageChanged(it)
|
||||||
},
|
},
|
||||||
colors = outlinedTextFieldColors(),
|
textStyle = LocalTextStyle.current.copy(fontSize = 12.sp),
|
||||||
textStyle = TextStyle.Default.copy(fontSize = 14.sp, color = MaterialTheme.colors.primaryTextColor),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -162,10 +162,11 @@ fun ActionDropdown(
|
|||||||
onClick = { showDropDownMenu = true },
|
onClick = { showDropDownMenu = true },
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(120.dp)
|
.width(120.dp)
|
||||||
.height(48.dp)
|
.height(40.dp)
|
||||||
.padding(end = 8.dp),
|
.padding(end = 8.dp),
|
||||||
text = action.toToken()
|
text = action.toToken().replaceFirstChar { it.uppercase() }
|
||||||
)
|
)
|
||||||
|
|
||||||
DropdownMenu(
|
DropdownMenu(
|
||||||
expanded = showDropDownMenu,
|
expanded = showDropDownMenu,
|
||||||
onDismissRequest = { showDropDownMenu = false },
|
onDismissRequest = { showDropDownMenu = false },
|
||||||
@ -183,7 +184,10 @@ fun ActionDropdown(
|
|||||||
onActionChanged(dropDownOption)
|
onActionChanged(dropDownOption)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Text(dropDownOption.toToken())
|
Text(
|
||||||
|
text = dropDownOption.toToken().replaceFirstChar { it.uppercase() },
|
||||||
|
fontSize = 14.sp,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,14 @@ package app.ui
|
|||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.Button
|
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.material.TextButton
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.input.pointer.PointerIcon
|
import androidx.compose.ui.input.pointer.PointerIcon
|
||||||
import androidx.compose.ui.input.pointer.pointerHoverIcon
|
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.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import app.extensions.handMouseClickable
|
import app.extensions.handMouseClickable
|
||||||
@ -22,7 +19,6 @@ import app.git.DiffEntryType
|
|||||||
import app.theme.*
|
import app.theme.*
|
||||||
import app.ui.dialogs.AuthorDialog
|
import app.ui.dialogs.AuthorDialog
|
||||||
import app.ui.dialogs.NewBranchDialog
|
import app.ui.dialogs.NewBranchDialog
|
||||||
import app.ui.dialogs.RebaseInteractive
|
|
||||||
import app.ui.dialogs.StashWithMessageDialog
|
import app.ui.dialogs.StashWithMessageDialog
|
||||||
import app.ui.log.Log
|
import app.ui.log.Log
|
||||||
import app.viewmodels.BlameState
|
import app.viewmodels.BlameState
|
||||||
@ -83,12 +79,10 @@ fun RepositoryOpenPage(tabViewModel: TabViewModel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
if (repositoryState == RepositoryState.REBASING_INTERACTIVE) {
|
|
||||||
val rebaseInteractiveViewModel = tabViewModel.rebaseInteractiveViewModel
|
val rebaseInteractiveViewModel = tabViewModel.rebaseInteractiveViewModel
|
||||||
|
|
||||||
if (rebaseInteractiveViewModel != null) {
|
if (repositoryState == RepositoryState.REBASING_INTERACTIVE && rebaseInteractiveViewModel != null) {
|
||||||
RebaseInteractive(rebaseInteractiveViewModel)
|
RebaseInteractive(rebaseInteractiveViewModel)
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
Menu(
|
Menu(
|
||||||
|
@ -12,6 +12,7 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.graphics.SolidColor
|
import androidx.compose.ui.graphics.SolidColor
|
||||||
import androidx.compose.ui.graphics.takeOrElse
|
import androidx.compose.ui.graphics.takeOrElse
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
@ -57,6 +58,7 @@ fun AdjustableOutlinedTextField(
|
|||||||
shape = RoundedCornerShape(4.dp)
|
shape = RoundedCornerShape(4.dp)
|
||||||
)
|
)
|
||||||
.padding(12.dp),
|
.padding(12.dp),
|
||||||
|
contentAlignment = Alignment.CenterStart,
|
||||||
) {
|
) {
|
||||||
innerTextField()
|
innerTextField()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user