From b712bfb74e78a7ebdb789e967cb015c3476343c7 Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Fri, 10 Aug 2018 20:50:52 +0300 Subject: [PATCH] Dark theme, navigation --- FoxTube/App.xaml | 29 +-- FoxTube/App.xaml.cs | 16 ++ FoxTube/Classes/ObjectEventArgs.cs | 2 + FoxTube/Classes/SecretsVault.cs | 19 +- FoxTube/Controls/ChannelCard.xaml | 4 +- FoxTube/Controls/CommentCard.xaml | 4 +- FoxTube/Controls/DownloadItem.xaml | 2 +- FoxTube/Controls/PlaylistCard.xaml | 4 +- FoxTube/Controls/ShowMore.xaml.cs | 2 - FoxTube/Controls/SuggestionsQueries.xaml | 30 --- FoxTube/Controls/SuggestionsQueries.xaml.cs | 113 --------- FoxTube/Controls/VideoCard.xaml | 10 +- FoxTube/Controls/VideoCard.xaml.cs | 12 +- FoxTube/FoxTube.csproj | 7 - FoxTube/Pages/ChannelPage.xaml.cs | 2 +- FoxTube/Pages/CommentsPage.xaml | 4 +- FoxTube/Pages/Home.xaml.cs | 1 + FoxTube/Pages/LoadingPage.xaml | 5 +- FoxTube/Pages/MainPage.xaml | 67 +++--- FoxTube/Pages/MainPage.xaml.cs | 246 +++++++++++--------- FoxTube/Pages/PlaylistPage.xaml.cs | 4 +- FoxTube/Pages/Search.xaml.cs | 9 +- FoxTube/Pages/Settings.xaml | 2 +- FoxTube/Pages/Settings.xaml.cs | 10 + FoxTube/Pages/SettingsPages/About.xaml | 18 +- FoxTube/Pages/SettingsPages/Feedback.xaml | 2 +- FoxTube/Pages/SettingsPages/General.xaml | 6 + FoxTube/Pages/SettingsPages/General.xaml.cs | 44 +++- FoxTube/Pages/SettingsPages/Inbox.xaml | 2 +- FoxTube/Pages/VideoGrid.xaml | 29 --- FoxTube/Pages/VideoPage.xaml | 33 ++- FoxTube/Pages/VideoPage.xaml.cs | 39 +++- 32 files changed, 359 insertions(+), 418 deletions(-) delete mode 100644 FoxTube/Controls/SuggestionsQueries.xaml delete mode 100644 FoxTube/Controls/SuggestionsQueries.xaml.cs diff --git a/FoxTube/App.xaml b/FoxTube/App.xaml index b0d3345..41a4760 100644 --- a/FoxTube/App.xaml +++ b/FoxTube/App.xaml @@ -2,33 +2,8 @@ x:Class="FoxTube.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="using:FoxTube" - RequestedTheme="Light"> + xmlns:local="using:FoxTube"> - - - - - - + Red diff --git a/FoxTube/App.xaml.cs b/FoxTube/App.xaml.cs index 5fe7b58..eb5371f 100644 --- a/FoxTube/App.xaml.cs +++ b/FoxTube/App.xaml.cs @@ -8,6 +8,7 @@ using Windows.ApplicationModel.Activation; using Windows.ApplicationModel.Core; using Windows.Foundation; using Windows.Foundation.Collections; +using Windows.Storage; using Windows.UI.Core; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -28,8 +29,23 @@ namespace FoxTube /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// + ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; public App() { + try + { + switch((int)settings.Values["themeMode"]) + { + case 0: + RequestedTheme = ApplicationTheme.Light; + break; + case 1: + RequestedTheme = ApplicationTheme.Dark; + break; + case 2: + break; + } + } catch { } this.InitializeComponent(); this.Suspending += OnSuspending; } diff --git a/FoxTube/Classes/ObjectEventArgs.cs b/FoxTube/Classes/ObjectEventArgs.cs index 5e60964..eea6edf 100644 --- a/FoxTube/Classes/ObjectEventArgs.cs +++ b/FoxTube/Classes/ObjectEventArgs.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; namespace FoxTube { + public delegate void Event(); + public delegate void ObjectEventHandler(object sender, params object[] args); public class SearchParameters diff --git a/FoxTube/Classes/SecretsVault.cs b/FoxTube/Classes/SecretsVault.cs index b090454..842c6ad 100644 --- a/FoxTube/Classes/SecretsVault.cs +++ b/FoxTube/Classes/SecretsVault.cs @@ -35,7 +35,7 @@ namespace FoxTube public static string AccountId { get; private set; } public static bool IsAuthorized { get; private set; } = false; - public static Google.Apis.YouTube.v3.Data.Channel UserChannel { get; private set; } + public static Channel UserChannel { get; private set; } public static List WatchLater { get; private set; } = new List(); public static List UserHistory { get; private set; } = new List(); public static List Subscriptions { get; private set; } = new List(); @@ -180,6 +180,7 @@ namespace FoxTube if(await Credential.RevokeTokenAsync(CancellationToken.None)) { Credential = null; + IsAuthorized = false; AuthorizationStateChanged.Invoke(null, null); settings.Values["authorized"] = false; } @@ -192,5 +193,21 @@ namespace FoxTube else Authorize(); } + + public static bool AdsDisabled { get; private set; } = true; + + public static void CheckAddons() + { + //TO-DO: Check addons list + bool purchased = true; + + if(!purchased) + { + AdsDisabled = false; + NotPurchased.Invoke(); + } + } + + public static event Event NotPurchased; } } diff --git a/FoxTube/Controls/ChannelCard.xaml b/FoxTube/Controls/ChannelCard.xaml index e07827b..4e0abec 100644 --- a/FoxTube/Controls/ChannelCard.xaml +++ b/FoxTube/Controls/ChannelCard.xaml @@ -12,7 +12,7 @@ d:DesignWidth="384"> + + - + @@ -70,10 +63,6 @@ FontFamily="Segoe MDL2 Assets" Content="" Width="50" Height="50" Background="Transparent"/> - - + + + + diff --git a/FoxTube/Pages/VideoPage.xaml.cs b/FoxTube/Pages/VideoPage.xaml.cs index b518a6b..bef50b5 100644 --- a/FoxTube/Pages/VideoPage.xaml.cs +++ b/FoxTube/Pages/VideoPage.xaml.cs @@ -46,7 +46,8 @@ namespace FoxTube.Pages { ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; - string videoId; + public string videoId; + string playlistId = null; Video item; List downloads = new List(); @@ -99,21 +100,40 @@ namespace FoxTube.Pages protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.Parameter == null) + if (e.Parameter == null || string.IsNullOrWhiteSpace((e.Parameter as string[])[0])) loading.Error("NullReferenceException", "Unable to initialize page. Video ID is not stated."); else - Initialize(e.Parameter as string); + Initialize(e.Parameter as string[]); } - public async void Initialize(string id) + public async void Initialize(string[] ids) { loading.Refresh(); try { - videoId = id; + videoId = ids[0]; + + if (ids[1] != null) + { + PlaylistsResource.ListRequest playlistRequest = SecretsVault.Service.Playlists.List("snippet,contentDetails"); + playlistRequest.Id = ids[1]; + Playlist playlistItem = (await playlistRequest.ExecuteAsync()).Items[0]; + + playlistName.Text = playlistItem.Snippet.Title; + playlistChannel.Text = playlistItem.Snippet.ChannelTitle; + + PlaylistItemsResource.ListRequest listRequest = SecretsVault.Service.PlaylistItems.List("snippet"); + listRequest.PlaylistId = ids[1]; + PlaylistItemListResponse listResponse = await listRequest.ExecuteAsync(); + + //Initialize playlist tab + } + else + pivot.Items.Remove(playlist); + VideosResource.ListRequest request = SecretsVault.Service.Videos.List("snippet,statistics,status,contentDetails"); - request.Id = id; + request.Id = ids[0]; item = (await request.ExecuteAsync()).Items[0]; title.Text = item.Snippet.Title; @@ -135,7 +155,7 @@ namespace FoxTube.Pages if (SecretsVault.IsAuthorized) { - VideoGetRatingResponse ratingResponse = await SecretsVault.Service.Videos.GetRating(id).ExecuteAsync(); + VideoGetRatingResponse ratingResponse = await SecretsVault.Service.Videos.GetRating(ids[0]).ExecuteAsync(); if (ratingResponse.Items[0].Rating == "like") { userRating = Rating.Like; @@ -274,7 +294,7 @@ namespace FoxTube.Pages public void refresh_Click(object sender, RoutedEventArgs e) { player = new VideoPlayer(); - Initialize(videoId); + Initialize(new string[2] { videoId, playlistId }); } private void grid_SizeChanged(object sender, SizeChangedEventArgs e) @@ -290,7 +310,8 @@ namespace FoxTube.Pages { mainContent.Children.Remove(pivot); tabsPlaceholder.Children.Add(pivot); - + + (pivot.Items[0] as PivotItem).Content = null; pivot.Items.RemoveAt(0); mainContent.Children.Add(descriptionPanel); }