executeExitDemoMode method

void executeExitDemoMode({
  1. required AFMergePublicStateDelegate mergePublicState,
})
inherited

Implementation

void executeExitDemoMode({
  required AFMergePublicStateDelegate mergePublicState,
}) {
  // first, navigate to the entering/leaving demo model page.

  // NOTE: this query was started in standard app mode, and so is linked to the standard app store.
  // however, in this case, we need to manipualate the state in the demo app store.  So, we need to
  // explicitly dispatch our nav into that store.
  final demoDispatcher = AFibF.g.internalOnlyDispatcher(AFConceptualStore.demoModeStore);
  demoDispatcher.dispatch(AFUIDemoModeExitScreen.navigatePush().castToReplaceAll());

  // wait for all navigation to complete, so that you don't have animations trying to
  // reference screens that existed prior to demo-mode, then:

  // Note: you cannot use executeDeferredCallback here, because in prototype mode it doesn't actually delay,
  // and we really need to delay and wait for the screen to render, even in prototype mode.
  Timer(const Duration(seconds: 1), () {
    AFibF.g.swapActiveAndBackgroundStores(
      mergePublicState: (source, dest) {
        var revised = mergePublicState(source, dest);
        var origRoute = AFibF.g.preDemoModeRoute;
        revised = revised.reviseRoute(origRoute!);
        return revised;
      }
    );

    AFibF.g.demoModeTest = null;
    AFibF.g.setActiveStore(AFConceptualStore.appStore);

    assert(AFibF.g.internalOnlyActiveStore.state.public.conceptualStore == AFConceptualStore.appStore);


    final route = AFibF.g.internalOnlyActiveStore.state.public.route;
    AFibF.g.internalOnlyActiveDispatcher.dispatch(AFNavigateSyncNavigatorStateWithRoute(route));
  });
}