Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose state #5242

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package org.wikipedia.compose.components

import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.wikipedia.compose.ComposeColors
import org.wikipedia.compose.theme.BaseTheme
import org.wikipedia.compose.theme.WikipediaTheme

@Composable
Expand Down Expand Up @@ -115,27 +123,57 @@ fun ThemeColorCircularButton(
onClick: () -> Unit,
text: String = "Aa",
modifier: Modifier = Modifier,
backgroundColor: Color,
borderColor: Color
size: Dp = 40.dp,
defaultBackgroundColor: Color = WikipediaTheme.colors.paperColor,
selectedBackgroundColor: Color = WikipediaTheme.colors.backgroundColor,
borderColor: Color = WikipediaTheme.colors.progressiveColor,
textColor: Color = WikipediaTheme.colors.primaryColor,
rippleColor: Color = Color.Transparent,
isSelected: Boolean = false
) {
Button(
onClick = onClick,
modifier = modifier.border(
width = 2.dp,
color = borderColor,
shape = CircleShape
).size(40.dp),
modifier = modifier
.border(
width = 2.dp,
color = if (isSelected) borderColor else Color.Transparent,
shape = CircleShape
)
.size(size),
colors = ButtonDefaults.buttonColors(
containerColor = backgroundColor
containerColor = if (isSelected) defaultBackgroundColor else selectedBackgroundColor,
contentColor = rippleColor
),
contentPadding = PaddingValues(0.dp)
) {
Text(
text = text,
style = WikipediaTheme.typography.h3.copy(
color = WikipediaTheme.colors.primaryColor,
color = textColor,
letterSpacing = 0.sp
)
)
}
}

@Preview(showSystemUi = true)
@Composable
private fun SepiaThemeColorButton() {
BaseTheme {
Column(
modifier = Modifier
.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(12.dp, Alignment.CenterVertically),
horizontalAlignment = Alignment.CenterHorizontally
) {
ThemeColorCircularButton(
isSelected = true,
defaultBackgroundColor = ComposeColors.Beige300,
selectedBackgroundColor = ComposeColors.Beige300,
rippleColor = ComposeColors.Beige300,
textColor = ComposeColors.Gray700,
onClick = {}
)
}
}
}
Loading