This file contains hidden or 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
@Composable | |
fun StackedBarChart( | |
data: List<Float>, | |
colors: List<Color>, | |
) { | |
val proportions = data.map { it.div(data.sum()) }.filter { it > 0 }.toMutableStateList() | |
val oldValues = rememberSaveable { mutableListOf<Float>() } | |
val animatedProportions = List(proportions.size) { remember { Animatable(0f) } } | |
val visibility = remember { mutableStateOf(false) } |
This file contains hidden or 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
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun <T : DropdownMenuItem> DropdownItemSelector( | |
preSelectedIndex: Int = 0, | |
dropdownLabel: String, | |
menuItemList: List<T>, | |
onMenuItemChange: (T) -> Unit = {} | |
) { | |
var dropDownExpanded by remember { mutableStateOf(false) } | |
var selectedMenuItem by remember { mutableStateOf(menuItemList.first()) } |
This file contains hidden or 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
@Composable | |
fun IconItemView(iconItem: IconItem, onIconSelected: (String, ImageVector) -> Unit) { | |
Column( | |
modifier = Modifier | |
.padding(MaterialTheme.spacing.small) | |
.wrapContentSize() | |
) { | |
iconItem.image?.let { | |
Icon( | |
imageVector = it, |
This file contains hidden or 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
@Composable | |
fun SearchBar(onTextChange: (String) -> Unit = {}) { | |
val searchString = remember { mutableStateOf("") } | |
Row { | |
OutlinedTextField( | |
value = searchString.value, | |
onValueChange = { | |
searchString.value = it | |
onTextChange(it) | |
}, |
This file contains hidden or 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
@Composable | |
fun IconPicker( | |
onIconSelected: (String, ImageVector) -> Unit, | |
iconPickerHeight: Float = 1f, | |
) { | |
val icons = Util.iconUtil.getListOfIcons( | |
iconNameList = stringArrayResource(R.array.icon_names) | |
.toList() | |
) | |
val searchText = remember { mutableStateOf("") } |
This file contains hidden or 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
data class IconItem( | |
val id: String, | |
val image: ImageVector? = null, | |
) |
This file contains hidden or 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
object IconUtil { | |
/** | |
* @param iconId name of the icon from the Icons.Filled class | |
* @return [ImageVector] object | |
*/ | |
fun createImageVector(iconId: String): ImageVector { | |
try { | |
val className = "androidx.compose.material.icons.filled.${iconId}Kt" | |
val cl = Class.forName(className) | |
val method = cl.declaredMethods.first() |
This file contains hidden or 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
object IconUtil { | |
/** | |
* @param iconId name of the icon from the Icons.Filled class | |
* @return [ImageVector] object | |
*/ | |
fun createImageVector(iconId: String): ImageVector { | |
try { | |
val className = "androidx.compose.material.icons.filled.${iconId}Kt" | |
val cl = Class.forName(className) | |
val method = cl.declaredMethods.first() |
This file contains hidden or 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
class LiveGraphPlotView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null | |
) : SurfaceView(context, attrs), SurfaceHolder.Callback, Runnable { | |
private lateinit var mCanvas: Canvas | |
private lateinit var mSurfaceHolder: SurfaceHolder | |
private var mWidth: Int = 0 | |
private var mHeight: Int = 0 | |
private var mRunning: Boolean = false |