Added new switch and adjusted surface color on light theme

This commit is contained in:
Abdelilah El Aissaoui 2023-07-15 13:21:19 +02:00
parent 38481b3a34
commit 1cf1eca45f
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
4 changed files with 69 additions and 11 deletions

View File

@ -59,7 +59,6 @@ class FileChangesWatcher @Inject constructor(
matchesAnyRule || isGitIgnoredFile
}
val hasGitDirChanged = paths.any { it.startsWith("$pathStr$systemSeparator.git%$systemSeparator") }
if (!areAllPathsIgnored) {

View File

@ -75,7 +75,6 @@ fun CommitChanges(
textScroll = textScroll,
searchFilter = searchFilter,
onDiffSelected = onDiffSelected,
onSearchFilterToggled = { visible ->
commitChangesViewModel.onSearchFilterToggled(visible)
},

View File

@ -0,0 +1,64 @@
package com.jetpackduba.gitnuro.ui.components
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.jetpackduba.gitnuro.extensions.handMouseClickable
@Preview
@Composable
fun SwitchPreview() {
AppSwitch(false, {})
}
@Composable
fun AppSwitch(
isChecked: Boolean,
onValueChanged: (Boolean) -> Unit,
) {
val background: Color
val startPadding: Dp
val uncheckedColor = Color(
red = (MaterialTheme.colors.onBackground.red + MaterialTheme.colors.primary.red) / 2,
green = (MaterialTheme.colors.onBackground.green + MaterialTheme.colors.primary.green) / 2,
blue = (MaterialTheme.colors.onBackground.blue + MaterialTheme.colors.primary.blue) / 2,
alpha = 0.4f
)
if (isChecked) {
background = MaterialTheme.colors.primary
startPadding = 24.dp
} else {
background = uncheckedColor
startPadding = 4.dp
}
Box(
modifier = Modifier
.width(48.dp)
.height(28.dp)
.clip(RoundedCornerShape(50))
.background(background)
.handMouseClickable { onValueChanged(!isChecked) }
.padding(top = 4.dp, bottom = 4.dp, end = 4.dp, start = startPadding),
contentAlignment = if (isChecked) Alignment.CenterEnd else Alignment.CenterStart,
) {
Box(
modifier = Modifier
.size(20.dp)
.clip(CircleShape)
.background(MaterialTheme.colors.onSecondary)
)
}
}

View File

@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.material.Switch
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -20,10 +21,7 @@ import com.jetpackduba.gitnuro.extensions.handOnHover
import com.jetpackduba.gitnuro.managers.Error
import com.jetpackduba.gitnuro.preferences.DEFAULT_UI_SCALE
import com.jetpackduba.gitnuro.theme.*
import com.jetpackduba.gitnuro.ui.components.AdjustableOutlinedTextField
import com.jetpackduba.gitnuro.ui.components.PrimaryButton
import com.jetpackduba.gitnuro.ui.components.ScrollableLazyColumn
import com.jetpackduba.gitnuro.ui.components.gitnuroViewModel
import com.jetpackduba.gitnuro.ui.components.*
import com.jetpackduba.gitnuro.ui.dialogs.ErrorDialog
import com.jetpackduba.gitnuro.ui.dialogs.MaterialDialog
import com.jetpackduba.gitnuro.ui.dropdowns.DropDownOption
@ -463,11 +461,9 @@ fun SettingToggle(
Spacer(modifier = Modifier.weight(1f))
Switch(
checked = value,
onCheckedChange = onValueChanged,
colors = SwitchDefaults.colors(uncheckedThumbColor = MaterialTheme.colors.secondary),
modifier = Modifier.handOnHover(),
AppSwitch(
isChecked = value,
onValueChanged = onValueChanged,
)
}
}