Archived
1
0

Redesign 1

This commit is contained in:
Michael Gordeev
2018-08-08 13:55:37 +03:00
parent 039a504d56
commit 6969af84a8
17 changed files with 446 additions and 880 deletions
+43
View File
@@ -0,0 +1,43 @@
<Page
x:Class="FoxTube.Pages.SettingsPages.General"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube.Pages.SettingsPages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Vertical">
<TextBlock Text="Preferences" FontSize="28"/>
<TextBlock Text="Region &#x26; search" FontSize="22"/>
<ComboBox Header="App interface language" MinWidth="250" Name="language" SelectionChanged="language_SelectionChanged">
<ComboBoxItem Content="English"/>
<ComboBoxItem Content="Russian"/>
</ComboBox>
<TextBlock Foreground="Red" Name="restartNote" Text="Reopen the app to apply settings" Visibility="Collapsed"/>
<ComboBox Header="Region" MinWidth="250" Name="region" SelectionChanged="region_SelectionChanged"/>
<ComboBox Header="SafeSearch" MinWidth="250" Name="safeSearch" SelectionChanged="safeSearch_SelectionChanged">
<ComboBoxItem Content="Moderate"/>
<ComboBoxItem Content="None"/>
<ComboBoxItem Content="Strict"/>
</ComboBox>
<TextBlock Text="Playback" FontSize="22"/>
<ComboBox Width="250" Header="Default video playback quality" Name="quality" SelectionChanged="quality_SelectionChanged">
<ComboBoxItem Content="Remember my choice"/>
<ComboBoxItem Content="2160p"/>
<ComboBoxItem Content="1080p"/>
<ComboBoxItem Content="720p"/>
<ComboBoxItem Content="480p"/>
<ComboBoxItem Content="360p"/>
<ComboBoxItem Content="240p"/>
<ComboBoxItem Content="144p"/>
</ComboBox>
<ToggleSwitch OnContent="Notify when playing on metered connection" OffContent="Notify when playing on metered connection" Name="mobileWarning" Toggled="notification_IsEnabledChanged"/>
<ToggleSwitch OnContent="Play videos automatically" OffContent="Play videos automatically" Name="autoplay" Toggled="notification_IsEnabledChanged"/>
<TextBlock Text="Notifications" FontSize="22"/>
<ToggleSwitch Name="newVideo" OnContent="Notify when someone of your subscriptions uploaded new video" OffContent="Notify when someone of your subscriptions uploaded new video" Toggled="notification_IsEnabledChanged"/>
</StackPanel>
</Page>
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube.Pages.SettingsPages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class General : Page
{
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
public General()
{
this.InitializeComponent();
language.SelectedIndex = (int)settings.Values["language"];
quality.SelectedIndex = (int)settings.Values["quality"];
newVideo.IsOn = (bool)settings.Values["newVideoNotification"];
mobileWarning.IsOn = (bool)settings.Values["moblieWarning"];
autoplay.IsOn = (bool)settings.Values["videoAutoplay"];
safeSearch.SelectedIndex = (int)settings.Values["safeSearch"];
foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
region.Items.Add(culture.DisplayName);
if (culture.Name == (string)settings.Values["region"])
region.SelectedIndex = region.Items.Count - 1;
}
}
private void language_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if ((int)settings.Values["language"] != language.SelectedIndex)
{
settings.Values["language"] = language.SelectedIndex;
restartNote.Visibility = Visibility.Visible;
}
}
private void quality_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
settings.Values["quality"] = quality.SelectedIndex;
}
private void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
{
if ((bool)settings.Values["newVideoNotification"] != newVideo.IsOn)
settings.Values["newVideoNotification"] = newVideo.IsOn;
if ((bool)settings.Values["moblieWarning"] != mobileWarning.IsOn)
settings.Values["moblieWarning"] = mobileWarning.IsOn;
if ((bool)settings.Values["videoAutoplay"] != autoplay.IsOn)
settings.Values["videoAutoplay"] = autoplay.IsOn;
}
private void region_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
settings.Values["region"] = CultureInfo.GetCultures(CultureTypes.AllCultures)[region.SelectedIndex].Name;
}
private void safeSearch_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
settings.Values["safeSearch"] = safeSearch.SelectedIndex;
}
}
}