Asking for approval to use some of the code #687
-
I want to use the SelectableMiniPalette you made for your app. I added the code to my app and would love to have your approval to publish it. Do I add you to my readme? Do I need to mention your license? My app: The file in which I used some of your code: package cloud.pablos.overload.ui.tabs.configurations
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.expandIn
// ...
@Composable
fun ConfigurationsTabCreateCategoryDialog(
onClose: () -> Unit,
categoryEvent: (CategoryEvent) -> Unit,
) {
val colorOptions: List<Color> =
listOf(
Color(255, 209, 220), // Pastel Pink
Color(255, 204, 204), // Pastel Red
// ...
)
var name by remember { mutableStateOf(TextFieldValue()) }
var color by remember { mutableStateOf(colorOptions.first()) }
AlertDialog(
onDismissRequest = onClose,
title = {
TextView(
text = "Create Category",
fontWeight = FontWeight.Bold,
align = TextAlign.Center,
modifier = Modifier.fillMaxWidth(),
)
},
text = {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
// ...
Row(
modifier =
Modifier
.horizontalScroll(rememberScrollState()),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
colorOptions.forEach { colorOption ->
SelectableMiniPalette(
selected = colorOption == color,
onClick = { color = colorOption },
color = colorOption,
)
}
}
}
},
confirmButton = {
Button(
onClick = {
// ...
},
colors =
ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.primaryContainer,
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
),
) {
TextView(stringResource(id = R.string.save))
}
},
dismissButton = {
Button(
onClick = onClose,
colors =
ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer,
),
) {
Text(text = stringResource(R.string.cancel))
}
},
modifier = Modifier.padding(16.dp),
)
}
private fun (() -> Unit).save(
sharedPreferences: OlSharedPreferences,
hours: Int?,
minutes: Int?,
valid: Boolean,
isPause: Boolean,
) {
// ...
}
@Composable
fun SelectableMiniPalette(
modifier: Modifier = Modifier,
selected: Boolean,
onClick: () -> Unit,
color: Color,
) {
Surface(
modifier = modifier,
shape = RoundedCornerShape(16.dp),
color = MaterialTheme.colorScheme.inverseOnSurface,
) {
Surface(
modifier =
Modifier
.clickable { onClick() }
.padding(12.dp)
.size(34.dp),
shape = CircleShape,
color = color,
) {
Box {
AnimatedVisibility(
visible = selected,
modifier =
Modifier
.align(Alignment.Center)
.clip(CircleShape)
.background(MaterialTheme.colorScheme.primary),
enter = fadeIn() + expandIn(expandFrom = Alignment.Center),
exit = shrinkOut(shrinkTowards = Alignment.Center) + fadeOut(),
) {
Icon(
imageVector = Icons.Outlined.Check,
contentDescription = "Checked",
modifier =
Modifier
.padding(5.dp)
.size(10.dp),
tint = MaterialTheme.colorScheme.surface,
)
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
JunkFood02
Apr 13, 2024
Replies: 1 comment
-
Feel free to use and modify this source code by any means you like, as long as it complies the GPLv3 license. A credit would be much appreciated, whether in code or the readme |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pablo03v
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feel free to use and modify this source code by any means you like, as long as it complies the GPLv3 license. A credit would be much appreciated, whether in code or the readme