Skip to content

Commit

Permalink
chore: move bounce config to MaimActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
trindadedev13 committed Dec 21, 2024
1 parent 6855a87 commit d11bc46
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@ public class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
_binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
val scaleState = ScaleState(view = binding.elasticMoveableLayout)
configureBounceLayout()
}

private fun configureBounceLayout() {
val scaleState = ScaleState(view = binding.bounceLayout)
scale = Scale(context = this, state = scaleState)

binding.bounceLayout.events.state.initialBound = 100f
binding.bounceLayout.events.state.targetBound = resources.displayMetrics.heightPixels.toFloat()
binding.bounceLayout.events.state.currentBound = binding.bounceLayout.events.state.initialBound
binding.bounceLayout.post {
binding.bounceLayout.layoutParams.height = binding.bounceLayout.events.state.initialBound.toInt()
binding.bounceLayout.requestLayout()
}
}

override fun onTouchEvent(event: MotionEvent): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ constructor(
var events = BounceLayoutEvents()

init {
events.state.initialBound = 100f
events.state.targetBound = resources.displayMetrics.heightPixels.toFloat()
events.state.currentBound = events.state.initialBound
post {
layoutParams.height = events.state.initialBound.toInt()
requestLayout()
}

setOnTouchListener { view, event ->
when (event.action) {
MotionEvent.ACTION_UP -> events.onUp(view, event)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
android:orientation="vertical"
android:padding="12dp">
<dev.trindadedev.learn.ui.components.bounce.BounceLayout
android:id="@+id/elastic_moveable_layout"
android:id="@+id/bounce_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/drag_shape" />
android:background="@drawable/tertiary_shape" />
</dev.trindadedev.learn.ui.components.bounce.BounceLayout>
</RelativeLayout>

0 comments on commit d11bc46

Please sign in to comment.