/// <summary>
 /// Activate tab
 /// </summary>
 /// <param name="index">Tab index</param>
 /// <param name="direction">Swipe direction</param>
 public void Activate(int index, TabDirection direction)
 {
     if (index < 0 || index > Tabs.Length - 1)
     {
         return;
     }
     Tabs[index].ChangeState(TabState.ENABLE, direction);
 }
Esempio n. 2
0
        /// <summary>
        /// Handles logic for changing tabs forward or backwards
        /// </summary>
        /// <param name="tabDirection">Tabdirection Object forward or backwards</param>
        private void changeTab(TabDirection tabDirection)
        {
            switch (tabDirection)
            {
            case TabDirection.Forward:

                switch (tabControl1.SelectedIndex)
                {
                case 0:
                    TabBackButton.Text        = "Back to Followed Streamers";
                    TabForwardButton.Text     = "Forward to Download Stream";
                    TabBackButton.Enabled     = true;
                    tabControl1.SelectedIndex = 1;
                    break;

                case 1:
                    TabBackButton.Text        = "Back to Past Streams";
                    TabForwardButton.Text     = "Cannot go forward";
                    tabControl1.SelectedIndex = 2;
                    TabForwardButton.Enabled  = false;
                    break;

                case 2:
                    break;
                }
                break;


            case TabDirection.Back:

                switch (tabControl1.SelectedIndex)
                {
                case 0:

                    break;

                case 1:
                    TabBackButton.Text        = "Cannot go back";
                    TabForwardButton.Text     = "Forward to Past Streams";
                    TabBackButton.Enabled     = false;
                    tabControl1.SelectedIndex = 0;
                    break;

                case 2:
                    TabBackButton.Text        = "Back to Followed Streamers";
                    TabForwardButton.Text     = "Forward to Download Stream";
                    TabForwardButton.Enabled  = true;
                    tabControl1.SelectedIndex = 1;
                    break;
                }


                break;

            default:
                break;
            }
        }
        Selectable FindNextSelectable(Selectable selectable, TabDirection direction)
        {
            int           columnIndex = -1, rowIndex = -1;
            CellContainer cellContainer = selectable.GetComponentInParent <CellContainer>();

            for (int i = 0; i < tableColumns.Count; i++)
            {
                int row = tableColumns[i].IndexOf(cellContainer);
                if (row >= 0)
                {
                    columnIndex = i;
                    rowIndex    = row;
                    break;
                }
            }
            if (columnIndex < 0 || rowIndex < 0)
            {
                return(null);
            }
            if (direction == TabDirection.Forward)
            {
                for (int i = rowIndex; i < ElementCount; i++)
                {
                    int startIndex = (i == rowIndex) ? columnIndex + 1 : 0;
                    for (int j = startIndex; j < tableColumns.Count; j++)
                    {
                        Selectable s = GetSelectableFromCellAt(j, i);
                        if (s != null)
                        {
                            return(s);
                        }
                    }
                }
            }
            else
            {
                for (int i = rowIndex; i >= 0; i--)
                {
                    int startIndex = (i == rowIndex) ? columnIndex - 1 : tableColumns.Count - 1;
                    for (int j = startIndex; j >= 0; j--)
                    {
                        Selectable s = GetSelectableFromCellAt(j, i);
                        if (s != null)
                        {
                            return(s);
                        }
                    }
                }
            }
            return(null);
        }
        /// <summary>
        /// Callback on tabs change
        /// </summary>
        /// <param name="tab">Tab container instance</param>
        /// <param name="state">Changed state</param>
        void OnStateChage(TabContainer tab, bool state)
        {
            if (_previousIndex == tab.Index)
            {
                return;
            }
            int previous = _previousIndex;

            _previousIndex = tab.Index;
            if (previous < 0)
            {
                return;
            }
            TabDirection direction = (previous > tab.Index) ? TabDirection.LEFT : TabDirection.RIGHT;

            Tabs[previous].SetState(false, direction);
            OnStateChange(tab.Index);
        }
Esempio n. 5
0
 /// <summary>
 /// Show/hide tab content
 /// </summary>
 /// <param name="value">State</param>
 /// <param name="direction">Direction to move tab</param>
 public void Switch(bool value, TabDirection direction)
 {
     if (direction == TabDirection.NONE)
     {
         Content.SetActive(value);
         _transform.DOAnchorPosX(0f, 0f);
         return;
     }
     if (value)
     {
         float position = (direction == TabDirection.LEFT) ? -REFERENCE_SCREEN_WIDTH : REFERENCE_SCREEN_WIDTH;
         _transform.DOAnchorPosX(position, 0f).OnComplete(() => {
             Content.SetActive(true);
             _transform.DOAnchorPosX(0f, TAB_MOVE_DURATION);
         });
     }
     else
     {
         float position = (direction == TabDirection.LEFT) ? REFERENCE_SCREEN_WIDTH : -REFERENCE_SCREEN_WIDTH;
         _transform.DOAnchorPosX(position, TAB_MOVE_DURATION).OnComplete(() => {
             Content.SetActive(false);
         });
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Change tab state
 /// </summary>
 /// <param name="state">State to change</param>
 /// <param name="direction">Swipe direction</param>
 public void ChangeState(TabState state, TabDirection direction)
 {
     _state = (state == TabState.DISABLE) ? false : true;
     OnStateChange(this, _state);
     SetState(_state, direction);
 }
Esempio n. 7
0
 /// <summary>
 /// Set state manually from controller
 /// </summary>
 /// <param name="state">State to change</param>
 /// <param name="direction">Swipe direction</param>
 public void SetState(bool state, TabDirection direction)
 {
     _state = state;
     _view.Switch(_state, direction);
 }