mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-02-19 21:30:41 +01:00
Make SmallButton
component for BrightDisplayButton
and StroboscopeButton
This commit is contained in:
parent
c59108e1ad
commit
b1b4c46dc3
@ -13,6 +13,7 @@ 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.graphics.painter.Painter
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
@ -116,18 +117,11 @@ internal fun FlashlightButton(
|
|||||||
internal fun BrightDisplayButton(
|
internal fun BrightDisplayButton(
|
||||||
onBrightDisplayPress: () -> Unit,
|
onBrightDisplayPress: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Icon(
|
SmallButton(
|
||||||
modifier = Modifier
|
|
||||||
.size(AppDimensions.smallerButtonSize)
|
|
||||||
.padding(vertical = SimpleTheme.dimens.margin.large)
|
|
||||||
.clickable(
|
|
||||||
indication = null,
|
|
||||||
interactionSource = rememberMutableInteractionSource(),
|
|
||||||
onClick = onBrightDisplayPress
|
|
||||||
),
|
|
||||||
painter = painterResource(id = R.drawable.ic_bright_display_vector),
|
painter = painterResource(id = R.drawable.ic_bright_display_vector),
|
||||||
contentDescription = stringResource(id = R.string.bright_display),
|
contentDescription = stringResource(id = R.string.bright_display),
|
||||||
tint = SimpleTheme.colorScheme.onSurface
|
isActive = false,
|
||||||
|
onPress = onBrightDisplayPress
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,18 +150,11 @@ internal fun StroboscopeButton(
|
|||||||
stroboscopeActive: Boolean,
|
stroboscopeActive: Boolean,
|
||||||
onStroboscopeButtonPress: () -> Unit,
|
onStroboscopeButtonPress: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Icon(
|
SmallButton(
|
||||||
modifier = Modifier
|
|
||||||
.size(AppDimensions.smallerButtonSize)
|
|
||||||
.padding(vertical = SimpleTheme.dimens.margin.large)
|
|
||||||
.clickable(
|
|
||||||
indication = null,
|
|
||||||
interactionSource = rememberMutableInteractionSource(),
|
|
||||||
onClick = onStroboscopeButtonPress
|
|
||||||
),
|
|
||||||
painter = painterResource(id = R.drawable.ic_stroboscope_vector),
|
painter = painterResource(id = R.drawable.ic_stroboscope_vector),
|
||||||
contentDescription = stringResource(id = R.string.stroboscope),
|
contentDescription = stringResource(id = R.string.stroboscope),
|
||||||
tint = if (stroboscopeActive) SimpleTheme.colorScheme.primary else SimpleTheme.colorScheme.onSurface
|
isActive = stroboscopeActive,
|
||||||
|
onPress = onStroboscopeButtonPress
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +199,28 @@ internal fun MainScreenSlidersSection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun SmallButton(
|
||||||
|
painter: Painter,
|
||||||
|
contentDescription: String,
|
||||||
|
isActive: Boolean,
|
||||||
|
onPress: () -> Unit
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(AppDimensions.smallerButtonSize)
|
||||||
|
.padding(vertical = SimpleTheme.dimens.margin.large)
|
||||||
|
.clickable(
|
||||||
|
indication = null,
|
||||||
|
interactionSource = rememberMutableInteractionSource(),
|
||||||
|
onClick = onPress
|
||||||
|
),
|
||||||
|
painter = painter,
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
tint = if (isActive) SimpleTheme.colorScheme.primary else SimpleTheme.colorScheme.onSurface
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun buildActionMenu(
|
private fun buildActionMenu(
|
||||||
showMoreApps: Boolean,
|
showMoreApps: Boolean,
|
||||||
openSettings: () -> Unit,
|
openSettings: () -> Unit,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user