-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Informações sobre os resultados na tela de resultados
- Loading branch information
1 parent
78f98d9
commit 8df4042
Showing
5 changed files
with
216 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
android/MLCChat/app/src/main/java/ai/mlc/mlcchat/components/Accordion.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package ai.mlc.mlcchat.components | ||
|
||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.KeyboardArrowDown | ||
import androidx.compose.material.icons.filled.KeyboardArrowUp | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.Font | ||
import androidx.compose.ui.text.font.FontWeight | ||
|
||
@Composable | ||
fun AccordionItem( | ||
modifier: Modifier = Modifier, | ||
isExpanded: Boolean = false, | ||
backgroundColor: Color = Color.Transparent, | ||
shape: Shape = RoundedCornerShape(10.dp), | ||
title: String, | ||
titleModifier: Modifier = Modifier, | ||
iconModifier: Modifier = Modifier, | ||
titleColor: Color = MaterialTheme.colorScheme.onSecondary, | ||
titleStyle: TextStyle = MaterialTheme.typography.bodyMedium, | ||
titleWeight: FontWeight = FontWeight.SemiBold, | ||
content: @Composable () -> Unit | ||
) { | ||
var expanded by remember { mutableStateOf(isExpanded) } | ||
|
||
Column( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.clip(shape) | ||
.background(backgroundColor) | ||
.clickable { | ||
expanded = !expanded | ||
} | ||
.padding(16.dp) | ||
) { | ||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
modifier = Modifier.fillMaxWidth() | ||
) { | ||
Text( | ||
modifier = titleModifier.weight(1f), | ||
color = titleColor, | ||
text = title, | ||
style = titleStyle, | ||
fontWeight = titleWeight, | ||
) | ||
Icon( | ||
modifier = iconModifier, | ||
imageVector = if (expanded) Icons.Default.KeyboardArrowUp else Icons.Default.KeyboardArrowDown, | ||
contentDescription = if (expanded) "Collapse" else "Expand", | ||
tint = titleColor | ||
) | ||
} | ||
AnimatedVisibility(visible = expanded) { | ||
Column { | ||
Spacer(modifier = Modifier.height(8.dp)) | ||
content() | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun AccordionText( | ||
modifier: Modifier = Modifier, | ||
text: String, | ||
color: Color = MaterialTheme.colorScheme.onPrimary, | ||
style: TextStyle = MaterialTheme.typography.bodySmall | ||
){ | ||
Text( | ||
modifier = modifier, | ||
text = text, | ||
color = color, | ||
style = style, | ||
) | ||
} |
72 changes: 72 additions & 0 deletions
72
android/MLCChat/app/src/main/java/ai/mlc/mlcchat/components/Chip.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package ai.mlc.mlcchat.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Star | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
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.graphics.Shape | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
|
||
|
||
@Composable | ||
fun Chip( | ||
modifier: Modifier = Modifier, | ||
backgroundColor: Color = MaterialTheme.colorScheme.primary, | ||
shape: Shape = RoundedCornerShape(10.dp), | ||
|
||
textModifier: Modifier = Modifier, | ||
textPaddingValues: PaddingValues = PaddingValues(10.dp), | ||
textColor: Color = MaterialTheme.colorScheme.onPrimary, | ||
fontWeight: FontWeight = FontWeight.SemiBold, | ||
textStyle: TextStyle = MaterialTheme.typography.bodySmall, | ||
text: String, | ||
|
||
icon: ImageVector? = null, // Default icon, can be customized | ||
iconDescription: String = "Chip icon", | ||
iconModifier: Modifier = Modifier.size(16.dp), // Default size, can be customized | ||
iconTint: Color = textColor // Default tint same as text color, can be customized | ||
) { | ||
Row( | ||
modifier = modifier | ||
.clip(shape) | ||
.background(backgroundColor) | ||
.padding(textPaddingValues), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
if(icon !== null) { | ||
Icon( | ||
imageVector = icon, | ||
contentDescription = iconDescription, | ||
tint = iconTint, | ||
modifier = iconModifier | ||
) | ||
Spacer(modifier = Modifier.width(4.dp)) | ||
} | ||
|
||
Text( | ||
modifier = textModifier, | ||
text = text, | ||
fontWeight = fontWeight, | ||
color = textColor, | ||
style = textStyle | ||
) | ||
} | ||
} |