Skip to content

Commit

Permalink
Dot animation behaviour changes, hide subTitle if null or empty, high…
Browse files Browse the repository at this point in the history
…light every active step with dot animation
  • Loading branch information
kukadiajayesh committed Oct 29, 2023
1 parent 907936f commit ccc52b4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.res.TypedArray
import android.graphics.Rect
import android.util.AttributeSet
import android.util.Log
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
Expand All @@ -13,6 +14,7 @@ import android.widget.FrameLayout
import androidx.annotation.ColorInt
import androidx.annotation.StyleRes
import androidx.core.view.ViewCompat
import androidx.core.view.children
import com.mikashboks.sequencelayout.R

/**
Expand Down Expand Up @@ -238,6 +240,20 @@ public class SequenceLayout(context: Context, attrs: AttributeSet?, defStyleAttr
}
}
}
.withEndAction {

postDelayed({
// Animate Every activated dot
stepsWrapper.children.forEachIndexed { index, view ->
if(view is SequenceStep && view.isActive()){
dotsWrapper.children().getOrNull(index)?.apply {
this.isEnabled = true
this.isActivated = true
}
}
}
}, 500)
}
.start()
}
}
Expand All @@ -251,14 +267,6 @@ public class SequenceLayout(context: Context, attrs: AttributeSet?, defStyleAttr

override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams) {
if (child is SequenceStep) {
if (child.isActive()) {
child.setPadding(
0,
if (stepsWrapper.childCount == 0) 0 else resources.getDimensionPixelSize(R.dimen.sequence_active_step_padding_top), //no paddingTop if first step is active
0,
resources.getDimensionPixelSize(R.dimen.sequence_active_step_padding_bottom)
)
}
child.onStepChangedListener = this
stepsWrapper.addView(child, params)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.annotation.Dimension
import androidx.annotation.StringRes
import androidx.annotation.StyleRes
import androidx.core.view.doOnPreDraw
import androidx.core.view.isVisible
import androidx.core.widget.TextViewCompat
import com.mikashboks.sequencelayout.R
import kotlin.math.max
Expand Down Expand Up @@ -155,7 +156,7 @@ public class SequenceStep(context: Context?, attrs: AttributeSet?) : TableRow(co
*/
public fun setSubtitle(subtitle: CharSequence?) {
this.subtitle.text = subtitle
this.subtitle.visibility = View.VISIBLE
this.subtitle.isVisible = subtitle.isNullOrEmpty()
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/values/integers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<resources>
<integer name="sequence_step_duration">300</integer>
<integer name="sequence_pulse_duration">1000</integer>
<integer name="sequence_pulse_repeat_pause">3000</integer>
<integer name="sequence_pulse_repeat_pause">500</integer>
</resources>
9 changes: 4 additions & 5 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@
<com.transferwise.sequencelayout.SequenceStep
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:active="true"
app:subtitle="This is the subtitle."
app:active="true"
app:anchor="30 Nov"
app:titleTextAppearance="@style/TextAppearance.AppCompat.Title"
app:title="Second step"/>

<com.transferwise.sequencelayout.SequenceStep
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingTop="4dp"
app:active="true"
app:anchor="Today"
app:subtitle="This is the subtitle of this step.\nIt should describe steps (especially the active step) in a detailed way."
app:title="Third step"
Expand All @@ -48,12 +46,13 @@
<com.transferwise.sequencelayout.SequenceStep
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:active="true"
app:anchor="30 Nov"
app:title="Fourth step"/>

<com.transferwise.sequencelayout.SequenceStep
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:active="true"
app:anchor="2 Dec"
app:title="Fifth step"/>
</com.transferwise.sequencelayout.SequenceLayout>
Expand Down

0 comments on commit ccc52b4

Please sign in to comment.