mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-24 20:02:16 +00:00
Add: Check the selected category on launch/resume
This commit is contained in:
parent
555bf1f14f
commit
e7295d90d6
@ -6,9 +6,11 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.material.Scaffold
|
import androidx.compose.material.Scaffold
|
||||||
|
import androidx.core.view.children
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import com.looker.droidify.R
|
import com.looker.droidify.R
|
||||||
import com.looker.droidify.content.Preferences
|
import com.looker.droidify.content.Preferences
|
||||||
|
import com.looker.droidify.database.entity.Category
|
||||||
import com.looker.droidify.database.entity.Repository
|
import com.looker.droidify.database.entity.Repository
|
||||||
import com.looker.droidify.databinding.FragmentExploreXBinding
|
import com.looker.droidify.databinding.FragmentExploreXBinding
|
||||||
import com.looker.droidify.entity.Section
|
import com.looker.droidify.entity.Section
|
||||||
@ -64,14 +66,23 @@ class ExploreFragment : MainNavFragmentX() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewModel.categories.observe(viewLifecycleOwner) {
|
viewModel.categories.observe(viewLifecycleOwner) {
|
||||||
binding.categories.removeAllViews()
|
binding.categories.apply {
|
||||||
binding.categories.addView(Chip(requireContext(), null, R.attr.chipStyle).apply {
|
removeAllViews()
|
||||||
setText(R.string.all_applications)
|
addView(Chip(requireContext(), null, R.attr.chipStyle).apply {
|
||||||
})
|
setText(R.string.all_applications)
|
||||||
it.forEach {
|
id = R.id.SHOW_ALL
|
||||||
binding.categories.addView(Chip(requireContext(), null, R.attr.chipStyle).apply {
|
|
||||||
text = it
|
|
||||||
})
|
})
|
||||||
|
it.forEach {
|
||||||
|
addView(Chip(requireContext(), null, R.attr.chipStyle).apply {
|
||||||
|
text = it
|
||||||
|
})
|
||||||
|
}
|
||||||
|
val selectedSection = viewModel.sections.value
|
||||||
|
check(
|
||||||
|
children.filterNotNull()
|
||||||
|
.find { it is Chip && selectedSection is Category && it.text == selectedSection.name }?.id
|
||||||
|
?: R.id.SHOW_ALL
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.categories.setOnCheckedChangeListener { group, checkedId ->
|
binding.categories.setOnCheckedChangeListener { group, checkedId ->
|
||||||
|
@ -19,9 +19,12 @@ class MainNavFragmentViewModelX(
|
|||||||
secondarySource: Source
|
secondarySource: Source
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
private val order = MutableLiveData(Order.LAST_UPDATE)
|
var order = MutableLiveData(Order.LAST_UPDATE)
|
||||||
private val sections = MutableLiveData<Section>(Section.All)
|
private set
|
||||||
private val searchQuery = MutableLiveData("")
|
var sections = MutableLiveData<Section>(Section.All)
|
||||||
|
private set
|
||||||
|
var searchQuery = MutableLiveData("")
|
||||||
|
private set
|
||||||
|
|
||||||
fun request(source: Source): Request {
|
fun request(source: Source): Request {
|
||||||
var mSearchQuery = ""
|
var mSearchQuery = ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user