WriteopiaStateManager

class WriteopiaStateManager(stepsNormalizer: UnitsNormalizationMap = StepsMapNormalizationBuilder.reduceNormalizations { defaultNormalizers() }, dispatcher: CoroutineDispatcher, coroutineScope: CoroutineScope = CoroutineScope(EmptyCoroutineContext), backStackManager: BackstackManager, userId: suspend () -> String = { "no_user_id_provided" }, writeopiaManager: WriteopiaManager) : BackstackHandler, BackstackInform

This is the entry class of the framework. It follows the Controller pattern, redirecting all the call to another class responsible for the part of the SDK requested.

Constructors

Link copied to clipboard
constructor(stepsNormalizer: UnitsNormalizationMap = StepsMapNormalizationBuilder.reduceNormalizations { defaultNormalizers() }, dispatcher: CoroutineDispatcher, coroutineScope: CoroutineScope = CoroutineScope(EmptyCoroutineContext), backStackManager: BackstackManager, userId: suspend () -> String = { "no_user_id_provided" }, writeopiaManager: WriteopiaManager)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val canRedo: StateFlow<Boolean>

Notifies if it is possible to redo an action.

Link copied to clipboard
open override val canUndo: StateFlow<Boolean>

Notifies if it is possible to undo an action.

Link copied to clipboard
Link copied to clipboard
val currentStory: StateFlow<StoryState>
Link copied to clipboard
val onEditPositions: StateFlow<Set<Int>>
Link copied to clipboard
val scrollToPosition: StateFlow<Int?>
Link copied to clipboard
val toDraw: Flow<DrawState>

Functions

Link copied to clipboard

At the moment it is only possible to check items not inside groups. Todo: Fix it!

Link copied to clipboard

At the moment it is only possible to check items not inside groups. Todo: Fix it!

Link copied to clipboard
fun changeStoryType(position: Int, storyType: StoryType, commandInfo: CommandInfo?)

Changes the story type. The type of a messages changes without changing the content of it. Commands normally change the type of a message. From a message to a unordered list item, for example.

Link copied to clipboard

A click at the end of the document. The focus should be moved to the first StoryStep that can receive the focus, from last to first.

Link copied to clipboard

Deletes the whole selection. All StoryStep in the selection will be deleted.

Link copied to clipboard
Link copied to clipboard
fun liveSync(sharedEditionManager: SharedEditionManager)
Link copied to clipboard
fun loadDocument(document: Document)

Initializes a document passed as a parameter. This method should be used when you would like to load a document from a database and start editing it, instead of creating something new.

Link copied to clipboard

Merges two StoryStep into a group. This can be used to merge two images into a message group or any other kind of group.

Link copied to clipboard

A request to move a content to a position.

Link copied to clipboard
fun newStory(documentId: String = GenerateId.generate(), title: String = "", forceRestart: Boolean = false)

Creates a new story. Use this when you wouldn't like to load a documented previously saved.

Link copied to clipboard
fun nextFocusOrCreate(position: Int)

Moves the focus to the next available StoryStep if it can't find a step to focus, it creates a new StoryStep at the end of the document.

Link copied to clipboard
fun onClear()

Clears the WriteopiaStateManager. Use this in the onCleared of your ViewModel.

Link copied to clipboard
fun onDelete(deleteStory: Action.DeleteStory)

Deletes a StoryStep

Link copied to clipboard

Creates a line break. When a line break happens, the line it divided into two StorySteps of the same, if possible, or the next line will be a Message.

Link copied to clipboard
fun onSelected(isSelected: Boolean, position: Int)

Add a StoryStep of a position into the selection list. Selected content can be used to perform bulk actions, like bulk edition and bulk deletion.

Link copied to clipboard
open override fun redo()

Redo the last undone action.

Link copied to clipboard
fun saveOnStoryChanges(documentTracker: DocumentTracker)

Saves the document automatically as it is changed. It uses the DocumentTracker passed in the constructor of WriteopiaStateManager

Link copied to clipboard
open override fun undo()

Undo the last action.