protected virtual void LoadScreen(CompositeDrawable loader, Drawable toLoad, Action continuation) { // If the previous screen has already been exited, do not attempt to load the new one. if ((loader as IScreen)?.ValidForPush == false) { return; } if (toLoad.LoadState >= LoadState.Ready) { continuation?.Invoke(); } else { if (loader.LoadState >= LoadState.Ready) { log($"loading {getTypeString(toLoad)}"); loader.LoadComponentAsync(toLoad, _ => continuation?.Invoke(), scheduler: Scheduler); } else { log($"scheduling load {getTypeString(toLoad)}"); Schedule(() => LoadScreen(loader, toLoad, continuation)); } } }
/// <summary> /// Loads a <see cref="IScreen"/> through a <see cref="CompositeDrawable"/>. /// </summary> /// <param name="loader">The <see cref="CompositeDrawable"/> to load <paramref name="toLoad"/> with.</param> /// <param name="toLoad">The <see cref="IScreen"/> to load.</param> /// <param name="continuation">The <see cref="Action"/> to invoke after <paramref name="toLoad"/> has finished loading.</param> protected virtual void LoadScreen(CompositeDrawable loader, Drawable toLoad, Action continuation) { if (toLoad.LoadState >= LoadState.Ready) { continuation?.Invoke(); } else { loader.LoadComponentAsync(toLoad, _ => continuation?.Invoke(), scheduler: Scheduler); } }