mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Add transformation item to SkillDialog
add isTransformationItem flag to SkillDialog: hide MP chip & spacer and update button label to “Use on Party” when true.
This commit is contained in:
parent
0981e78e23
commit
1773907fb2
4 changed files with 46 additions and 36 deletions
|
|
@ -1040,6 +1040,7 @@
|
|||
<string name="stat_allocation">Stat Allocation</string>
|
||||
<string name="stat_description">All Habitica characters have four stats that affect the gameplay aspects of Habitica.\n\n**Strength (STR)** affects critical hits and raises damage done to a Quest Boss. Warriors and Rogues gain STR from their class equipment.\n\n**Constitution (CON)** raises your HP and makes you take less damage. Healers and Warriors gain CON from their class equipment.\n\n**Intelligence (INT)** raises the amount of EXP you earn and gives you more Mana. Mages and Healers gain INT from their class equipment.\n\n**Perception (PER)** increases the gold you earn and the rate of finding dropped items. Rogues and Mages gain PER from their class equipment.\n\nAfter level 10, you earn 1 Stat Point every level you gain that you can put into any stat you’d like. You can also equip gear that has different combinations of stat boosts.</string>
|
||||
<string name="use_skill">Use Skill</string>
|
||||
<string name="use_on_party">Use on Party</string>
|
||||
|
||||
<string name="standard"> Standard </string>
|
||||
<string name="premium_currency">Premium Currency</string>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class SkillDialogBottomSheetFragment : BottomSheetDialogFragment() {
|
|||
skillPath: String,
|
||||
skillKey: String,
|
||||
resourceIcon: Drawable,
|
||||
isTransformationItem: Boolean = false,
|
||||
onUseSkill: () -> Unit
|
||||
): SkillDialogBottomSheetFragment {
|
||||
return SkillDialogBottomSheetFragment().apply {
|
||||
|
|
@ -39,6 +40,7 @@ class SkillDialogBottomSheetFragment : BottomSheetDialogFragment() {
|
|||
this.skillKey = skillKey
|
||||
this.skillPath = skillPath
|
||||
this.onUseSkill = onUseSkill
|
||||
this.isTransformationItem = isTransformationItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +49,7 @@ class SkillDialogBottomSheetFragment : BottomSheetDialogFragment() {
|
|||
private var resourceIcon: Drawable? = null
|
||||
var skillKey = ""
|
||||
var skillPath = ""
|
||||
var isTransformationItem: Boolean = false
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
|
|
@ -62,6 +65,7 @@ class SkillDialogBottomSheetFragment : BottomSheetDialogFragment() {
|
|||
title = requireArguments().getString(ARG_SKILL_TITLE) ?: "",
|
||||
description = requireArguments().getString(ARG_SKILL_DESCRIPTION) ?: "",
|
||||
mpCost = requireArguments().getString(ARG_SKILL_MP_COST) ?: "",
|
||||
isTransformationItem = isTransformationItem,
|
||||
onUseSkill = {
|
||||
onUseSkill?.invoke()
|
||||
dismiss()
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ class SkillsFragment : BaseMainFragment<FragmentRecyclerviewBinding>() {
|
|||
val context = context ?: return
|
||||
val resourceIconDrawable: Drawable = HabiticaIconsHelper.imageOfMagic().toDrawable(context.resources)
|
||||
val skillIdentifier = "shop_"
|
||||
val isTransformationItem = skill.habitClass == "special"
|
||||
|
||||
val bottomSheet = SkillDialogBottomSheetFragment.newInstance(
|
||||
skillTitle = skill.text,
|
||||
|
|
@ -114,6 +115,7 @@ class SkillsFragment : BaseMainFragment<FragmentRecyclerviewBinding>() {
|
|||
skillPath = skillIdentifier,
|
||||
skillMpCost = "${skill.mana?.toInt() ?: 0} MP",
|
||||
resourceIcon = resourceIconDrawable,
|
||||
isTransformationItem = isTransformationItem,
|
||||
onUseSkill = {
|
||||
when {
|
||||
"special" == skill.habitClass -> {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ fun SkillDialog(
|
|||
title: String,
|
||||
description: String,
|
||||
mpCost: String,
|
||||
isTransformationItem: Boolean = false,
|
||||
onUseSkill: () -> Unit,
|
||||
) {
|
||||
val colors = HabiticaTheme.colors
|
||||
|
|
@ -61,11 +62,10 @@ fun SkillDialog(
|
|||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier
|
||||
.padding(bottom = 16.dp)
|
||||
.background(colorResource(R.color.content_background_offset))
|
||||
.size(24.dp, 3.dp)
|
||||
modifier = Modifier
|
||||
.padding(bottom = 16.dp)
|
||||
.background(colorResource(R.color.content_background_offset))
|
||||
.size(24.dp, 3.dp)
|
||||
)
|
||||
|
||||
Box(
|
||||
|
|
@ -75,14 +75,12 @@ fun SkillDialog(
|
|||
.background(colors.pixelArtBackground(hasIcon = true)),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
PixelArtView (
|
||||
imageName = skillPath + skillKey,
|
||||
PixelArtView(
|
||||
imageName = "$skillPath$skillKey",
|
||||
modifier = Modifier.size(62.dp)
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
Text(
|
||||
text = title,
|
||||
fontSize = 16.sp,
|
||||
|
|
@ -98,33 +96,33 @@ fun SkillDialog(
|
|||
modifier = Modifier.padding(top = 8.dp),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(18.dp))
|
||||
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(20.dp))
|
||||
.background(chipBg)
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
) {
|
||||
Icon(
|
||||
painter = resourceIconPainter,
|
||||
contentDescription = null,
|
||||
tint = Color.Unspecified,
|
||||
modifier = Modifier.size(22.dp)
|
||||
)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(
|
||||
text = mpCost,
|
||||
color = chipTextColor,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
if (!isTransformationItem) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(20.dp))
|
||||
.background(chipBg)
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
) {
|
||||
Icon(
|
||||
painter = resourceIconPainter,
|
||||
contentDescription = null,
|
||||
tint = Color.Unspecified,
|
||||
modifier = Modifier.size(22.dp)
|
||||
)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(
|
||||
text = mpCost,
|
||||
color = chipTextColor,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.height(28.dp))
|
||||
} else {
|
||||
Spacer(Modifier.height(18.dp))
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(28.dp))
|
||||
|
||||
Button(
|
||||
onClick = onUseSkill,
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
|
|
@ -136,18 +134,22 @@ fun SkillDialog(
|
|||
.fillMaxWidth()
|
||||
.height(43.dp)
|
||||
) {
|
||||
val label = if (isTransformationItem)
|
||||
stringResource(R.string.use_on_party)
|
||||
else
|
||||
stringResource(R.string.use_skill)
|
||||
Text(
|
||||
text = stringResource(R.string.use_skill),
|
||||
text = label,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 17.sp
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Preview(showBackground = true, backgroundColor = 0xFF232136)
|
||||
@Composable
|
||||
fun PreviewSkillDialog() {
|
||||
|
|
@ -158,6 +160,7 @@ fun PreviewSkillDialog() {
|
|||
title = "Title Skill",
|
||||
description = "Skill Description",
|
||||
mpCost = "10 MP",
|
||||
isTransformationItem = true,
|
||||
onUseSkill = {
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue