mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-15 10:41:58 +00:00
Customization fixes
This commit is contained in:
parent
a1271945cc
commit
6656f304a2
11 changed files with 69 additions and 50 deletions
|
|
@ -28,7 +28,7 @@
|
|||
android:id="@+id/switches_in_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?tintedUiDetails"
|
||||
android:textColor="?textColorTintedSecondary"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
style="@style/Caption2"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<string name="sidebar_party">Party</string>
|
||||
<string name="sidebar_challenges">Challenges</string>
|
||||
<string name="sidebar_section_inventory">Inventory</string>
|
||||
<string name="sidebar_avatar">Avatar Customisation</string>
|
||||
<string name="sidebar_avatar">Customize Avatar</string>
|
||||
<string name="sidebar_equipment">Equipment</string>
|
||||
<string name="sidebar_stable">Pets & Mounts</string>
|
||||
<string name="sidebar_news">News</string>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<string name="sidebar_subscription">Subscription</string>
|
||||
<string name="sidebar_challenges">Challenges</string>
|
||||
<string name="sidebar_section_inventory">Inventory</string>
|
||||
<string name="sidebar_avatar">Avatar Customization</string>
|
||||
<string name="sidebar_avatar">Customize Avatar</string>
|
||||
<string name="sidebar_avatar_equipment">Avatar & Equipment</string>
|
||||
<string name="sidebar_equipment">Equipment</string>
|
||||
<string name="sidebar_stable">Pets & Mounts</string>
|
||||
|
|
|
|||
|
|
@ -1509,6 +1509,7 @@
|
|||
<string name="customization_shop_check_out">Head over to the Customization Shop to browse the many ways you can customize your avatar!</string>
|
||||
<string name="switches_in_x">Switches in %s</string>
|
||||
<string name="tap_to_reload">Refresh for new items</string>
|
||||
<string name="monthly_backgrounds">Monthly Backgrounds</string>
|
||||
|
||||
<plurals name="you_x_others">
|
||||
<item quantity="zero">You</item>
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@
|
|||
|
||||
<style name="Caption2">
|
||||
<item name="android:fontFamily">@string/font_family_medium</item>
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:letterSpacing">0.04</item>
|
||||
</style>
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ open class Customization : RealmObject(), BaseObject {
|
|||
if (this.type == "hair" && this.category == "color") {
|
||||
return "icon_color_hair_bangs_1_$identifier"
|
||||
}
|
||||
return "icon_" + (getImageName(userSize, hairColor) ?: return null)
|
||||
val name = (getImageName(userSize, hairColor) ?: return null)
|
||||
return if (!name.startsWith("icon_")) "icon_$name" else name
|
||||
}
|
||||
|
||||
fun getImageName(
|
||||
|
|
|
|||
|
|
@ -258,13 +258,6 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
|
||||
val shop = getItemWithIdentifier(SIDEBAR_SHOPS_SEASONAL) ?: return
|
||||
shop.pillText = context?.getString(R.string.open)
|
||||
if (gearEvent?.isCurrentlyActive == true) {
|
||||
shop.isVisible = true
|
||||
shop.subtitle =
|
||||
context?.getString(R.string.open_for, gearEvent.end?.getShortRemainingString())
|
||||
} else {
|
||||
shop.isVisible = false
|
||||
}
|
||||
adapter.updateItem(shop)
|
||||
}
|
||||
|
||||
|
|
@ -440,7 +433,6 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
SIDEBAR_SHOPS_SEASONAL,
|
||||
context.getString(R.string.seasonalShop),
|
||||
)
|
||||
seasonalShopEntry.isVisible = false
|
||||
items.add(seasonalShopEntry)
|
||||
items.add(
|
||||
HabiticaDrawerItem(
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class CustomizationViewModel : ViewModel() {
|
|||
var type: String? = null
|
||||
var category: String? = null
|
||||
|
||||
val customizations = mutableStateListOf<Customization>()
|
||||
val items = mutableStateListOf<Any>()
|
||||
val activeCustomization = mutableStateOf<String?>(null)
|
||||
|
||||
val userSize = mutableStateOf("slim")
|
||||
|
|
@ -170,7 +170,7 @@ class ComposeAvatarCustomizationFragment :
|
|||
val hairColor by viewModel.hairColor
|
||||
val activeCustomization by viewModel.activeCustomization
|
||||
val avatar by userViewModel.user.observeAsState()
|
||||
AvatarCustomizationView(avatar = avatar, configManager = configManager, viewModel.customizations, userSize, hairColor, type, stringResource(viewModel.typeNameId), activeCustomization) { customization ->
|
||||
AvatarCustomizationView(avatar = avatar, configManager = configManager, viewModel.items, userSize, hairColor, type, stringResource(viewModel.typeNameId), activeCustomization) { customization ->
|
||||
lifecycleScope.launchCatching {
|
||||
if (customization.identifier?.isNotBlank() != true) {
|
||||
userRepository.useCustomization(type ?: "", category, activeCustomization ?: "")
|
||||
|
|
@ -281,12 +281,12 @@ class ComposeAvatarCustomizationFragment :
|
|||
.combine(currentFilter) { customizations, filter -> Pair(customizations, filter) }
|
||||
.combine(ownedCustomizations) { pair, ownedCustomizations ->
|
||||
val ownedKeys = ownedCustomizations.map { it.key }
|
||||
return@combine Pair(pair.first.filter { ownedKeys.contains(it.identifier) || ((it.price ?: 0) == 0 && type != "background") }, pair.second)
|
||||
return@combine Pair(pair.first.filter { ownedKeys.contains(it.identifier) || ((it.price ?: 0) == 0 && (type != "background" || it.identifier.isNullOrEmpty())) }, pair.second)
|
||||
}
|
||||
.map { (customizations, filter) ->
|
||||
var displayedCustomizations = customizations
|
||||
if (filter.isFiltering) {
|
||||
displayedCustomizations = mutableListOf<Customization>()
|
||||
displayedCustomizations = mutableListOf()
|
||||
for (customization in customizations) {
|
||||
if (shouldSkip(filter, customization)) continue
|
||||
displayedCustomizations.add(customization)
|
||||
|
|
@ -299,8 +299,20 @@ class ComposeAvatarCustomizationFragment :
|
|||
}
|
||||
}
|
||||
.collect { customizations ->
|
||||
viewModel.customizations.clear()
|
||||
viewModel.customizations.addAll(customizations)
|
||||
viewModel.items.clear()
|
||||
if (type == "background") {
|
||||
var lastSection = ""
|
||||
customizations.forEach { background ->
|
||||
val section = if (background.customizationSet?.startsWith("20") == true) requireContext().getString(R.string.monthly_backgrounds) else background.customizationSetName ?: ""
|
||||
if (section != lastSection && background.customizationSet != "incentiveBackgrounds") {
|
||||
viewModel.items.add(section)
|
||||
lastSection = section
|
||||
}
|
||||
viewModel.items.add(background)
|
||||
}
|
||||
} else {
|
||||
viewModel.items.addAll(customizations)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -433,7 +445,7 @@ class ComposeAvatarCustomizationFragment :
|
|||
private fun AvatarCustomizationView(
|
||||
avatar: Avatar?,
|
||||
configManager: AppConfigManager,
|
||||
customizations: List<Customization>,
|
||||
items: List<Any>,
|
||||
userSize: String,
|
||||
hairColor: String?,
|
||||
type: String?,
|
||||
|
|
@ -480,29 +492,40 @@ private fun AvatarCustomizationView(
|
|||
modifier = Modifier.padding(10.dp),
|
||||
)
|
||||
}
|
||||
if (customizations.size > 1) {
|
||||
items(customizations) { customization ->
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier =
|
||||
if (items.size > 1) {
|
||||
items(items, span = { item -> if (item is Customization) GridItemSpan(1) else GridItemSpan(3) }) { item ->
|
||||
if (item is Customization) {
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier =
|
||||
Modifier
|
||||
.padding(4.dp)
|
||||
.border(if (activeCustomization == customization.identifier) 2.dp else 0.dp, if (activeCustomization == customization.identifier) HabiticaTheme.colors.tintedUiMain else colorResource(R.color.transparent), RoundedCornerShape(8.dp))
|
||||
.border(if (activeCustomization == item.identifier) 2.dp else 0.dp, if (activeCustomization == item.identifier) HabiticaTheme.colors.tintedUiMain else colorResource(R.color.transparent), RoundedCornerShape(8.dp))
|
||||
.size(76.dp)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.clickable {
|
||||
onSelect(customization)
|
||||
onSelect(item)
|
||||
}
|
||||
.background(colorResource(id = R.color.window_background)),
|
||||
) {
|
||||
if (customization.identifier.isNullOrBlank() || customization.identifier == "0") {
|
||||
Image(painterResource(R.drawable.empty_slot), contentDescription = null, contentScale = ContentScale.None, modifier = Modifier.size(68.dp))
|
||||
} else {
|
||||
PixelArtView(
|
||||
imageName = customization.getIconName(userSize, hairColor),
|
||||
Modifier.size(68.dp),
|
||||
)
|
||||
) {
|
||||
if (item.identifier.isNullOrBlank() || item.identifier == "0") {
|
||||
Image(painterResource(R.drawable.empty_slot), contentDescription = null, contentScale = ContentScale.None, modifier = Modifier.size(68.dp))
|
||||
} else {
|
||||
PixelArtView(
|
||||
imageName = item.getIconName(userSize, hairColor),
|
||||
Modifier.size(68.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if (item is String) {
|
||||
Text(
|
||||
item.uppercase(),
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
color = colorResource(id = R.color.text_ternary),
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.padding(10.dp).padding(top = 16.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -510,21 +533,23 @@ private fun AvatarCustomizationView(
|
|||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier =
|
||||
Modifier.padding(top = 40.dp).clickable {
|
||||
Modifier.padding(top = 56.dp).clickable {
|
||||
MainNavigationController.navigate(R.id.customizationsShopFragment)
|
||||
},
|
||||
) {
|
||||
Image(
|
||||
painterResource(if (type == "backgrounds") R.drawable.customization_background else R.drawable.customization_mix),
|
||||
null,
|
||||
modifier = Modifier.padding(bottom = 12.dp),
|
||||
modifier = Modifier.padding(bottom = 16.dp),
|
||||
)
|
||||
if (customizations.size <= 1) {
|
||||
Text(stringResource(R.string.customizations_no_owned), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colorResource(R.color.text_secondary))
|
||||
Text(stringResource(R.string.customization_shop_check_out), fontSize = 13.sp, color = colorResource(R.color.text_ternary), textAlign = TextAlign.Center)
|
||||
if (items.size <= 1) {
|
||||
Text(stringResource(R.string.customizations_no_owned), fontSize = 16.sp, fontWeight = FontWeight.Bold, color = colorResource(R.color.text_secondary),
|
||||
modifier = Modifier.padding(bottom = 2.dp))
|
||||
Text(stringResource(R.string.customization_shop_check_out), fontSize = 14.sp, color = colorResource(R.color.text_ternary), textAlign = TextAlign.Center)
|
||||
} else {
|
||||
Text(stringResource(R.string.looking_for_more), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colorResource(R.color.text_secondary))
|
||||
Text(stringResource(R.string.customization_shop_more), fontSize = 13.sp, color = colorResource(R.color.text_ternary), textAlign = TextAlign.Center)
|
||||
Text(stringResource(R.string.looking_for_more), fontSize = 16.sp, fontWeight = FontWeight.Bold, color = colorResource(R.color.text_secondary),
|
||||
modifier = Modifier.padding(bottom = 2.dp))
|
||||
Text(stringResource(R.string.customization_shop_more), fontSize = 14.sp, color = colorResource(R.color.text_ternary), textAlign = TextAlign.Center)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ fun HabiticaColors.contentBackgroundFor(task: Task?): Color {
|
|||
@Composable
|
||||
fun HabiticaColors.pixelArtBackground(hasIcon: Boolean): Color {
|
||||
return if (isSystemInDarkTheme()) {
|
||||
colorResource(if (hasIcon) R.color.gray_200 else R.color.gray_5)
|
||||
colorResource(if (hasIcon) R.color.gray_50 else R.color.gray_5)
|
||||
} else {
|
||||
colorResource(if (hasIcon) R.color.content_background else R.color.content_background_offset)
|
||||
colorResource(if (hasIcon) R.color.window_background else R.color.content_background_offset)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ fun OverviewItem(
|
|||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier =
|
||||
modifier
|
||||
.width(70.dp),
|
||||
.width(76.dp),
|
||||
) {
|
||||
Box(
|
||||
Modifier
|
||||
.size(70.dp)
|
||||
.size(76.dp)
|
||||
.clip(MaterialTheme.shapes.small)
|
||||
.background(HabiticaTheme.colors.pixelArtBackground(hasIcon)),
|
||||
contentAlignment = Alignment.Center,
|
||||
|
|
@ -66,7 +66,7 @@ fun OverviewItem(
|
|||
imageName = iconName,
|
||||
modifier =
|
||||
Modifier
|
||||
.size(70.dp),
|
||||
.size(76.dp),
|
||||
)
|
||||
} else {
|
||||
Image(painterResource(R.drawable.empty_slot), null)
|
||||
|
|
@ -75,7 +75,7 @@ fun OverviewItem(
|
|||
Text(
|
||||
text,
|
||||
style = HabiticaTheme.typography.caption2,
|
||||
color = colorResource(R.color.text_ternary),
|
||||
color = colorResource(R.color.text_secondary),
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.padding(top = 4.dp),
|
||||
)
|
||||
|
|
@ -297,7 +297,7 @@ fun AvatarCustomizationOverviewView(
|
|||
fun EquipmentOverviewItemPreview() {
|
||||
Column(Modifier.width(320.dp)) {
|
||||
Row(
|
||||
modifier = Modifier.background(colorResource(id = R.color.equipment_overview_background)),
|
||||
modifier = Modifier.background(colorResource(id = R.color.equipment_column_background)),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
OverviewItem("Main-Hand", "shop_weapon_warrior_1")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.3.7
|
||||
CODE=7591
|
||||
CODE=7601
|
||||
Loading…
Reference in a new issue