Adding NavigationBarVisibility property to hide/show navigation buttons auto/never/always
This commit is contained in:
parent
e9504f3b36
commit
31c8231b2d
@ -65,6 +65,9 @@ namespace TelegramBotBase.Controls
|
||||
|
||||
public String SearchQuery { get; set; }
|
||||
|
||||
public eNavigationBarVisibility NavigationBarVisibility { get; set; } = eNavigationBarVisibility.always;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Index of the current page
|
||||
/// </summary>
|
||||
@ -413,13 +416,14 @@ namespace TelegramBotBase.Controls
|
||||
bf.AddButtonRow(new ButtonBase(NoItemsLabel, "$"));
|
||||
}
|
||||
|
||||
if (this.NavigationBarVisibility == eNavigationBarVisibility.always | (this.NavigationBarVisibility == eNavigationBarVisibility.auto && PagingNecessary))
|
||||
{
|
||||
//🔍
|
||||
List<ButtonBase> lst = new List<ButtonBase>();
|
||||
lst.Add(new ButtonBase(PreviousPageLabel, "$previous$"));
|
||||
lst.Add(new ButtonBase(String.Format(Localizations.Default.Language["ButtonGrid_CurrentPage"], this.CurrentPageIndex + 1, this.PageCount), "$site$"));
|
||||
lst.Add(new ButtonBase(NextPageLabel, "$next$"));
|
||||
|
||||
|
||||
if (this.EnableSearch)
|
||||
{
|
||||
lst.Insert(2, new ButtonBase("🔍 " + (this.SearchQuery ?? ""), "$search$"));
|
||||
@ -428,6 +432,7 @@ namespace TelegramBotBase.Controls
|
||||
bf.InsertButtonRow(0, lst);
|
||||
|
||||
bf.AddButtonRow(lst);
|
||||
}
|
||||
|
||||
return bf;
|
||||
}
|
||||
@ -436,7 +441,12 @@ namespace TelegramBotBase.Controls
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((this.KeyboardType == eKeyboardType.InlineKeyBoard && ButtonsForm.Rows > Constants.Telegram.MaxInlineKeyBoardRows) | (this.KeyboardType == eKeyboardType.ReplyKeyboard && ButtonsForm.Rows > Constants.Telegram.MaxReplyKeyboardRows))
|
||||
if (this.KeyboardType == eKeyboardType.InlineKeyBoard && TotalRows > Constants.Telegram.MaxInlineKeyBoardRows)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.KeyboardType == eKeyboardType.ReplyKeyboard && TotalRows > Constants.Telegram.MaxReplyKeyboardRows)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -466,6 +476,18 @@ namespace TelegramBotBase.Controls
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of all rows (layout + navigation + content);
|
||||
/// </summary>
|
||||
public int TotalRows
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.LayoutRows + ButtonsForm.Rows;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Contains the Number of Rows which are used by the layout.
|
||||
/// </summary>
|
||||
@ -473,7 +495,10 @@ namespace TelegramBotBase.Controls
|
||||
{
|
||||
get
|
||||
{
|
||||
int layoutRows = 2;
|
||||
int layoutRows = 0;
|
||||
|
||||
if (this.NavigationBarVisibility == eNavigationBarVisibility.always | this.NavigationBarVisibility == eNavigationBarVisibility.auto)
|
||||
layoutRows += 2;
|
||||
|
||||
if (this.HeadLayoutButtonRow != null && this.HeadLayoutButtonRow.Count > 0)
|
||||
layoutRows++;
|
||||
|
||||
25
TelegramBotBase/Enums/eNavigationBarVisibility.cs
Normal file
25
TelegramBotBase/Enums/eNavigationBarVisibility.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TelegramBotBase.Enums
|
||||
{
|
||||
public enum eNavigationBarVisibility
|
||||
{
|
||||
/// <summary>
|
||||
/// Shows it depending on the amount of items.
|
||||
/// </summary>
|
||||
auto = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Will not show it at any time.
|
||||
/// </summary>
|
||||
never = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Will show it at any time.
|
||||
/// </summary>
|
||||
always = 2
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user