Exemplo n.º 1
0
        private async Task ManageFavorites()
        {
            if (await Permissions.RequestAsync <Permissions.StorageRead>() == PermissionStatus.Granted)
            {
                await LocalStorage.LoadFile();

                LocalStorage.GetStorage().FavoriteWorks.ForEach(FavoriteWorks.Add);
            }
            else
            {
                await Alerts.CallToastAsync("Storage access permission must be granted for favorite functions",
                                            TimeSpan.FromSeconds(7), Color.Salmon, Color.White, "alert");
            }
        }
Exemplo n.º 2
0
        private async Task FavoriteWork(Work work)
        {
            if (!await _favoriteService.CheckFavorites(work))
            {
                await _favoriteService.AddToFavorites(work);

                WorkFavorited = true;
                await Alerts.CallToastAsync("Added to favorites", null, Color.PaleGreen, Color.White);
            }
            else
            {
                await _favoriteService.RemoveFromFavorites(work);

                WorkFavorited = false;
                await Alerts.CallToastAsync("Removed from favorites", null, Color.Salmon, Color.White);
            }
        }