-
-
Save Stjin/807c430a25adebef76fae8a039cbc2b5 to your computer and use it in GitHub Desktop.
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
@Composable | |
fun Sample() { | |
val listOfDonutSection = listOf( | |
DonutSection(amount = 12f, color = Color.Cyan), | |
DonutSection(amount = 5f, color = Color.Red), | |
DonutSection(amount = 3f, color = Color.Green), | |
) | |
DonutProgress( | |
model = DonutModel( | |
cap = 20f, | |
masterProgress = 1f, | |
gapWidthDegrees = 0f, | |
gapAngleDegrees = 270f, | |
strokeWidth = 40f, | |
backgroundLineColor = Color.LightGray, | |
sections = listOfDonutSection.sortedBy { it.amount }, | |
), modifier = Modifier | |
.height(128.dp) | |
.width(128.dp) | |
) | |
} |
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
<app.futured.donut.DonutProgressView | |
android:id="@+id/donut_view" | |
android:layout_centerInParent="true" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
app:donut_bgLineColor="#1f1f1f" | |
app:donut_gapWidth="0" | |
app:donut_gapAngle="270" | |
app:donut_cap="20" | |
app:donut_strokeWidth="16dp"/> |
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
val donut_view = findViewById<DonutProgressView>(R.id.donut_view) | |
val listOfDonutSection: ArrayList<DonutSection> = arrayListOf() | |
val section1 = DonutSection( | |
name = "section_1", | |
color = Color.parseColor("#00ffff"), // Cyan | |
amount = 12.0f | |
) | |
val section2 = DonutSection( | |
name = "section_2", | |
color = Color.parseColor("#ff0000"), // red | |
amount = 5.0f | |
) | |
val section3 = DonutSection( | |
name = "section_3", | |
color = Color.parseColor("#00ff00"), // green | |
amount = 3.0f | |
) | |
listOfDonutSection.add(section1) | |
listOfDonutSection.add(section2) | |
listOfDonutSection.add(section3) | |
donut_view.submitData(listOfDonutSection.sortedBy { it.amount }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment