Archived
1
0

Implemented default home tab and downloads settings

This commit is contained in:
Michael Gordeev
2020-05-14 00:02:50 +03:00
parent b4cfb58b64
commit d25bc92188
4 changed files with 53 additions and 7 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
xmlns:homesections="using:FoxTube.Views.HomeSections"
mc:Ignorable="d">
<Pivot>
<Pivot x:Name="pivot">
<PivotItem Header="Recommended">
<homesections:Recommended/>
</PivotItem>
+13 -1
View File
@@ -10,7 +10,19 @@ namespace FoxTube.Views
[Refreshable]
public sealed partial class Home : Page
{
public Home() =>
public Home()
{
InitializeComponent();
pivot.SelectedIndex = FoxTube.Settings.DefaultHomeTab;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.NavigationMode == NavigationMode.New)
pivot.SelectedIndex = FoxTube.Settings.DefaultHomeTab;
}
}
}
+4 -4
View File
@@ -15,7 +15,7 @@
</StackPanel.ChildrenTransitions>
<StackPanel Margin="0,0,0,10">
<ComboBox Header="Default homepage tab" Width="250">
<ComboBox Header="Default homepage tab" Width="250" Name="defaultHomeTab" SelectionChanged="HomeTabChanged">
<ComboBoxItem Content="Recommended"/>
<ComboBoxItem Content="Trending"/>
<ComboBoxItem Content="Subscriptions"/>
@@ -60,11 +60,11 @@
<StackPanel Margin="0,0,0,10">
<TextBlock Text="Downloads" Style="{StaticResource TitleTextBlockStyle}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,5">
<TextBox Header="Default downloads location" Width="250" IsReadOnly="True" PlaceholderText="//Videos/FoxTube"/>
<Button VerticalAlignment="Bottom" FontFamily="Segoe MDL2 Assets" Content="&#xE10C;" Margin="5,0"/>
<TextBox x:Name="downloadsPath" Header="Default downloads location" Width="250" IsReadOnly="True" PlaceholderText="//Videos/FoxTube"/>
<Button x:Name="changeDownloadsPathButton" Click="ChangeDownloadsPath" VerticalAlignment="Bottom" FontFamily="Segoe MDL2 Assets" Content="&#xE10C;" Margin="5,0"/>
</StackPanel>
<ToggleSwitch OnContent="Ask where to save before downloading" OffContent="Ask where to save before downloading"/>
<ToggleSwitch x:Name="askDownloads" Toggled="AlwaysAskDownloadsChanged" OnContent="Ask where to save before downloading" OffContent="Ask where to save before downloading"/>
</StackPanel>
<StackPanel Margin="0,0,0,10">
+35 -1
View File
@@ -1,5 +1,11 @@
using System.Linq;
using FoxTube.Services;
using System;
using System.Linq;
using System.Security.Cryptography;
using Windows.Globalization;
using Windows.Storage;
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -14,6 +20,8 @@ namespace FoxTube.Views.SettingsSections
{
InitializeComponent();
defaultHomeTab.SelectedIndex = FoxTube.Settings.DefaultHomeTab;
language.SelectedItem = language.Items.FirstOrDefault(i => ((ComboBoxItem)i).Tag.ToString() == FoxTube.Settings.Language);
safeSearch.SelectedIndex = FoxTube.Settings.SafeSearch;
@@ -25,6 +33,10 @@ namespace FoxTube.Views.SettingsSections
developersNews.IsOn = FoxTube.Settings.DevNotifications;
clipboardProcessing.IsOn = FoxTube.Settings.ProcessClipboard;
askDownloads.IsOn = FoxTube.Settings.AskBeforeDownloading;
LoadPath();
switch (FoxTube.Settings.Theme)
{
case 0:
@@ -39,6 +51,9 @@ namespace FoxTube.Views.SettingsSections
}
}
private async void LoadPath() =>
downloadsPath.Text = (await DownloadsCenter.GetDefaultDownloadsFolder()).Path;
private void LoadRelevaneLanguageList(object sender, RoutedEventArgs e)
{
// TODO: Add list loading
@@ -66,6 +81,9 @@ namespace FoxTube.Views.SettingsSections
restart.Visibility = Visibility.Visible;
}
private void HomeTabChanged(object sender, SelectionChangedEventArgs e) =>
FoxTube.Settings.DefaultHomeTab = defaultHomeTab.SelectedIndex;
private void Restart(object sender, RoutedEventArgs e) =>
Utils.Utils.RestartApp();
@@ -128,5 +146,21 @@ namespace FoxTube.Views.SettingsSections
{
Utils.Utils.InitializeFailsafeProtocol();
}
private async void ChangeDownloadsPath(object sender, RoutedEventArgs e)
{
StorageFolder destinationFolder = await new FolderPicker().PickSingleFolderAsync();
if (destinationFolder == null)
return;
if (!string.IsNullOrWhiteSpace(FoxTube.Settings.DefaultDownloadsFolder))
StorageApplicationPermissions.FutureAccessList.Remove(FoxTube.Settings.DefaultDownloadsFolder);
downloadsPath.Text = destinationFolder.Path;
FoxTube.Settings.DefaultDownloadsFolder = StorageApplicationPermissions.FutureAccessList.Add(destinationFolder);
}
private void AlwaysAskDownloadsChanged(object sender, RoutedEventArgs e) =>
FoxTube.Settings.AskBeforeDownloading = askDownloads.IsOn;
}
}