<commit_before>﻿using Microsoft.Toolkit.Uwp.UI.Controls;
using System.Threading.Tasks;
using TUMCampusAppAPI.DBTables;
using TUMCampusAppAPI.Managers;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace TUMCampusApp.Controls.Widgets
{
    public sealed partial class NewsWidgetControl : UserControl
    {
        //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
        #region --Attributes--
        public NewsTable News
        {
            get { return (NewsTable)GetValue(NewsProperty); }
            set { SetValue(NewsProperty, value); }
        }
        public static readonly DependencyProperty NewsProperty = DependencyProperty.Register("News", typeof(NewsTable), typeof(NewsWidgetControl), null);

        public NewsDummyWidgetControl NewsDummyWidget
        {
            get { return (NewsDummyWidgetControl)GetValue(NewsDummyWidgetProperty); }
            set { SetValue(NewsDummyWidgetProperty, value); }
        }
        public static readonly DependencyProperty NewsDummyWidgetProperty = DependencyProperty.Register("NewsDummyWidget", typeof(NewsDummyWidgetControl), typeof(NewsWidgetControl), null);

        #endregion
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--
        /// <summary>
        /// Basic Constructor
        /// </summary>
        /// <history>
        /// 06/04/2018 Created [<NAME>]
        /// </history>
        public NewsWidgetControl()
        {
            this.InitializeComponent();
        }

        #endregion
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--


        #endregion

        #region --Misc Methods (Private)--
        private void markAsRead()
        {
            Visibility = Visibility.Collapsed;
            if (News != null)
            {
                string id = News.id;
                Task.Run(() =>
                {
                    NewsManager.INSTANCE.markNewsAsRead(id);
                });
            }
        }

        #endregion

        #region --Misc Methods (Protected)--


        #endregion
        //--------------------------------------------------------Events:---------------------------------------------------------------------\\
        #region --Events--
        private void slideListItem_sli_SwipeStatusChanged(SlidableListItem sender, SwipeStatusChangedEventArgs args)
        {
            if (args.NewValue == SwipeStatus.Idle)
            {
                if (args.OldValue == SwipeStatus.SwipingPassedRightThreshold)
                {
                    markAsRead();
                }
                else if (args.OldValue == SwipeStatus.SwipingPassedLeftThreshold)
                {
                    NewsDummyWidget?.disableNewsWidgets();
                }
            }
        }

        #endregion
    }
}<commit_msg>Fixed swiping direction<commit_after>﻿using Microsoft.Toolkit.Uwp.UI.Controls;
using System.Threading.Tasks;
using TUMCampusAppAPI.DBTables;
using TUMCampusAppAPI.Managers;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace TUMCampusApp.Controls.Widgets
{
    public sealed partial class NewsWidgetControl : UserControl
    {
        //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
        #region --Attributes--
        public NewsTable News
        {
            get { return (NewsTable)GetValue(NewsProperty); }
            set { SetValue(NewsProperty, value); }
        }
        public static readonly DependencyProperty NewsProperty = DependencyProperty.Register("News", typeof(NewsTable), typeof(NewsWidgetControl), null);

        public NewsDummyWidgetControl NewsDummyWidget
        {
            get { return (NewsDummyWidgetControl)GetValue(NewsDummyWidgetProperty); }
            set { SetValue(NewsDummyWidgetProperty, value); }
        }
        public static readonly DependencyProperty NewsDummyWidgetProperty = DependencyProperty.Register("NewsDummyWidget", typeof(NewsDummyWidgetControl), typeof(NewsWidgetControl), null);

        #endregion
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--
        /// <summary>
        /// Basic Constructor
        /// </summary>
        /// <history>
        /// 06/04/2018 Created [<NAME>]
        /// </history>
        public NewsWidgetControl()
        {
            this.InitializeComponent();
        }

        #endregion
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--


        #endregion

        #region --Misc Methods (Private)--
        private void markAsRead()
        {
            Visibility = Visibility.Collapsed;
            if (News != null)
            {
                string id = News.id;
                Task.Run(() =>
                {
                    NewsManager.INSTANCE.markNewsAsRead(id);
                });
            }
        }

        #endregion

        #region --Misc Methods (Protected)--


        #endregion
        //--------------------------------------------------------Events:---------------------------------------------------------------------\\
        #region --Events--
        private void slideListItem_sli_SwipeStatusChanged(SlidableListItem sender, SwipeStatusChangedEventArgs args)
        {
            if (args.NewValue == SwipeStatus.Idle)
            {
                if (args.OldValue == SwipeStatus.SwipingPassedLeftThreshold)
                {
                    markAsRead();
                }
                else if (args.OldValue == SwipeStatus.SwipingPassedRightThreshold)
                {
                    NewsDummyWidget?.disableNewsWidgets();
                }
            }
        }

        #endregion
    }
}
{'fraction_non_alphanumeric': 0.26323706377858, 'fraction_numerical': 0.0024067388688327317, 'mean_word_length': 1.061705426356589, 'pattern_counts': {'":': 0, '<': 13, '<?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': '976276', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1395, 'n_words': 274}