<commit_before>﻿using wallabag.Common;
using wallabag.Views;
using Windows.UI.ApplicationSettings;
using Windows.UI.Xaml.Controls;

namespace wallabag
{
    public sealed partial class MainPage : basicPage
    {
        public MainPage()
        {
            this.InitializeComponent();
            SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;
        }

        protected override void SaveState(SaveStateEventArgs e)
        {
            e.PageState.Add("unreadItemsActive", unreadItemsMenuButton.IsChecked);
            e.PageState.Add("favouriteItemsActive", favouriteItemsMenuButton.IsChecked);
            e.PageState.Add("archivedItemsActive", archivedItemsMenuButton.IsChecked);
            base.SaveState(e);
        }

        protected override void LoadState(LoadStateEventArgs e)
        {
            if (e.PageState != null)
            {
                if (e.PageState.ContainsKey("unreadItemsActive"))
                    unreadItemsMenuButton.IsChecked = (bool)e.PageState["unreadItemsActive"];
                if (e.PageState.ContainsKey("favouriteItemsActive"))
                    favouriteItemsMenuButton.IsChecked = (bool)e.PageState["favouriteItemsActive"];
                if (e.PageState.ContainsKey("archivedItemsActive"))
                    archivedItemsMenuButton.IsChecked = (bool)e.PageState["archivedItemsActive"];
            }
            base.LoadState(e);
        }

        protected override void ChangedSize(Windows.UI.Core.WindowSizeChangedEventArgs e)
        {
            if (e.Size.Width >= 500)
            {
                unreadItemsText.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                favouriteItemsText.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                archivedItemsText.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

                layoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new Windows.UI.Xaml.GridLength(100) });
                layoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star) });
                layoutRoot.ColumnDefinitions.Clear();

                navigationGrid.RowDefinitions.Clear();
                navigationGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new Windows.UI.Xaml.GridLength(100) });
                navigationGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star) });

                Grid.SetColumn(menuStackPanel, 1);
                menuStackPanel.Orientation = Orientation.Horizontal;

                Grid.SetRow(unreadItems, 1);
                Grid.SetRow(favouriteItems, 1);
                Grid.SetRow(archivedItems, 1);
            }
            else if (e.Size.Width >= 800 || e.Size.Height > e.Size.Width)
            {
                unreadItemsText.Visibility = Windows.UI.Xaml.Visibility.Visible;
                favouriteItemsText.Visibility = Windows.UI.Xaml.Visibility.Visible;
                archivedItemsText.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            else if (e.Size.Width >= 1100)
            {

            }
            else
            {

            }
        }

        void MainPage_CommandsRequested(Windows.UI.ApplicationSettings.SettingsPane sender, Windows.UI.ApplicationSettings.SettingsPaneCommandsRequestedEventArgs args)
        {
            SettingsCommand generalSettings = new SettingsCommand("generalSettings", Helpers.LocalizedString("generalSettingsText"), (handler) =>
            {
                generalSettingsFlyout settingsFlyout = new generalSettingsFlyout();
                settingsFlyout.Show();
            });

            SettingsCommand readingSettings = new SettingsCommand("readingSettings", Helpers.LocalizedString("readingSettingsText"), (handler) =>
            {<commit_msg>Add some bugfixes and include widescreen layout for app resizing.<commit_after>﻿using wallabag.Common;
using wallabag.Views;
using Windows.UI.ApplicationSettings;
using Windows.UI.Xaml.Controls;

namespace wallabag
{
    public sealed partial class MainPage : basicPage
    {
        public MainPage()
        {
            this.InitializeComponent();
            SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;
        }

        protected override void SaveState(SaveStateEventArgs e)
        {
            e.PageState.Add("unreadItemsActive", unreadItemsMenuButton.IsChecked);
            e.PageState.Add("favouriteItemsActive", favouriteItemsMenuButton.IsChecked);
            e.PageState.Add("archivedItemsActive", archivedItemsMenuButton.IsChecked);
            base.SaveState(e);
        }

        protected override void LoadState(LoadStateEventArgs e)
        {
            if (e.PageState != null)
            {
                if (e.PageState.ContainsKey("unreadItemsActive"))
                    unreadItemsMenuButton.IsChecked = (bool)e.PageState["unreadItemsActive"];
                if (e.PageState.ContainsKey("favouriteItemsActive"))
                    favouriteItemsMenuButton.IsChecked = (bool)e.PageState["favouriteItemsActive"];
                if (e.PageState.ContainsKey("archivedItemsActive"))
                    archivedItemsMenuButton.IsChecked = (bool)e.PageState["archivedItemsActive"];
            }
            base.LoadState(e);
        }

        protected override void ChangedSize(Windows.UI.Core.WindowSizeChangedEventArgs e)
        {
            if (e.Size.Width >= 500)
            {
                unreadItemsText.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                favouriteItemsText.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                archivedItemsText.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

                layoutRoot.ColumnDefinitions.Clear();
                layoutRoot.RowDefinitions.Clear();
                layoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new Windows.UI.Xaml.GridLength(100) });
                layoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star) });
                

                navigationGrid.RowDefinitions.Clear();
                navigationGrid.ColumnDefinitions.Clear();
                navigationGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new Windows.UI.Xaml.GridLength(100) });
                navigationGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star) });

                Grid.SetColumn(menuStackPanel, 1);
                menuStackPanel.Orientation = Orientation.Horizontal;

                Grid.SetRow(unreadItems, 1);
                Grid.SetRow(favouriteItems, 1);
                Grid.SetRow(archivedItems, 1);
            }
            else if (e.Size.Width >= 800 || e.Size.Height > e.Size.Width)
            {
                unreadItemsText.Visibility = Windows.UI.Xaml.Visibility.Visible;
                favouriteItemsText.Visibility = Windows.UI.Xaml.Visibility.Visible;
                archivedItemsText.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            else if (e.Size.Width >= 1100)
            {
                layoutRoot.RowDefinitions.Clear();
                layoutRoot.ColumnDefinitions.Clear();
                layoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = new Windows.UI.Xaml.GridLength(320) });
                layoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star) });

                navigationGrid.ColumnDefinitions.Clear();
                navigationGrid.RowDefinitions.Clear();
                navigationGrid.RowDefinitions.Add(new RowDefinition() { Height = new Windows.UI.Xaml.GridLength(180) });
                navigationGrid.RowDefinitions.Add(new RowDefinition() { Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star) });

                Grid.SetColumn(menuStackPanel, 0);
                menuStackPanel.Orientation = Orientation.Vertical;

                Grid.SetRow(unreadItems, 0);
                Grid.SetRow(favouriteItems, 0);
                Grid.SetRow(archivedItems, 0);
            }
            else
            {

            }
        }

        void MainPage_CommandsRequested(Windows.UI.ApplicationSettings.SettingsPane sender, Windows.UI.ApplicationSettings.SettingsPaneCommandsRequestedEventArgs args)
        {
            SettingsCommand generalSettings = new SettingsCommand("generalSettings", Helpers.LocalizedString("generalSettingsText"), (handler) =>
            {
                generalSettingsFlyout settingsFlyout = new generalSettingsFlyout();
                settingsFlyout.Show();
            });

            SettingsCommand readingSettings = new SettingsCommand("readingSettings", Helpers.LocalizedString("readingSettingsText"), (handler) =>
            {
{'fraction_non_alphanumeric': 0.09701327433628319, 'fraction_numerical': 0.006194690265486726, 'mean_word_length': 2.288832302655511, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4658391', 'n_tokens_mistral': 2412, 'n_tokens_neox': 2240, 'n_words': 329}