Fixed edit remotes dialog buttons
This commit is contained in:
parent
a0383b2781
commit
302376a23e
@ -11,7 +11,9 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.jetpackduba.gitnuro.extensions.backgroundIf
|
||||
import com.jetpackduba.gitnuro.extensions.handMouseClickable
|
||||
import com.jetpackduba.gitnuro.extensions.handOnHover
|
||||
|
||||
|
||||
@Composable
|
||||
@ -20,16 +22,22 @@ fun PrimaryButton(
|
||||
text: String,
|
||||
enabled: Boolean = true,
|
||||
backgroundColor: Color = MaterialTheme.colors.primary,
|
||||
backgroundDisabled: Color = MaterialTheme.colors.primary.copy(0.5f),
|
||||
textColor: Color = MaterialTheme.colors.onPrimary,
|
||||
disabledTextColor: Color = MaterialTheme.colors.onBackground,
|
||||
disabledTextColor: Color = MaterialTheme.colors.onPrimary.copy(alpha = 0.5f),
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.clip(RoundedCornerShape(4.dp))
|
||||
.background(backgroundColor)
|
||||
.handMouseClickable {
|
||||
onClick()
|
||||
.backgroundIf(enabled, backgroundColor, backgroundDisabled)
|
||||
.run {
|
||||
if(enabled) {
|
||||
handMouseClickable {
|
||||
onClick()
|
||||
}
|
||||
} else
|
||||
handOnHover()
|
||||
},
|
||||
) {
|
||||
Text(
|
||||
|
@ -105,7 +105,7 @@ fun AuthorDialog(
|
||||
text = "Cancel",
|
||||
modifier = Modifier.padding(end = 8.dp),
|
||||
onClick = onClose,
|
||||
backgroundColor = Color.Transparent
|
||||
backgroundColor = Color.Transparent,
|
||||
)
|
||||
PrimaryButton(
|
||||
onClick = {
|
||||
|
@ -10,6 +10,7 @@ import androidx.compose.material.icons.filled.Clear
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.jetpackduba.gitnuro.extensions.handMouseClickable
|
||||
@ -280,15 +281,15 @@ fun EditRemotesDialog(
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(top = 16.dp)
|
||||
.align(Alignment.End)
|
||||
.align(Alignment.End),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
if (!selectedRemote.isNew) {
|
||||
TextButton(
|
||||
PrimaryButton(
|
||||
text = "Discard changes",
|
||||
modifier = Modifier.padding(end = 8.dp),
|
||||
enabled = remoteChanged,
|
||||
colors = textButtonColors(),
|
||||
onClick = {
|
||||
remotesEditorData = remotesEditorData.copy(
|
||||
selectedRemote = selectedRemote.copy(
|
||||
@ -298,17 +299,13 @@ fun EditRemotesDialog(
|
||||
)
|
||||
|
||||
remoteChanged = false
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
"Discard changes",
|
||||
style = MaterialTheme.typography.body1,
|
||||
color = if (remoteChanged)
|
||||
MaterialTheme.colors.primaryVariant
|
||||
else
|
||||
MaterialTheme.colors.onBackground,
|
||||
)
|
||||
}
|
||||
},
|
||||
backgroundColor = Color.Transparent,
|
||||
backgroundDisabled = Color.Transparent,
|
||||
enabled = remoteChanged,
|
||||
textColor = MaterialTheme.colors.onBackground,
|
||||
disabledTextColor = MaterialTheme.colors.onBackground.copy(alpha = 0.5f),
|
||||
)
|
||||
}
|
||||
|
||||
val text = if (selectedRemote.isNew)
|
||||
|
Loading…
Reference in New Issue
Block a user