public void FactReadingProcess(FactFrame factFrame, bool leftDirection) { factFrame.FactIsSwipped = true; if (!factFrame.FactIsReaded) { factFrame.FactIsReaded = true; var factEntity = new FactEntity { Id = factFrame.Id, IsFavorite = factFrame.IsFavorite, ReadedFactName = factFrame.FactId }; CommonData.AllReadedFacts.Add(factEntity); Task.Run(() => { _viewModel.SaveFactToStorage(factEntity); }); } Task.Run(() => { Device.BeginInvokeOnMainThread(() => { var fact = GetFactFrame(MainWrapper.Children.Count(x => x is FactFrame)); if (fact != null) { fact.Opacity = 0; MainWrapper.Children.Insert(0, fact); fact.FadeTo(1, 500); var visibleFrame = MainWrapper.Children.LastOrDefault( x => (x as FactFrame) != null && !(x as FactFrame).FactIsSwipped); SetToolbar(visibleFrame as FactFrame); } else if (!MainWrapper.Children.Any(x => (x as EmptyLabel) != null)) { MainWrapper.Children.Insert(0, new EmptyLabel()); } }); }); if (leftDirection) { factFrame.RaiseSwipedLeft(); } else { factFrame.RaiseSwipedRight(); } }
private static void AddToolbarItems(FactFrame factFrame, IList <ToolbarItem> toolbarItems, Action favoriteAction, Action shareAction) { toolbarItems.Add(new ToolbarItem { Icon = factFrame.IsFavorite ? "Assets/removeFavorite.png" : "Assets/addFavorite.png", Text = factFrame.IsFavorite ? "Удалить из избранных" : "Добавить в избранное", Command = new Command(favoriteAction) }); toolbarItems.Add(new ToolbarItem { Icon = "Assets/share.png", Text = "Поделиться", Command = new Command(shareAction) }); }
private static void AddToolbarItems(FactFrame factFrame, IList <ToolbarItem> toolbarItems, Action favoriteAction, Action shareAction) { toolbarItems.Add(new ToolbarItem { Icon = factFrame.IsFavorite ? "Assets/removeFavorite.png" : "Assets/addFavorite.png", Text = factFrame.IsFavorite ? "Remove from favorites" : "Add to favorites", Command = new Command(favoriteAction) }); toolbarItems.Add(new ToolbarItem { Icon = "Assets/share.png", Text = "Share", Command = new Command(shareAction) }); }
public static void SetToolbarItems(FactFrame factFrame, IList <ToolbarItem> toolbarItems, Action favoriteAction, Action shareAction) { if (factFrame != null) { if (factFrame.IsFavorite == _isFavorite && toolbarItems.Any()) { toolbarItems[0].Command = new Command(favoriteAction); toolbarItems[1].Command = new Command(shareAction); } else { _isFavorite = factFrame.IsFavorite; toolbarItems.Clear(); AddToolbarItems(factFrame, toolbarItems, favoriteAction, shareAction); } } }
private void SetToolbar(FactFrame fact) { NaviagationService.SetToolbarItems(fact, ToolbarItems, FavoriteAction, async() => { await ShareAction(); }); }