Merge branch 'github/main'

pull/58/head
kbuilder 3 years ago
commit 91b9f12074

@ -276,7 +276,7 @@ View models receive streams of data as cold [flows](https://kotlin.github.io/kot
**Example: Displaying followed topics and authors**
The `FollowingViewModel` exposes `uiState` as a `StateFlow<FollowingUiState>`. This hot flow is created by combining four data streams:
The `InterestsViewModel` exposes `uiState` as a `StateFlow<InterestsUiState>`. This hot flow is created by combining four data streams:
@ -287,7 +287,7 @@ The `FollowingViewModel` exposes `uiState` as a `StateFlow<FollowingUiState>`. T
The list of `Author`s is mapped to a new list of `FollowableAuthor`s. `FollowableAuthor` is a wrapper for `Author` which also indicates whether the current user is following that author. The same transformation is applied for the list of `Topic`s.
The two new lists are used to create a `FollowingUiState.Interests` state which is exposed to the UI.
The two new lists are used to create a `InterestsUiState.Interests` state which is exposed to the UI.
### Processing user interactions
@ -296,7 +296,7 @@ User actions are communicated from UI elements to view models using regular meth
**Example: Following a topic**
The `FollowingScreen` takes a lambda expression named `followTopic` which is supplied from `FollowingViewModel.followTopic`. Each time the user taps on a topic to follow this method is called. The view model then processes this action by informing the topics repository.
The `InterestsScreen` takes a lambda expression named `followTopic` which is supplied from `InterestsViewModel.followTopic`. Each time the user taps on a topic to follow this method is called. The view model then processes this action by informing the topics repository.
## Further reading

@ -50,8 +50,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.outlined.AccountCircle
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
@ -90,6 +88,7 @@ import com.google.samples.apps.nowinandroid.core.model.data.SaveableNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.ui.LoadingWheel
import com.google.samples.apps.nowinandroid.core.ui.NewsResourceCardExpanded
import com.google.samples.apps.nowinandroid.core.ui.component.NiaFilledButton
import com.google.samples.apps.nowinandroid.core.ui.component.NiaGradientBackground
import com.google.samples.apps.nowinandroid.core.ui.component.NiaToggleButton
import com.google.samples.apps.nowinandroid.core.ui.component.NiaTopAppBar
@ -275,19 +274,15 @@ private fun LazyListScope.InterestsSelection(
horizontalArrangement = Arrangement.Center,
modifier = Modifier.fillMaxWidth()
) {
Button(
NiaFilledButton(
onClick = saveFollowedTopics,
enabled = interestsSelectionState.canSaveInterests,
modifier = Modifier
.padding(horizontal = 40.dp)
.width(364.dp),
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.onBackground
)
.width(364.dp)
) {
Text(
text = stringResource(R.string.done),
color = MaterialTheme.colorScheme.onPrimary
text = stringResource(R.string.done)
)
}
}

Loading…
Cancel
Save