<commit_before>using Uno;
using Uno.UX;
using Uno.Collections;
using Fuse.Scripting;
using Fuse.Triggers;
using Fuse.Animations;
using Fuse.Elements;

namespace Fuse.Navigation
{
	public abstract partial class VisualNavigation : Behavior, INavigation, IParentObserver
	{
		static VisualNavigation()
		{
			ScriptClass.Register(typeof(VisualNavigation),
				new ScriptMethod<VisualNavigation>("goto", gotoNode));
		}

		/**
			Transition to the target node.
			
			@scriptmethod goto(node)
			@param node The `Visual` target for the transition. For most navigation types this must already be
				 a child of the navigation panel.
		*/
		static void gotoNode(VisualNavigation nav, object[] args)
		{
			var target = args[0] as Visual;
			if (target != null) nav.Goto(target);
			else Fuse.Diagnostics.UserError("Navigation.goto() : Argument must be a node object", nav);
		}

		internal VisualNavigation() { }

		public abstract void Goto(Visual element, NavigationGotoMode mode = NavigationGotoMode.Transition);
		public abstract Visual Active { get; set; }
		public virtual void Toggle(Visual page) { }

		public abstract double PageProgress { get; }
		public virtual NavigationPageState GetPageState(Visual page)
		{
			var pd = GetPageData(page);
			if (pd == null)
				return new NavigationPageState{ Progress = 0, PreviousProgress = 0 };
			return new NavigationPageState{ 
				Progress = pd.Progress, PreviousProgress = pd.PreviousProgress };
		}

		public event NavigationPageCountHandler PageCountChanged;
		
		NavigationState _navState = NavigationState.Stable;
		public NavigationState State
		{
			get { return _navState; }
		}
		public event ValueChangedHandler<NavigationState> StateChanged;
		
		protected void OnStateChanged(NavigationState newState)
		{
			if (newState == _navState)
				return;
				
			_navState = newState;
			if (StateChanged != null)
				StateChanged( this, new ValueChangedArgs<NavigationState>(newState) );
		}

		protected void OnPageCountChanged()
		{
			if (PageCountChanged != null)
				PageCountChanged(this);
		}

		public event NavigationHandler PageProgressChanged;

		protected void OnPageProgressChanged(NavigationMode mode)
		{
			OnPageProgressChanged(0,0,mode);
		}
		
		protected void OnPageProgressChanged(double current, double prev, NavigationMode mode)
		{
			if (PageProgressChanged != null)
				PageProgressChanged(this, new NavigationArgs(current, prev, mode) );
		}

		public event NavigatedHandler Navigated;

		/**
			Call when the navigation to the target page is completed.
		*/
		protected void OnNavigated(Visual newElement)
		{
			var handler = Navigated;
			if (handler != null)
			{
				handler(this, new NavigatedArgs(newElement));
			}
		}
		
		public event ActivePageChangedHandler ActivePageChanged;
		
		/**
			Call immedaitely when the active page changes (when it is set). This happens prior to animation,
			so strictly prior to `OnNavigated` (though within the same frame, the next calls, is fine).
		*/
		protected void OnActiveChanged(Visual newElement)
		{
			OnPropertyChanged(ActiveIndexName);
			
			if (ActivePageChanged != null)
				ActivePageChanged(this, newElement);
		}

		public event HistoryChangedHandler HistoryChanged;

		protected void OnHistoryChanged()
		{
			if (HistoryChanged != null)
				HistoryChanged(this);
		}

		public virtual void GoForward() { }
		public virtual void GoBack() { }
		public virtual bool CanGoBack { get { return false; } }
		public virtual bool CanGoForward { get { return false; } }
		public virtual void ClearHistory() { }

		
		List<PageData> _pages = new List<PageData>();
		
		internal protected IList<PageData> Pages { get { return _pages; } }
		
		internal PageData GetPageData( Visual page ) 
		{
			if (page == null)
				return null;
				
			return PageData.Get(page);
		}
		
		protected override void OnRooted()
		{
			base.OnRooted();
			UpdatePages();
		}

