Added option to refresh repository
This commit is contained in:
parent
93a1ef3240
commit
a3f233d363
@ -21,10 +21,7 @@ import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import app.theme.primaryTextColor
|
||||
import app.ui.context_menu.DropDownContent
|
||||
import app.ui.context_menu.DropDownContentData
|
||||
import app.ui.context_menu.pullContextMenuItems
|
||||
import app.ui.context_menu.pushContextMenuItems
|
||||
import app.ui.context_menu.*
|
||||
import app.viewmodels.MenuViewModel
|
||||
|
||||
// TODO Add tooltips to all the buttons
|
||||
@ -34,6 +31,8 @@ fun Menu(
|
||||
onRepositoryOpen: () -> Unit,
|
||||
onCreateBranch: () -> Unit,
|
||||
) {
|
||||
var showAdditionalOptionsDropDownMenu by remember { mutableStateOf(false) }
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(vertical = 4.dp)
|
||||
@ -93,6 +92,7 @@ fun Menu(
|
||||
icon = painterResource("stash.svg"),
|
||||
onClick = { menuViewModel.stash() },
|
||||
)
|
||||
|
||||
MenuButton(
|
||||
title = "Pop",
|
||||
icon = painterResource("apply_stash.svg"),
|
||||
@ -101,11 +101,33 @@ fun Menu(
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
IconMenuButton(
|
||||
modifier = Modifier.padding(end = 8.dp),
|
||||
icon = painterResource("source.svg"),
|
||||
onClick = { menuViewModel.openFolderInFileExplorer() },
|
||||
)
|
||||
Box {
|
||||
IconMenuButton(
|
||||
modifier = Modifier.padding(end = 8.dp),
|
||||
icon = painterResource("more_vert.svg"),
|
||||
onClick = {
|
||||
showAdditionalOptionsDropDownMenu = true
|
||||
},
|
||||
)
|
||||
DropdownMenu(
|
||||
expanded = showAdditionalOptionsDropDownMenu,
|
||||
content = {
|
||||
val menuOptions = remember {
|
||||
repositoryAdditionalOptionsMenu(
|
||||
onOpenRepositoryOnFileExplorer = { menuViewModel.openFolderInFileExplorer() },
|
||||
onForceRepositoryRefresh = { menuViewModel.refresh() },
|
||||
)
|
||||
}
|
||||
for (item in menuOptions) {
|
||||
DropDownContent(
|
||||
dropDownContentData = item,
|
||||
onDismiss = { showAdditionalOptionsDropDownMenu = false }
|
||||
)
|
||||
}
|
||||
},
|
||||
onDismissRequest = { showAdditionalOptionsDropDownMenu = false }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,9 +262,8 @@ fun IconMenuButton(
|
||||
MaterialTheme.colors.secondaryVariant
|
||||
}
|
||||
|
||||
OutlinedButton(
|
||||
modifier = modifier
|
||||
.padding(horizontal = 2.dp),
|
||||
IconButton(
|
||||
modifier = modifier,
|
||||
enabled = enabled,
|
||||
onClick = onClick,
|
||||
) {
|
||||
|
@ -1,10 +1,15 @@
|
||||
package app.ui.context_menu
|
||||
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.DropdownMenuItem
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
@Composable
|
||||
@ -20,12 +25,23 @@ fun DropDownContent(
|
||||
onDismiss()
|
||||
}
|
||||
) {
|
||||
Row {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
if (dropDownContentData.icon != null) {
|
||||
Icon(imageVector = dropDownContentData.icon, contentDescription = null)
|
||||
Icon(
|
||||
painter = painterResource(dropDownContentData.icon),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.padding(end = 8.dp),
|
||||
)
|
||||
}
|
||||
|
||||
Text(dropDownContentData.label, fontSize = 14.sp)
|
||||
Text(
|
||||
text = dropDownContentData.label,
|
||||
fontSize = 13.sp,
|
||||
modifier = Modifier.padding(end = 8.dp),
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package app.ui.context_menu
|
||||
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
|
||||
data class DropDownContentData(
|
||||
val label: String,
|
||||
val icon: ImageVector? = null,
|
||||
val icon: String? = null,
|
||||
val onClick: () -> Unit,
|
||||
)
|
||||
|
@ -0,0 +1,22 @@
|
||||
package app.ui.context_menu
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
fun repositoryAdditionalOptionsMenu(
|
||||
onOpenRepositoryOnFileExplorer: () -> Unit,
|
||||
onForceRepositoryRefresh: () -> Unit,
|
||||
): List<DropDownContentData> {
|
||||
return mutableListOf(
|
||||
DropDownContentData(
|
||||
label = "Open repository folder",
|
||||
icon = "source.svg",
|
||||
onClick = onOpenRepositoryOnFileExplorer,
|
||||
),
|
||||
DropDownContentData(
|
||||
label = "Refresh repository",
|
||||
icon = "refresh.svg",
|
||||
onClick = onForceRepositoryRefresh,
|
||||
),
|
||||
)
|
||||
}
|
@ -51,4 +51,10 @@ class MenuViewModel @Inject constructor(
|
||||
) { git ->
|
||||
Desktop.getDesktop().open(git.repository.directory.parentFile)
|
||||
}
|
||||
|
||||
fun refresh() = tabState.safeProcessing(
|
||||
refreshType = RefreshType.ALL_DATA,
|
||||
){
|
||||
// Nothing to do here
|
||||
}
|
||||
}
|
1
src/main/resources/more_vert.svg
Normal file
1
src/main/resources/more_vert.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/></svg>
|
After Width: | Height: | Size: 302 B |
1
src/main/resources/refresh.svg
Normal file
1
src/main/resources/refresh.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>
|
After Width: | Height: | Size: 359 B |
Loading…
Reference in New Issue
Block a user