mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-17 19:29:02 +00:00
Bottom sheet improvements
This commit is contained in:
parent
afe8b22cca
commit
400c5f2fcf
12 changed files with 52 additions and 45 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<corners android:radius="24dp" />
|
||||
<corners android:radius="@dimen/rounded_button_radius" />
|
||||
<solid android:color="@color/white" />
|
||||
<stroke android:color="@color/gray_500" android:width="2dp" />
|
||||
</shape>
|
||||
|
|
@ -32,7 +32,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="24dp"
|
||||
style="@style/Pill"
|
||||
android:padding="0dp"
|
||||
android:paddingHorizontal="4dp"
|
||||
android:minWidth="24dp"
|
||||
android:gravity="center"
|
||||
tools:text="12"
|
||||
android:layout_alignEnd="@id/egg_frame_view"
|
||||
|
|
@ -73,7 +74,8 @@
|
|||
android:id="@+id/potion_count_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="24dp"
|
||||
android:padding="0dp"
|
||||
android:paddingHorizontal="4dp"
|
||||
android:minWidth="24dp"
|
||||
android:gravity="center"
|
||||
style="@style/Pill"
|
||||
tools:text="12"
|
||||
|
|
|
|||
|
|
@ -140,8 +140,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="65dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="@dimen/spacing_large"
|
||||
android:paddingEnd="@dimen/spacing_large"
|
||||
android:baselineAligned="false">
|
||||
<com.habitrpg.android.habitica.ui.RoundedFrameLayout
|
||||
android:layout_width="40dp"
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
tools:text="Title"
|
||||
android:gravity="center"
|
||||
style="@style/Subheader1"
|
||||
android:background="@drawable/bottom_sheet_title"
|
||||
android:padding="8dp"/>
|
||||
style="@style/Subheader1"/>
|
||||
<com.habitrpg.android.habitica.ui.views.PixelArtView
|
||||
android:id="@+id/icon_view"
|
||||
android:layout_width="@dimen/shopitem_image_size"
|
||||
|
|
|
|||
|
|
@ -1,19 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/HabiticaButton.Purple.Small"
|
||||
android:background="@drawable/layout_rounded_bg"
|
||||
android:layout_marginVertical="6dp"
|
||||
android:layout_marginHorizontal="@dimen/spacing_large"
|
||||
android:background="@drawable/button_background"
|
||||
android:foreground="?selectableItemBackground"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:layout_marginHorizontal="21dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/BottomMenuItemText"
|
||||
tools:text="Menu Item"/>
|
||||
<com.habitrpg.android.habitica.ui.views.CurrencyView
|
||||
android:id="@+id/currency_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
android:textColor="@color/white"
|
||||
app:currency="gold"
|
||||
tools:text="100"
|
||||
android:layout_marginStart="8dp"/>
|
||||
</LinearLayout>
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:src="@drawable/justin_textbox"
|
||||
android:layout_gravity="right"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginEnd="30dp"/>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@
|
|||
<dimen name="content_inset">21dp</dimen>
|
||||
<dimen name="header_border_spacing">16dp</dimen>
|
||||
|
||||
<dimen name="button_height">50dp</dimen>
|
||||
<dimen name="button_height">54dp</dimen>
|
||||
<dimen name="button_height_small">24dp</dimen>
|
||||
<dimen name="alert_side_padding">26dp</dimen>
|
||||
<dimen name="downwards_drop_shadow_height">16dp</dimen>
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@
|
|||
<string name="armoireFood_new">You rummage in the Armoire and find food. What\'s that doing in here?</string>
|
||||
<string name="armoireExp">You wrestle with the Armoire and gain Experience. Take that!</string>
|
||||
<string name="sell">Sell (%d Gold)</string>
|
||||
<string name="sell_no_price">Sell</string>
|
||||
<string name="hatch_with_potion">Hatch with potion</string>
|
||||
<string name="hatch_egg">Hatch with egg</string>
|
||||
<string name="invite_party">Invite party</string>
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
|
||||
if (customization.type == "background" && customization.identifier == "") {
|
||||
binding.imageView.load(R.drawable.no_background)
|
||||
binding.imageView.bitmap = null
|
||||
} else {
|
||||
binding.imageView.loadImage(customization.getIconName(userSize, hairColor))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class ItemRecyclerAdapter(val context: Context, val user: User?) : BaseRecyclerV
|
|||
menu.setTitle(item?.text)
|
||||
menu.setImage(getImageName(item))
|
||||
if (item !is QuestContent && item !is SpecialItem) {
|
||||
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.sell, item?.value), true))
|
||||
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.sell_no_price), true, "gold", item?.value?.toDouble() ?: 0.0))
|
||||
}
|
||||
if (item is Egg) {
|
||||
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.hatch_with_potion)))
|
||||
|
|
|
|||
|
|
@ -5,33 +5,23 @@ import android.content.res.ColorStateList
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.databinding.MenuBottomSheetItemBinding
|
||||
|
||||
class BottomSheetMenuItem {
|
||||
|
||||
private var title: String? = null
|
||||
private var isDestructive: Boolean? = null
|
||||
|
||||
constructor(title: String) {
|
||||
this.title = title
|
||||
this.isDestructive = false
|
||||
}
|
||||
|
||||
constructor(title: String, isDestructive: Boolean?) {
|
||||
this.title = title
|
||||
this.isDestructive = isDestructive
|
||||
}
|
||||
class BottomSheetMenuItem(private val title: String, private val isDestructive: Boolean = false, private val currency: String? = null, private val price: Double = 0.0) {
|
||||
|
||||
fun inflate(context: Context, inflater: LayoutInflater, contentView: ViewGroup): View {
|
||||
val menuItemView = inflater.inflate(R.layout.menu_bottom_sheet_item, contentView, false) as? LinearLayout
|
||||
val textView = menuItemView?.findViewById<TextView>(R.id.textView)
|
||||
textView?.text = this.title
|
||||
if (this.isDestructive == true) {
|
||||
menuItemView?.backgroundTintList = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.red_10))
|
||||
val binding = MenuBottomSheetItemBinding.inflate(inflater, contentView, false)
|
||||
binding.textView.text = this.title
|
||||
if (this.isDestructive) {
|
||||
binding.root.backgroundTintList = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.maroon_100))
|
||||
}
|
||||
return menuItemView ?: View(context)
|
||||
if (price > 0) {
|
||||
binding.currencyView.currency = currency ?: "gold"
|
||||
binding.currencyView.value = price
|
||||
binding.currencyView.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,16 @@ class PixelArtView @JvmOverloads constructor(
|
|||
var targetHeight = bitmap?.height ?: 0
|
||||
val smallestSide = min(width, height)
|
||||
|
||||
if (smallestSide > 0 && targetWidth > 0 && smallestSide != targetWidth) {
|
||||
targetWidth = (targetWidth / 3) * (smallestSide / (targetWidth / 3))
|
||||
}
|
||||
if (smallestSide > 0 && targetHeight > 0 && smallestSide != targetHeight) {
|
||||
targetHeight = (targetHeight / 3) * (smallestSide / (targetHeight / 3))
|
||||
}
|
||||
|
||||
val factor = min(
|
||||
(if (smallestSide > 0 && targetWidth > 0 && smallestSide != targetWidth) {
|
||||
smallestSide / (targetWidth / 3)
|
||||
} else 1),
|
||||
if (smallestSide > 0 && targetHeight > 0 && smallestSide != targetHeight) {
|
||||
smallestSide / (targetHeight / 3)
|
||||
} else 1
|
||||
)
|
||||
targetWidth = (targetWidth / 3) * factor
|
||||
targetHeight = (targetHeight / 3) * factor
|
||||
val left = (width - targetWidth) / 2
|
||||
val top = (height - targetHeight) / 2
|
||||
targetRect = Rect(left, top, left + targetWidth, top + targetHeight)
|
||||
|
|
|
|||
Loading…
Reference in a new issue