		void UpdatePages()
		{
			_pages.Clear();
			int c = 0;
			for (var x = Parent.FirstChild<Visual>(); x != null; x = x.NextSibling<Visual>())<commit_msg>Fuse.Navigation: fix visibility problem<commit_after>using Uno;
using Uno.UX;
using Uno.Collections;
using Fuse.Scripting;
using Fuse.Triggers;
using Fuse.Animations;
using Fuse.Elements;

namespace Fuse.Navigation
{
	public abstract partial class VisualNavigation : Behavior, INavigation, IParentObserver
	{
		static VisualNavigation()
		{
			ScriptClass.Register(typeof(VisualNavigation),
				new ScriptMethod<VisualNavigation>("goto", gotoNode));
		}

		/**
			Transition to the target node.
			
			@scriptmethod goto(node)
			@param node The `Visual` target for the transition. For most navigation types this must already be
				 a child of the navigation panel.
		*/
		static void gotoNode(VisualNavigation nav, object[] args)
		{
			var target = args[0] as Visual;
			if (target != null) nav.Goto(target);
			else Fuse.Diagnostics.UserError("Navigation.goto() : Argument must be a node object", nav);
		}

		internal VisualNavigation() { }

		public abstract void Goto(Visual element, NavigationGotoMode mode = NavigationGotoMode.Transition);
		public abstract Visual Active { get; set; }
		public virtual void Toggle(Visual page) { }

		public abstract double PageProgress { get; }
		public virtual NavigationPageState GetPageState(Visual page)
		{
			var pd = GetPageData(page);
			if (pd == null)
				return new NavigationPageState{ Progress = 0, PreviousProgress = 0 };
			return new NavigationPageState{ 
				Progress = pd.Progress, PreviousProgress = pd.PreviousProgress };
		}

		public event NavigationPageCountHandler PageCountChanged;
		
		NavigationState _navState = NavigationState.Stable;
		public NavigationState State
		{
			get { return _navState; }
		}
		public event ValueChangedHandler<NavigationState> StateChanged;
		
		protected void OnStateChanged(NavigationState newState)
		{
			if (newState == _navState)
				return;
				
			_navState = newState;
			if (StateChanged != null)
				StateChanged( this, new ValueChangedArgs<NavigationState>(newState) );
		}

		protected void OnPageCountChanged()
		{
			if (PageCountChanged != null)
				PageCountChanged(this);
		}

		public event NavigationHandler PageProgressChanged;

		protected void OnPageProgressChanged(NavigationMode mode)
		{
			OnPageProgressChanged(0,0,mode);
		}
		
		protected void OnPageProgressChanged(double current, double prev, NavigationMode mode)
		{
			if (PageProgressChanged != null)
				PageProgressChanged(this, new NavigationArgs(current, prev, mode) );
		}

		public event NavigatedHandler Navigated;

		/**
			Call when the navigation to the target page is completed.
		*/
		protected void OnNavigated(Visual newElement)
		{
			var handler = Navigated;
			if (handler != null)
			{
				handler(this, new NavigatedArgs(newElement));
			}
		}
		
		public event ActivePageChangedHandler ActivePageChanged;
		
		/**
			Call immedaitely when the active page changes (when it is set). This happens prior to animation,
			so strictly prior to `OnNavigated` (though within the same frame, the next calls, is fine).
		*/
		protected void OnActiveChanged(Visual newElement)
		{
			OnPropertyChanged(ActiveIndexName);
			
			if (ActivePageChanged != null)
				ActivePageChanged(this, newElement);
		}

		public event HistoryChangedHandler HistoryChanged;

		protected void OnHistoryChanged()
		{
			if (HistoryChanged != null)
				HistoryChanged(this);
		}

		public virtual void GoForward() { }
		public virtual void GoBack() { }
		public virtual bool CanGoBack { get { return false; } }
		public virtual bool CanGoForward { get { return false; } }
		public virtual void ClearHistory() { }

		
		List<PageData> _pages = new List<PageData>();
		
		internal IList<PageData> Pages { get { return _pages; } }
		
		internal PageData GetPageData( Visual page ) 
		{
			if (page == null)
				return null;
				
			return PageData.Get(page);
		}
		
		protected override void OnRooted()
		{
			base.OnRooted();
			UpdatePages();
		}

		void UpdatePages()
		{
			_pages.Clear();
			int c = 0;
			for (var x = Parent.FirstChild<Visual>(); x != null; x = x.NextSibling<Visual>())
{'fraction_non_alphanumeric': 0.08974358974358974, 'fraction_numerical': 0.0014792899408284023, 'mean_word_length': 3.8814681107099878, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '1876041', 'n_tokens_mistral': 2759, 'n_tokens_neox': 2264, 'n_words': 705}