Overlay topic
Overlay
Controller
Here comes IEasyOverlayController which suddenly has pretty similar responsibilities to that of the Manager, such as inserting and removing dialogs into the Overlay using two methods.
abstract class IEasyOverlayController implements TickerProvider {
void insertDialog(EasyOverlayBoxInsert strategy);
void removeDialog(EasyOverlayBoxRemove strategy);
}
You may notice the strategy named argument, and you would be correct in thinking that it refers to the strategies mentioned earlier.
Box
It is the strict variation of Map with generic types which is using only for storing Overlay entries and associated Managers:
abstract class IEasyDialogsOverlayBox {
void put(Object key, Object value);
T? remove<T>(Object key);
T? get<T>(Object key);
T putIfAbsent<T>(Object key, T Function() ifAbsent);
}
Note:
EachManagercan provide its own complex structure for state as complex as it needs to be. For example, the PositionedDialogManager stores its data in the format of anotherMap, or BasicDialogInsertStrategy uses aList ofintegersas identifiers of inserted dialogs.
Box mutation
So that's it - the strategy for inserting/removing Manager data into IEasyDialogsOverlayBox. The basis of this is called BoxMutation, which has the single responsibility of mutating the storage state of this Box:
abstract class EasyOverlayBoxMutation<M extends EasyDialogManager,
R extends EasyOverlayEntry?> {
const EasyOverlayBoxMutation();
Type get key => M;
R apply(IEasyOverlayBox box);
}
The result of applying of the mutation strategy must be an any derived class of EasyOverlayEntry (specific class derived from OverlayEntry) which can later could be used within IEasyOverlayController to insert that entry into EasyOverlay.
For the sake of simplicity, there are two classes.
One is for inserting:
abstract class EasyOverlayBoxInsert<M extends EasyDialogManager>
extends EasyOverlayBoxMutation<M, EasyOverlayEntry> {
final Widget dialog;
const EasyOverlayBoxInsert({
required this.dialog,
});
}
Which provides the dialog to be inserted into EasyDialogsOverlay.
And the another is for removing, which result could be nullable as it could be no such dialog entry existing withing the IEasyDialogsOverlayBox
abstract class EasyOverlayBoxRemove<M extends EasyDialogManager>
extends EasyOverlayBoxMutation<M, EasyOverlayEntry?> {
const EasyOverlayBoxRemove();
}
EasyDialogsOverlay
This is the core widget that provides all possibilities of dialogs to appear at any time and in any place within the wrapped application. Its state is responsible for storing IEasyDialogsOverlayBox and implementing IEasyOverlayController. There isn't much to know, to be honest.
Classes
- EasyDialogsOverlayEntry
- Simple overlay entry.
-
EasyOverlayBoxInsert<
M extends EasyDialogManager< CustomEasyDialogManagerShowParams?, EasyDialogManagerHideParams?> > - Insert mutation.
-
EasyOverlayBoxMutation<
M extends EasyDialogManager< CustomEasyDialogManagerShowParams?, EasyDialogManagerHideParams?> , R extends EasyOverlayEntry?> - Similar to Command/Strategy class for applying specific mutation within IEasyDialogsOverlayBox.
-
EasyOverlayBoxRemove<
M extends EasyDialogManager< CustomEasyDialogManagerShowParams?, EasyDialogManagerHideParams?> > - Remove mutation.
- EasyOverlayEntry
- The EasyOverlayEntry class is an abstract class that extends OverlayEntry.
- IEasyDialogsOverlayBox Custom
- Box for storing dialog specific entries.
- IEasyOverlayController Custom
- Controller for manipulating overlay with the dialogs.