Skip to content

Commit f1b4ee6

Browse files
author
Parminder
committed
dev: align status with current prop added
1 parent 4c0b5c1 commit f1b4ee6

4 files changed

Lines changed: 20 additions & 10 deletions

File tree

app/src/main/java/jugnoo/com/learningcustomvviews/StatusView.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ class StatusView @JvmOverloads constructor(
2626

2727
/*
2828
TODO
29-
alignAllStatusWithCurrent
30-
Pass font to textView
31-
Ensure Text single line & text gap prop
29+
Display status above|bottom
3230
Text Appearance?
3331
LTR Support
3432
Orientation draw vertical too
35-
Display status above|bottom
36-
*/
33+
34+
*/
3735

3836
companion object {
3937
const val CIRCLE_COLOR_TYPE_FILL = 1
@@ -132,6 +130,14 @@ class StatusView @JvmOverloads constructor(
132130
*/
133131
var labelTopMargin by OnLayoutProp( 4.0f.pxValue())
134132

133+
/**
134+
* set true to align all status to align same as current Status y-pos
135+
*
136+
*/
137+
var alignStatusWithCurrent by OnValidateProp(false){
138+
setDrawingDimensions()
139+
}
140+
135141
/**
136142
* Stroke width of the line between circles (dp)
137143
*/
@@ -429,6 +435,7 @@ class StatusView @JvmOverloads constructor(
429435

430436
circleFillColorCurrent = a.getColor(R.styleable.StatusView_circleColorCurrent, circleFillColorIncomplete)
431437
currentStatusZoom = a.getFloat(R.styleable.StatusView_currentStatusZoom, currentStatusZoom)
438+
alignStatusWithCurrent = a.getBoolean(R.styleable.StatusView_alignStatusWithCurrent, alignStatusWithCurrent)
432439

433440
val entries = a.getTextArray(R.styleable.StatusView_android_entries)
434441
if (entries != null) {
@@ -756,7 +763,8 @@ class StatusView @JvmOverloads constructor(
756763
lastPoint.x += ((circleRadius) * 2.0f) + (circleStrokeWidth / 2)
757764

758765
if(i<statusData.size){
759-
labelItemText = StatusItemText(circleItem.center.x, circleItem.center.y + circleRadius + circleStrokeWidth/2 + labelTopMargin, statusData[i].staticLayout)
766+
val radii = if(isShowingCurrentStatus() && alignStatusWithCurrent) currentStatusRadius else circleRadius
767+
labelItemText = StatusItemText(circleItem.center.x, circleItem.center.y + radii + circleStrokeWidth/2 + labelTopMargin, statusData[i].staticLayout)
760768
}
761769

762770

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
android:layout_width="wrap_content"
2323
android:layout_height="wrap_content"
2424
app:circleColorType="fillStroke"
25-
app:statusCount="3"
26-
app:currentCount="1"
25+
app:statusCount="4"
26+
app:currentCount="3"
2727
app:lineLength="25dp"
2828
app:circleRadius="25dp"
2929
app:obeyLineLength="false"
30-
app:currentStatusZoom="0.0"
30+
app:currentStatusZoom="0.5"
3131
app:drawCount="true"
3232
app:statusFont="@font/bree_serif"
3333
app:labelFont="@font/pt_sans"

app/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<attr name="minStatusMargin" format="dimension"/>
4040
<attr name="labelTopMargin" format="dimension"/>
4141
<attr name="currentStatusZoom" format="float"/>
42+
<attr name="alignStatusWithCurrent" format="boolean"/>
4243
<attr name="statusFont" format="reference"/>
4344
<attr name="labelFont" format="reference"/>
4445
<attr name="android:entries" />

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<string name="customViewLabel">Fan Control</string>
44

55
<string-array name="statuses">
6-
<item>On the way</item>
6+
<item>Confirmed</item>
7+
<item>Dispatched</item>
78
<item>Arriving</item>
89
<item>Delivered</item>
910
</string-array>

0 commit comments

Comments
 (0)