
Thriving in Android Development Using Kotlin
By :

In this section, we’ll focus on developing a feature for creating and editing new stories within our stories feature. We’ll begin by writing a StoryEditorScreen
composable, along with its corresponding ViewModel
, aptly named StoryEditorViewModel
. Although this ViewModel
will initially have limited functionality, we’ll expand upon it in subsequent chapters.
Let’s start creating our ViewModel
, as follows:
class StoryEditorViewModel: ViewModel() { private val _isEditing = MutableStateFlow(true) val isEditing: StateFlow<Boolean> = _isEditing }
In the preceding code, we are declaring StoryEditorViewModel
and adding a property that will indicate if our screen is in edit mode or not. Edit mode will be used when the user has taken a photo or a video and wants to add more components to it.
Now, we need to take care of the dependency injection of this ViewModel
as it must...