Class WriteopiaManager
-
- All Implemented Interfaces:
-
io.writeopia.sdk.backstack.BackstackHandler,io.writeopia.sdk.backstack.BackstackInform
public final class WriteopiaManager implements 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.
-
-
Field Summary
Fields Modifier and Type Field Description private final StateFlow<Integer>scrollToPositionprivate final StateFlow<Set<Integer>>onEditPositionsprivate final StateFlow<StoryState>currentStoryprivate final Flow<Document>currentDocumentprivate final Flow<DrawState>toDrawprivate final StateFlow<Boolean>canUndoprivate final StateFlow<Boolean>canRedo
-
Constructor Summary
Constructors Constructor Description WriteopiaManager(Function1<Map<Integer, List<StoryStep>>, Map<Integer, StoryStep>> stepsNormalizer, MovementHandler movementHandler, ContentHandler contentHandler, FocusHandler focusHandler, CoroutineScope coroutineScope, CoroutineDispatcher dispatcher, BackstackManager backStackManager, SuspendFunction0<String> userId)
-
Method Summary
Modifier and Type Method Description final StateFlow<Integer>getScrollToPosition()final StateFlow<Set<Integer>>getOnEditPositions()final StateFlow<StoryState>getCurrentStory()final Flow<Document>getCurrentDocument()final Flow<DrawState>getToDraw()final UnitsaveOnStoryChanges(DocumentTracker documentTracker)Saves the document automatically as it is changed. final BooleanisInitialized()final UnitnewStory(String documentId, String title)Creates a new story. final UnitinitDocument(Document document)Initializes a document passed as a parameter. final UnitnextFocusOrCreate(Integer position)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. final UnitmergeRequest(Action.Merge info)Merges two StoryStep into a group. final UnitmoveRequest(Action.Move move)A request to move a content to a position. final UnitchangeStoryState(Action.StoryStateChange stateChange)At the moment it is only possible to check items not inside groups. final UnitchangeStoryType(Integer position, StoryType storyType, CommandInfo commandInfo)Changes the story type. final UnitonTextEdit(String text, Integer position)An text edition of a StoryStep final UnitonTitleEdit(String text, Integer position)An edition in title. final UnitonLineBreak(Action.LineBreak lineBreak)Creates a line break. final UnitonSelected(Boolean isSelected, Integer position)Add a StoryStep of a position into the selection list. final UnitclickAtTheEnd()A click at the end of the document. Unitundo()Undo the last action. Unitredo()Redo the last undone action. final UnitonDelete(Action.DeleteStory deleteStory)Deletes a StoryStep final UnitdeleteSelection()Deletes the whole selection. final UnitonClear()Clears the WriteopiaManager. -
-
Constructor Detail
-
WriteopiaManager
WriteopiaManager(Function1<Map<Integer, List<StoryStep>>, Map<Integer, StoryStep>> stepsNormalizer, MovementHandler movementHandler, ContentHandler contentHandler, FocusHandler focusHandler, CoroutineScope coroutineScope, CoroutineDispatcher dispatcher, BackstackManager backStackManager, SuspendFunction0<String> userId)
-
-
Method Detail
-
getScrollToPosition
final StateFlow<Integer> getScrollToPosition()
-
getOnEditPositions
final StateFlow<Set<Integer>> getOnEditPositions()
-
getCurrentStory
final StateFlow<StoryState> getCurrentStory()
-
getCurrentDocument
final Flow<Document> getCurrentDocument()
-
saveOnStoryChanges
final Unit saveOnStoryChanges(DocumentTracker documentTracker)
Saves the document automatically as it is changed. It uses the DocumentTracker passed in the constructor of WriteopiaManager
-
isInitialized
final Boolean isInitialized()
-
newStory
final Unit newStory(String documentId, String title)
Creates a new story. Use this when you wouldn't like to load a documented previously saved.
- Parameters:
documentId- the id of the document that will be createdtitle- the title of the document
-
initDocument
final Unit initDocument(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.
- Parameters:
document- Document
-
nextFocusOrCreate
final Unit nextFocusOrCreate(Integer position)
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.
- Parameters:
position- Int
-
mergeRequest
final Unit mergeRequest(Action.Merge info)
Merges two StoryStep into a group. This can be used to merge two images into a message group or any other kind of group.
- Parameters:
info- Action.Merge
-
moveRequest
final Unit moveRequest(Action.Move move)
A request to move a content to a position.
- Parameters:
move- Action.Move
-
changeStoryState
final Unit changeStoryState(Action.StoryStateChange stateChange)
At the moment it is only possible to check items not inside groups. Todo: Fix it!
- Parameters:
stateChange- Action.StoryStateChange
-
changeStoryType
final Unit changeStoryType(Integer position, 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.
- Parameters:
position- IntstoryType- StoryStepcommandInfo- CommandInfo
-
onTextEdit
final Unit onTextEdit(String text, Integer position)
An text edition of a StoryStep
- Parameters:
text- Stringposition- Int
-
onTitleEdit
final Unit onTitleEdit(String text, Integer position)
An edition in title. Title edition also changes the meta data of a document.
- Parameters:
text- Stringposition- Int
-
onLineBreak
final Unit onLineBreak(Action.LineBreak lineBreak)
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.
- Parameters:
lineBreak- Action.LineBreak
-
onSelected
final Unit onSelected(Boolean isSelected, Integer position)
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.
-
clickAtTheEnd
final Unit clickAtTheEnd()
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.
-
onDelete
final Unit onDelete(Action.DeleteStory deleteStory)
Deletes a StoryStep
- Parameters:
deleteStory- Action.DeleteStory
-
deleteSelection
final Unit deleteSelection()
Deletes the whole selection. All StoryStep in the selection will be deleted.
-
onClear
final Unit onClear()
Clears the WriteopiaManager. Use this in the onCleared of your ViewModel.
-
-
-
-