Archived
1
0

Development 7

This commit is contained in:
Michael Gordeev
2018-07-22 15:00:47 +03:00
parent 57c90f4037
commit 0338d8a626
24 changed files with 727 additions and 359 deletions
+79 -28
View File
@@ -17,6 +17,7 @@ using System.Globalization;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using Windows.Storage;
using Windows.UI.Text;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -27,6 +28,9 @@ namespace FoxTube
/// </summary>
public sealed partial class Home : Page
{
private bool recLoaded = false;
private bool trendLoaded = false;
private bool subsLoaded = false;
public Home()
{
this.InitializeComponent();
@@ -35,7 +39,6 @@ namespace FoxTube
public async void Initialize()
{
#region Vairables declaring
VideoGrid videoGrid = new VideoGrid();
string reg;
@@ -47,58 +50,106 @@ namespace FoxTube
{
reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper();
}
#endregion
pivot.Items.Clear();
grid.RowDefinitions[0].Height = new GridLength(0);
#region Request-Response
VideosResource.ListRequest request = SecretsVault.NoAuthService.Videos.List("snippet,contentDetails,statistics");
request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;
request.RegionCode = reg;
VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id");
request.MaxResults = 48;
VideoListResponse response = await request.ExecuteAsync();
#endregion
foreach (Google.Apis.YouTube.v3.Data.Video vid in response.Items)
if(SecretsVault.IsAuthorized)
{
VideoCard vCard = new VideoCard(vid.Id);
videoGrid.AddCards(vCard);
navigation.Visibility = Visibility.Visible;
for(int k = 0; k < 3; k++)
{
StackPanel stack = new StackPanel();
stack.Children.Add(new VideoGrid());
stack.Children.Add(new LoadingPage());
pivot.Items.Add(new PivotItem()
{
Margin = new Thickness(0, -48, 0, 0),
Content = stack
});
}
//Initializing recommended videos loading
recLoaded = true;
(((pivot.Items[0] as PivotItem).Content as StackPanel).Children[1] as LoadingPage).Block();
}
pivot.Items.Add(new PivotItem()
else
{
Margin = new Thickness(0,-48,0,0),
Name = "trending",
Content = videoGrid
});
Grid g = new Grid();
StackPanel stack = new StackPanel();
stack.Children.Add(new VideoGrid());
stack.Children.Add(new HyperlinkButton()
{
/*if((Parent as MainPage).Logged)
{
grid.RowDefinitions[0].Height = new GridLength(47);
//TO-DO: Add initializing recommended and subscriptions tabs
}*/
});
g.Children.Add(stack);
g.Children.Add(new LoadingPage());
pivot.Items.Add(new PivotItem()
{
Margin = new Thickness(0, -48, 0, 0),
Content = g
});
//Initializing recommended videos loading
request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;
request.RegionCode = reg;
VideoListResponse response = await request.ExecuteAsync();
foreach (Google.Apis.YouTube.v3.Data.Video vid in response.Items)
{
VideoCard vCard = new VideoCard(vid.Id);
videoGrid.AddCards(vCard);
}
trendLoaded = true;
}
}
private void toRecommended_Click(object sender, RoutedEventArgs e)
{
pivot.SelectedIndex = 0;
}
private void toTrending_Click(object sender, RoutedEventArgs e)
{
if (pivot.Items.Count > 1)
pivot.SelectedIndex = 1;
else
pivot.SelectedIndex = 0;
}
private void tosubs_Click(object sender, RoutedEventArgs e)
{
pivot.SelectedIndex = 2;
}
private void refresh_Click(object sender, RoutedEventArgs e)
{
Initialize();
}
private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
toRecommended.FontWeight = FontWeights.Normal;
toTrending.FontWeight = FontWeights.Normal;
tosubs.FontWeight = FontWeights.Normal;
switch(pivot.SelectedIndex)
{
case 2:
tosubs.FontWeight = FontWeights.Bold;
break;
case 1:
toTrending.FontWeight = FontWeights.Bold;
break;
case 0:
if (pivot.Items.Count > 1)
toRecommended.FontWeight = FontWeights.Bold;
else toTrending.FontWeight = FontWeights.Bold;
break;
}
}
}
}