Add the search feature inside the character sheet.
This commit is contained in:
parent
719ebd4c5e
commit
2eff9f8e2f
3 changed files with 62 additions and 24 deletions
|
|
@ -6,8 +6,6 @@ import android.content.res.Configuration
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.combinedClickable
|
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.BoxScope
|
import androidx.compose.foundation.layout.BoxScope
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
|
@ -24,12 +22,15 @@ import androidx.compose.material.ModalBottomSheetLayout
|
||||||
import androidx.compose.material.ModalBottomSheetState
|
import androidx.compose.material.ModalBottomSheetState
|
||||||
import androidx.compose.material.ModalBottomSheetValue
|
import androidx.compose.material.ModalBottomSheetValue
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.MoreVert
|
||||||
import androidx.compose.material.icons.filled.Refresh
|
import androidx.compose.material.icons.filled.Refresh
|
||||||
|
import androidx.compose.material.icons.filled.Search
|
||||||
import androidx.compose.material.pullrefresh.PullRefreshState
|
import androidx.compose.material.pullrefresh.PullRefreshState
|
||||||
import androidx.compose.material.pullrefresh.pullRefresh
|
import androidx.compose.material.pullrefresh.pullRefresh
|
||||||
import androidx.compose.material.pullrefresh.rememberPullRefreshState
|
import androidx.compose.material.pullrefresh.rememberPullRefreshState
|
||||||
import androidx.compose.material.rememberModalBottomSheetState
|
import androidx.compose.material.rememberModalBottomSheetState
|
||||||
import androidx.compose.material.ripple.rememberRipple
|
import androidx.compose.material3.DropdownMenu
|
||||||
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
|
@ -40,7 +41,6 @@ import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Tab
|
import androidx.compose.material3.Tab
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.material3.minimumInteractiveComponentSize
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
|
|
@ -53,7 +53,6 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.semantics.Role
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||||
|
|
@ -67,6 +66,7 @@ import com.pixelized.rplexicon.ui.composable.Loader
|
||||||
import com.pixelized.rplexicon.ui.composable.edit.HandleHitPointEditDialog
|
import com.pixelized.rplexicon.ui.composable.edit.HandleHitPointEditDialog
|
||||||
import com.pixelized.rplexicon.ui.composable.error.HandleFetchError
|
import com.pixelized.rplexicon.ui.composable.error.HandleFetchError
|
||||||
import com.pixelized.rplexicon.ui.navigation.LocalScreenNavHost
|
import com.pixelized.rplexicon.ui.navigation.LocalScreenNavHost
|
||||||
|
import com.pixelized.rplexicon.ui.navigation.screens.navigateToSearch
|
||||||
import com.pixelized.rplexicon.ui.screens.character.CharacterTabUio.Action
|
import com.pixelized.rplexicon.ui.screens.character.CharacterTabUio.Action
|
||||||
import com.pixelized.rplexicon.ui.screens.character.CharacterTabUio.Alteration
|
import com.pixelized.rplexicon.ui.screens.character.CharacterTabUio.Alteration
|
||||||
import com.pixelized.rplexicon.ui.screens.character.CharacterTabUio.Inventory
|
import com.pixelized.rplexicon.ui.screens.character.CharacterTabUio.Inventory
|
||||||
|
|
@ -131,10 +131,11 @@ fun CharacterSheetScreen(
|
||||||
)
|
)
|
||||||
val refresh = rememberPullRefreshState(
|
val refresh = rememberPullRefreshState(
|
||||||
refreshing = false,
|
refreshing = false,
|
||||||
onRefresh = { scope.launch { viewModel.update(force = true) } },
|
onRefresh = { scope.launch { viewModel.update(force = true, full = false) } },
|
||||||
)
|
)
|
||||||
val tabs = rememberHeaderTabsState()
|
val tabs = rememberHeaderTabsState()
|
||||||
val pagerState = rememberPagerState { tabs.value.size }
|
val pagerState = rememberPagerState { tabs.value.size }
|
||||||
|
val isMenuExpended = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
|
@ -144,6 +145,7 @@ fun CharacterSheetScreen(
|
||||||
pagerState = pagerState,
|
pagerState = pagerState,
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
refreshState = refresh,
|
refreshState = refresh,
|
||||||
|
isMenuExpended = isMenuExpended,
|
||||||
name = viewModel.character,
|
name = viewModel.character,
|
||||||
tabs = tabs,
|
tabs = tabs,
|
||||||
header = headerViewModel.header,
|
header = headerViewModel.header,
|
||||||
|
|
@ -160,8 +162,14 @@ fun CharacterSheetScreen(
|
||||||
},
|
},
|
||||||
onDeathSuccess = headerViewModel::onDeathSuccess,
|
onDeathSuccess = headerViewModel::onDeathSuccess,
|
||||||
onDeathFailure = headerViewModel::onDeathFailure,
|
onDeathFailure = headerViewModel::onDeathFailure,
|
||||||
onRefresh = {
|
onMenuRequest = { isMenuExpended.value = it },
|
||||||
scope.launch { viewModel.update(force = true) }
|
onSearch = {
|
||||||
|
screen.navigateToSearch(
|
||||||
|
enableLexicon = true,
|
||||||
|
enableQuests = true,
|
||||||
|
enableLocations = true,
|
||||||
|
enableSpells = true,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
onFullRefresh = {
|
onFullRefresh = {
|
||||||
scope.launch { viewModel.update(force = true, full = true) }
|
scope.launch { viewModel.update(force = true, full = true) }
|
||||||
|
|
@ -241,7 +249,9 @@ private fun CharacterSheetContent(
|
||||||
pagerState: PagerState,
|
pagerState: PagerState,
|
||||||
sheetState: ModalBottomSheetState,
|
sheetState: ModalBottomSheetState,
|
||||||
refreshState: PullRefreshState,
|
refreshState: PullRefreshState,
|
||||||
onRefresh: () -> Unit,
|
isMenuExpended: State<Boolean>,
|
||||||
|
onMenuRequest: (Boolean) -> Unit,
|
||||||
|
onSearch: () -> Unit,
|
||||||
onFullRefresh: () -> Unit,
|
onFullRefresh: () -> Unit,
|
||||||
name: String,
|
name: String,
|
||||||
tabs: State<List<CharacterTabUio>>,
|
tabs: State<List<CharacterTabUio>>,
|
||||||
|
|
@ -274,21 +284,45 @@ private fun CharacterSheetContent(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
Box(
|
IconButton(onClick = { onMenuRequest(!isMenuExpended.value) }) {
|
||||||
modifier = Modifier
|
|
||||||
.minimumInteractiveComponentSize()
|
|
||||||
.combinedClickable(
|
|
||||||
onClick = onRefresh,
|
|
||||||
onLongClick = onFullRefresh,
|
|
||||||
role = Role.Button,
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
|
||||||
indication = rememberRipple(bounded = false)
|
|
||||||
),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Refresh,
|
imageVector = Icons.Filled.MoreVert,
|
||||||
contentDescription = null,
|
contentDescription = "More",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = isMenuExpended.value,
|
||||||
|
onDismissRequest = { onMenuRequest(false) },
|
||||||
|
) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
leadingIcon = {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.Search,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(text = stringResource(id = R.string.search_field_title))
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
onMenuRequest(false)
|
||||||
|
onSearch()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
DropdownMenuItem(
|
||||||
|
leadingIcon = {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.Refresh,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(text = stringResource(id = R.string.character_sheet_refresh_label))
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
onMenuRequest(false)
|
||||||
|
onFullRefresh()
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -456,9 +490,11 @@ private fun CharacterScreenPreview(
|
||||||
name = "Brulkhai",
|
name = "Brulkhai",
|
||||||
header = rememberCharacterHeaderStatePreview(),
|
header = rememberCharacterHeaderStatePreview(),
|
||||||
tabs = rememberHeaderPreview(),
|
tabs = rememberHeaderPreview(),
|
||||||
|
isMenuExpended = remember { mutableStateOf(false) },
|
||||||
|
onMenuRequest = { },
|
||||||
onBack = { },
|
onBack = { },
|
||||||
onTab = { },
|
onTab = { },
|
||||||
onRefresh = { },
|
onSearch = { },
|
||||||
onFullRefresh = { },
|
onFullRefresh = { },
|
||||||
loader = { },
|
loader = { },
|
||||||
onHitPoint = { },
|
onHitPoint = { },
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@
|
||||||
<string name="map_destination">Destinations :</string>
|
<string name="map_destination">Destinations :</string>
|
||||||
<string name="map_illustrations">Illustrations :</string>
|
<string name="map_illustrations">Illustrations :</string>
|
||||||
|
|
||||||
|
<string name="character_sheet_refresh_label">Rafraichir</string>
|
||||||
<string name="character_sheet_tab_proficiency">Talents</string>
|
<string name="character_sheet_tab_proficiency">Talents</string>
|
||||||
<string name="character_sheet_tab_inventory">Inventaire</string>
|
<string name="character_sheet_tab_inventory">Inventaire</string>
|
||||||
<string name="character_sheet_tab_alteration">Altérations</string>
|
<string name="character_sheet_tab_alteration">Altérations</string>
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@
|
||||||
<string name="map_destination">Destinations:</string>
|
<string name="map_destination">Destinations:</string>
|
||||||
<string name="map_illustrations">Illustrations:</string>
|
<string name="map_illustrations">Illustrations:</string>
|
||||||
|
|
||||||
|
<string name="character_sheet_refresh_label">Refresh</string>
|
||||||
<string name="character_sheet_tab_proficiency">Proficiencies</string>
|
<string name="character_sheet_tab_proficiency">Proficiencies</string>
|
||||||
<string name="character_sheet_tab_inventory">Inventory</string>
|
<string name="character_sheet_tab_inventory">Inventory</string>
|
||||||
<string name="character_sheet_tab_alteration">Alterations</string>
|
<string name="character_sheet_tab_alteration">Alterations</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue