mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-09 23:59:33 +01:00
Add a drag indicator element at the top of LicenceDialog
A new `DragIndicatorView` had been introduced, which draws a drag indicator drawable. Users of this view should add the callback member as a behavior callback for proper hiding of the indicator when the dialog is fully expanded.
This commit is contained in:
parent
bf331abcdc
commit
e00db910f1
@ -8,6 +8,7 @@ package emu.skyline.preference
|
|||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.*
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
import emu.skyline.databinding.LicenseDialogBinding
|
import emu.skyline.databinding.LicenseDialogBinding
|
||||||
|
|
||||||
@ -32,6 +33,13 @@ class LicenseDialog : BottomSheetDialogFragment() {
|
|||||||
}.root
|
}.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
|
||||||
|
val behavior = BottomSheetBehavior.from(requireView().parent as View)
|
||||||
|
behavior.addBottomSheetCallback(binding.dragIndicator.callback)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view : View, savedInstanceState : Bundle?) {
|
override fun onViewCreated(view : View, savedInstanceState : Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
40
app/src/main/java/emu/skyline/views/DragIndicatorView.kt
Normal file
40
app/src/main/java/emu/skyline/views/DragIndicatorView.kt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: MPL-2.0
|
||||||
|
* Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
*/
|
||||||
|
|
||||||
|
package emu.skyline.views
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.transition.TransitionManager
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
import emu.skyline.R
|
||||||
|
|
||||||
|
class DragIndicatorView : androidx.appcompat.widget.AppCompatImageView {
|
||||||
|
val callback = DragIndicatorCallback()
|
||||||
|
|
||||||
|
init {
|
||||||
|
setImageResource(R.drawable.drag_indicator)
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(context : Context) : super(context)
|
||||||
|
constructor(context : Context, attrs : AttributeSet?) : super(context, attrs)
|
||||||
|
constructor(context : Context, attrs : AttributeSet?, defStyleAttr : Int) : super(context, attrs, defStyleAttr)
|
||||||
|
|
||||||
|
inner class DragIndicatorCallback : BottomSheetBehavior.BottomSheetCallback() {
|
||||||
|
override fun onStateChanged(bottomSheet : View, newState : Int) {
|
||||||
|
// Enables animation between visibility states
|
||||||
|
TransitionManager.beginDelayedTransition(parent as ViewGroup)
|
||||||
|
|
||||||
|
visibility = if (newState == BottomSheetBehavior.STATE_EXPANDED && bottomSheet.top == 0)
|
||||||
|
View.INVISIBLE
|
||||||
|
else
|
||||||
|
View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSlide(bottomSheet : View, slideOffset : Float) {}
|
||||||
|
}
|
||||||
|
}
|
9
app/src/main/res/drawable/drag_indicator.xml
Normal file
9
app/src/main/res/drawable/drag_indicator.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<size
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="4dp" />
|
||||||
|
<solid android:color="@color/onBackgroundLight" />
|
||||||
|
<corners android:radius="4dp" />
|
||||||
|
</shape>
|
@ -8,8 +8,13 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingHorizontal="2.5dp"
|
android:paddingHorizontal="2.5dp">
|
||||||
android:paddingTop="20dp">
|
|
||||||
|
<emu.skyline.views.DragIndicatorView
|
||||||
|
android:id="@+id/drag_indicator"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingVertical="10dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/library_title"
|
android:id="@+id/library_title"
|
||||||
@ -29,6 +34,7 @@
|
|||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
|
tools:ignore="TouchTargetSizeCheck"
|
||||||
tools:text="https://github.com/skyline-emu/skyline" />
|
tools:text="https://github.com/skyline-emu/skyline" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -46,10 +52,10 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:autoLink="web"
|
android:autoLink="web"
|
||||||
|
android:justificationMode="inter_word"
|
||||||
|
android:paddingHorizontal="15dp"
|
||||||
android:paddingTop="15dp"
|
android:paddingTop="15dp"
|
||||||
android:paddingBottom="15dp"
|
android:paddingBottom="15dp"
|
||||||
android:paddingHorizontal="15dp"
|
|
||||||
android:justificationMode="inter_word"
|
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||||
tools:text="@string/mpl2_license" />
|
tools:text="@string/mpl2_license" />
|
||||||
|
|
||||||
|
@ -4,4 +4,5 @@
|
|||||||
<color name="backgroundColor">#FF121212</color>
|
<color name="backgroundColor">#FF121212</color>
|
||||||
<color name="backgroundColorVariant">#323232</color>
|
<color name="backgroundColorVariant">#323232</color>
|
||||||
<color name="dividerColor">@android:color/white</color>
|
<color name="dividerColor">@android:color/white</color>
|
||||||
|
<color name="onBackgroundLight">#1AFFFFFF</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -5,4 +5,5 @@
|
|||||||
<color name="backgroundColor">@android:color/white</color>
|
<color name="backgroundColor">@android:color/white</color>
|
||||||
<color name="backgroundColorVariant">#F8F8F8</color>
|
<color name="backgroundColorVariant">#F8F8F8</color>
|
||||||
<color name="dividerColor">@android:color/black</color>
|
<color name="dividerColor">@android:color/black</color>
|
||||||
|
<color name="onBackgroundLight">#1E000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user