M app/src/main/java/com/github/nacabaro/vbhelper/components/CharacterEntry.kt => app/src/main/java/com/github/nacabaro/vbhelper/components/CharacterEntry.kt +3 -11
@@ 1,6 1,5 @@
package com.github.nacabaro.vbhelper.components
-import android.util.Log
import android.widget.Toast
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
@@ 23,22 22,18 @@ import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
import com.github.nacabaro.vbhelper.utils.BitmapData
import com.github.nacabaro.vbhelper.utils.getBitmap
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.unit.Dp
-import androidx.compose.ui.unit.TextUnit
import com.github.nacabaro.vbhelper.utils.getObscuredBitmap
-import java.nio.ByteBuffer
@Composable
fun CharacterEntry(
icon: BitmapData,
- obscure: Boolean = false,
modifier: Modifier = Modifier,
+ obscure: Boolean = false,
shape: Shape = MaterialTheme.shapes.medium,
multiplier: Int = 3,
onClick: () -> Unit = { }
@@ 79,8 74,6 @@ fun ItemDisplay(
icon: Int,
textValue: String,
modifier: Modifier = Modifier,
- iconSize: Dp = 48.dp,
- textSize: TextUnit = 24.sp,
definition: String = "",
) {
val context = LocalContext.current
@@ 101,15 94,14 @@ fun ItemDisplay(
painter = painterResource(icon),
contentDescription = "Vitals",
modifier = Modifier
+ .fillMaxSize(0.5f)
.padding(8.dp)
- .size(iconSize)
)
Text(
text = textValue,
textAlign = TextAlign.Center,
- fontSize = textSize,
fontFamily = MaterialTheme.typography.titleLarge.fontFamily,
- fontWeight = FontWeight.Bold
+ fontWeight = FontWeight.Bold,
)
}
}
M app/src/main/java/com/github/nacabaro/vbhelper/components/ItemElement.kt => app/src/main/java/com/github/nacabaro/vbhelper/components/ItemElement.kt +6 -5
@@ 25,6 25,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.github.nacabaro.vbhelper.R
+import com.github.nacabaro.vbhelper.screens.itemsScreen.ItemsScreenControllerImpl
import com.github.nacabaro.vbhelper.ui.theme.VBHelperTheme
import kotlin.math.absoluteValue
@@ 159,11 160,11 @@ fun ItemDialog(
fun getIconResource(index: Int): Int {
return when (index) {
- 1 -> R.drawable.baseline_agility_24
- 2 -> R.drawable.baseline_attack_24
- 3 -> R.drawable.baseline_shield_24
- 4 -> R.drawable.baseline_trophy_24
- 5 -> R.drawable.baseline_arrow_up_24
+ ItemsScreenControllerImpl.ItemTypes.PPTraining.id -> R.drawable.baseline_agility_24
+ ItemsScreenControllerImpl.ItemTypes.APTraining.id -> R.drawable.baseline_attack_24
+ ItemsScreenControllerImpl.ItemTypes.HPTraining.id -> R.drawable.baseline_shield_24
+ ItemsScreenControllerImpl.ItemTypes.BPTraining.id -> R.drawable.baseline_trophy_24
+ ItemsScreenControllerImpl.ItemTypes.AllTraining.id -> R.drawable.baseline_arrow_up_24
6 -> R.drawable.baseline_timer_24
7 -> R.drawable.baseline_rank_24
8 -> R.drawable.baseline_vitals_24
M app/src/main/java/com/github/nacabaro/vbhelper/screens/StorageScreen.kt => app/src/main/java/com/github/nacabaro/vbhelper/screens/StorageScreen.kt +21 -21
@@ 99,31 99,31 @@ fun StorageScreen(
selectedCharacter = index.id
}
)
+ }
+ }
- if (selectedCharacter != null) {
- StorageDialog(
- characterId = selectedCharacter!!,
- onDismissRequest = { selectedCharacter = null },
- onClickSetActive = {
- coroutineScope.launch {
- withContext(Dispatchers.IO) {
- storageRepository.setActiveCharacter(selectedCharacter!!)
- selectedCharacter = null
- }
- navController.navigate(NavigationItems.Home.route)
- }
- },
- onSendToBracelet = {
- navController.navigate(
- NavigationItems.Scan.route.replace(
- "{characterId}",
- selectedCharacter.toString()
- )
- )
+ if (selectedCharacter != null) {
+ StorageDialog(
+ characterId = selectedCharacter!!,
+ onDismissRequest = { selectedCharacter = null },
+ onClickSetActive = {
+ coroutineScope.launch {
+ withContext(Dispatchers.IO) {
+ storageRepository.setActiveCharacter(selectedCharacter!!)
+ selectedCharacter = null
}
+ navController.navigate(NavigationItems.Home.route)
+ }
+ },
+ onSendToBracelet = {
+ navController.navigate(
+ NavigationItems.Scan.route.replace(
+ "{characterId}",
+ selectedCharacter.toString()
+ )
)
}
- }
+ )
}
}
}
M app/src/main/java/com/github/nacabaro/vbhelper/screens/homeScreens/BEBEmHomeScreen.kt => app/src/main/java/com/github/nacabaro/vbhelper/screens/homeScreens/BEBEmHomeScreen.kt +20 -0
@@ 15,8 15,10 @@ import com.github.nacabaro.vbhelper.R
import com.github.nacabaro.vbhelper.components.CharacterEntry
import com.github.nacabaro.vbhelper.components.ItemDisplay
import com.github.nacabaro.vbhelper.components.TransformationHistoryCard
+import com.github.nacabaro.vbhelper.components.getIconResource
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
+import com.github.nacabaro.vbhelper.screens.itemsScreen.ItemsScreenControllerImpl
import com.github.nacabaro.vbhelper.utils.BitmapData
import java.util.Locale
@@ 153,6 155,24 @@ fun BEBEmHomeScreen(
.aspectRatio(1f)
.padding(8.dp)
)
+ if (beData.itemRemainingTime != 0) {
+ ItemDisplay(
+ icon = getIconResource(beData.itemType),
+ textValue = "${beData.itemRemainingTime} m",
+ definition = when (beData.itemType) {
+ ItemsScreenControllerImpl.ItemTypes.PPTraining.id -> "PP Training"
+ ItemsScreenControllerImpl.ItemTypes.HPTraining.id -> "HP Training"
+ ItemsScreenControllerImpl.ItemTypes.APTraining.id -> "AP Training"
+ ItemsScreenControllerImpl.ItemTypes.BPTraining.id -> "BP Training"
+ ItemsScreenControllerImpl.ItemTypes.AllTraining.id -> "All Training"
+ else -> ""
+ },
+ modifier = Modifier
+ .weight(1f)
+ .aspectRatio(1f)
+ .padding(8.dp)
+ )
+ }
}
Row (
modifier = Modifier
M app/src/main/java/com/github/nacabaro/vbhelper/screens/homeScreens/BEDiMHomeScreen.kt => app/src/main/java/com/github/nacabaro/vbhelper/screens/homeScreens/BEDiMHomeScreen.kt +39 -9
@@ 16,8 16,10 @@ import com.github.nacabaro.vbhelper.R
import com.github.nacabaro.vbhelper.components.CharacterEntry
import com.github.nacabaro.vbhelper.components.ItemDisplay
import com.github.nacabaro.vbhelper.components.TransformationHistoryCard
+import com.github.nacabaro.vbhelper.components.getIconResource
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
+import com.github.nacabaro.vbhelper.screens.itemsScreen.ItemsScreenControllerImpl
import com.github.nacabaro.vbhelper.utils.BitmapData
import kotlin.text.format
@@ 33,7 35,7 @@ fun BEDiMHomeScreen(
.padding(top = contentPadding.calculateTopPadding())
.verticalScroll(state = rememberScrollState())
) {
- Row (
+ Row(
modifier = Modifier
.fillMaxWidth()
) {
@@ 49,7 51,7 @@ fun BEDiMHomeScreen(
.weight(1f)
.aspectRatio(1f)
)
- Column (
+ Column(
modifier = Modifier
.weight(0.5f)
.aspectRatio(0.5f)
@@ 74,7 76,7 @@ fun BEDiMHomeScreen(
)
}
}
- Row (
+ Row(
modifier = Modifier
.fillMaxWidth()
) {
@@ 108,7 110,7 @@ fun BEDiMHomeScreen(
.padding(8.dp)
)
}
- Row (
+ Row(
modifier = Modifier
.fillMaxWidth()
) {
@@ 130,8 132,13 @@ fun BEDiMHomeScreen(
textValue = when {
activeMon.totalBattlesLost == 0 -> "0.00 %"
else -> {
- val battleWinPercentage = activeMon.totalBattlesWon.toFloat() / (activeMon.totalBattlesWon + activeMon.totalBattlesLost).toFloat()
- String.format(Locale.getDefault(), "%.2f", battleWinPercentage * 100) + " %" // Specify locale
+ val battleWinPercentage =
+ activeMon.totalBattlesWon.toFloat() / (activeMon.totalBattlesWon + activeMon.totalBattlesLost).toFloat()
+ String.format(
+ Locale.getDefault(),
+ "%.2f",
+ battleWinPercentage * 100
+ ) + " %" // Specify locale
}
},
definition = "Total battle win %",
@@ 145,8 152,13 @@ fun BEDiMHomeScreen(
textValue = when {
activeMon.totalBattlesLost == 0 -> "0.00 %"
else -> {
- val battleWinPercentage = activeMon.currentPhaseBattlesWon.toFloat() / (activeMon.currentPhaseBattlesWon + activeMon.currentPhaseBattlesLost).toFloat()
- String.format(Locale.getDefault(), "%.2f", battleWinPercentage * 100) + " %" // Specify locale
+ val battleWinPercentage =
+ activeMon.currentPhaseBattlesWon.toFloat() / (activeMon.currentPhaseBattlesWon + activeMon.currentPhaseBattlesLost).toFloat()
+ String.format(
+ Locale.getDefault(),
+ "%.2f",
+ battleWinPercentage * 100
+ ) + " %" // Specify locale
}
},
definition = "Current phase win %",
@@ 155,8 167,26 @@ fun BEDiMHomeScreen(
.aspectRatio(1f)
.padding(8.dp)
)
+ if (beData.itemRemainingTime != 0) {
+ ItemDisplay(
+ icon = getIconResource(beData.itemType),
+ textValue = "${beData.itemRemainingTime} m",
+ definition = when (beData.itemType) {
+ ItemsScreenControllerImpl.ItemTypes.PPTraining.id -> "PP Training"
+ ItemsScreenControllerImpl.ItemTypes.HPTraining.id -> "HP Training"
+ ItemsScreenControllerImpl.ItemTypes.APTraining.id -> "AP Training"
+ ItemsScreenControllerImpl.ItemTypes.BPTraining.id -> "BP Training"
+ ItemsScreenControllerImpl.ItemTypes.AllTraining.id -> "All Training"
+ else -> ""
+ },
+ modifier = Modifier
+ .weight(1f)
+ .aspectRatio(1f)
+ .padding(8.dp)
+ )
+ }
}
- Row (
+ Row(
modifier = Modifier
.fillMaxWidth()
) {
M app/src/main/java/com/github/nacabaro/vbhelper/screens/itemsScreen/ItemsScreenControllerImpl.kt => app/src/main/java/com/github/nacabaro/vbhelper/screens/itemsScreen/ItemsScreenControllerImpl.kt +2 -3
@@ 5,7 5,6 @@ import androidx.lifecycle.lifecycleScope
import com.github.nacabaro.vbhelper.database.AppDatabase
import com.github.nacabaro.vbhelper.di.VBHelper
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
-import com.github.nacabaro.vbhelper.domain.device_data.VBCharacterData
import com.github.nacabaro.vbhelper.dtos.ItemDtos
import com.github.nacabaro.vbhelper.utils.DeviceType
import kotlinx.coroutines.Dispatchers
@@ 17,7 16,7 @@ class ItemsScreenControllerImpl (
): ItemsScreenController {
private var database: AppDatabase
- private enum class ItemTypes(val id: Int) {
+ enum class ItemTypes(val id: Int) {
PPTraining(1),
HPTraining(2),
APTraining(3),
@@ 39,7 38,7 @@ class ItemsScreenControllerImpl (
val item = getItem(itemId)
val characterData = database.userCharacterDao().getCharacter(characterId)
val beCharacterData: BECharacterData
- var vbCharacterData: VBCharacterData
+ //var vbCharacterData: VBCharacterData
if (characterData.characterType == DeviceType.BEDevice) {
beCharacterData = database.userCharacterDao().getBeData(characterId)
M app/src/main/java/com/github/nacabaro/vbhelper/screens/itemsScreen/ItemsStore.kt => app/src/main/java/com/github/nacabaro/vbhelper/screens/itemsScreen/ItemsStore.kt +12 -14
@@ 32,7 32,6 @@ fun ItemsStore(
val application = LocalContext.current.applicationContext as VBHelper
val itemsRepository = ItemsRepository(application.container.db)
val myItems = remember { mutableStateOf(emptyList<ItemDtos.ItemsWithQuantities>()) }
- var showDialog by remember { mutableStateOf(false) }
var selectedElementIndex by remember { mutableStateOf<Int?>(null) }
LaunchedEffect(itemsRepository) {
@@ 55,23 54,22 @@ fun ItemsStore(
modifier = Modifier
.padding(8.dp),
onClick = {
- showDialog = true
selectedElementIndex = myItems.value.indexOf(index)
}
)
-
- if (showDialog && selectedElementIndex != null) {
- ItemDialog(
- name = myItems.value[selectedElementIndex!!].name,
- description = myItems.value[selectedElementIndex!!].description,
- itemIcon = getIconResource(myItems.value[selectedElementIndex!!].itemIcon),
- lengthIcon = getLengthResource(myItems.value[selectedElementIndex!!].itemLength),
- amount = myItems.value[selectedElementIndex!!].quantity,
- onClickUse = { },
- onClickCancel = { showDialog = false }
- )
- }
}
}
+
+ if (selectedElementIndex != null) {
+ ItemDialog(
+ name = myItems.value[selectedElementIndex!!].name,
+ description = myItems.value[selectedElementIndex!!].description,
+ itemIcon = getIconResource(myItems.value[selectedElementIndex!!].itemIcon),
+ lengthIcon = getLengthResource(myItems.value[selectedElementIndex!!].itemLength),
+ amount = myItems.value[selectedElementIndex!!].quantity,
+ onClickUse = { },
+ onClickCancel = { selectedElementIndex = null }
+ )
+ }
}
}=
\ No newline at end of file
M app/src/main/java/com/github/nacabaro/vbhelper/screens/itemsScreen/MyItems.kt => app/src/main/java/com/github/nacabaro/vbhelper/screens/itemsScreen/MyItems.kt +22 -24
@@ 37,7 37,6 @@ fun MyItems(
val application = LocalContext.current.applicationContext as VBHelper
val itemsRepository = ItemsRepository(application.container.db)
val myItems = remember { mutableStateOf(emptyList<ItemDtos.ItemsWithQuantities>()) }
- var showDialog by remember { mutableStateOf(false) }
var selectedElementIndex by remember { mutableStateOf<Int?>(null) }
LaunchedEffect(itemsRepository) {
@@ 66,34 65,33 @@ fun MyItems(
modifier = Modifier
.padding(8.dp),
onClick = {
- showDialog = true
selectedElementIndex = myItems.value.indexOf(index)
}
)
+ }
+ }
- if (showDialog && selectedElementIndex != null) {
- ItemDialog(
- name = myItems.value[selectedElementIndex!!].name,
- description = myItems.value[selectedElementIndex!!].description,
- itemIcon = getIconResource(myItems.value[selectedElementIndex!!].itemIcon),
- lengthIcon = getLengthResource(myItems.value[selectedElementIndex!!].itemLength),
- amount = myItems.value[selectedElementIndex!!].quantity,
- onClickUse = {
- showDialog = false
- navController
- .navigate(
- NavigationItems
- .ApplyItem.route
- .replace(
- "{itemId}",
- myItems.value[selectedElementIndex!!].id.toString()
- )
+ if (selectedElementIndex != null) {
+ ItemDialog(
+ name = myItems.value[selectedElementIndex!!].name,
+ description = myItems.value[selectedElementIndex!!].description,
+ itemIcon = getIconResource(myItems.value[selectedElementIndex!!].itemIcon),
+ lengthIcon = getLengthResource(myItems.value[selectedElementIndex!!].itemLength),
+ amount = myItems.value[selectedElementIndex!!].quantity,
+ onClickUse = {
+ navController
+ .navigate(
+ NavigationItems
+ .ApplyItem.route
+ .replace(
+ "{itemId}",
+ myItems.value[selectedElementIndex!!].id.toString()
)
- },
- onClickCancel = { showDialog = false }
- )
- }
- }
+ )
+ selectedElementIndex = null
+ },
+ onClickCancel = { selectedElementIndex = null }
+ )
}
}
}=
\ No newline at end of file