Merge pull request #489 from android/av/remove-tab-state

Remove tab state from InterestsViewModel
pull/493/head
Don Turner 2 years ago committed by GitHub
commit 7a8414e46d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,7 +17,6 @@
package com.google.samples.apps.nowinandroid.feature.interests package com.google.samples.apps.nowinandroid.feature.interests
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -51,7 +50,6 @@ internal fun InterestsRoute(
) )
} }
@OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
internal fun InterestsScreen( internal fun InterestsScreen(
uiState: InterestsUiState, uiState: InterestsUiState,

@ -24,10 +24,8 @@ import com.google.samples.apps.nowinandroid.core.domain.TopicSortField
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -38,14 +36,6 @@ class InterestsViewModel @Inject constructor(
getFollowableTopics: GetFollowableTopicsUseCase, getFollowableTopics: GetFollowableTopicsUseCase,
) : ViewModel() { ) : ViewModel() {
private val _tabState = MutableStateFlow(
InterestsTabState(
titles = listOf(R.string.interests_topics, R.string.interests_people),
currentIndex = 0
)
)
val tabState: StateFlow<InterestsTabState> = _tabState.asStateFlow()
val uiState: StateFlow<InterestsUiState> = val uiState: StateFlow<InterestsUiState> =
getFollowableTopics(sortBy = TopicSortField.NAME).map( getFollowableTopics(sortBy = TopicSortField.NAME).map(
InterestsUiState::Interests InterestsUiState::Interests
@ -62,11 +52,6 @@ class InterestsViewModel @Inject constructor(
} }
} }
data class InterestsTabState(
val titles: List<Int>,
val currentIndex: Int
)
sealed interface InterestsUiState { sealed interface InterestsUiState {
object Loading : InterestsUiState object Loading : InterestsUiState

@ -17,8 +17,6 @@
<resources> <resources>
<!-- TODO: Remove the redundant "interests" prefix --> <!-- TODO: Remove the redundant "interests" prefix -->
<string name="interests">Interests</string> <string name="interests">Interests</string>
<string name="interests_topics">Topics</string>
<string name="interests_people">People</string>
<string name="interests_loading">Loading data</string> <string name="interests_loading">Loading data</string>
<string name="interests_empty_header">"No available data"</string> <string name="interests_empty_header">"No available data"</string>
<string name="interests_card_follow_button_content_desc">Follow interest button</string> <string name="interests_card_follow_button_content_desc">Follow interest button</string>

Loading…
Cancel
Save