addItem<T> function
Adds a new item to the top of the list
Implementation
ThunkAction<SwipeFeedState<T>> addItem<T>(T? item, {Function? onComplete, bool wait = true, bool overrideWait = false}) {
return (Store<SwipeFeedState<T>> store) async {
if(store.state.items.isNotEmpty){
store.state.items[0].item2.dispatch(SetSwipeFeedCardState(SwipeCardHideState()));
/// Duration After Hiding
/// This is the functional duration not the actual animation
/// Insert HERE
/// Do we still need to wait this 400 ms when on the no items card and you are adding an item
if((store.state.items[0].item1 != null && wait) || overrideWait){
await Future.delayed(Duration(milliseconds: 400));
}
}
List<Tuple2<T?, Store<SwipeFeedCardState>>> addNewItem =
[Tuple2(item, SwipeFeedCardState.tower()), ...store.state.items];
store.dispatch(SetItemsEvent(addNewItem));
/// Duration For showing the Card
/// This is the functional duration not the actual animation
/// Insert Here
await Future.delayed(Duration(milliseconds: 400)).then((value){
store.state.items[0].item2.dispatch(SetSwipeFeedCardState(SwipeCardShowState()));
});
if(onComplete != null){
onComplete();
}
};
}