Files
BotPages/Demo/Pages/MainPage.cs
FrigaT 4aff8edbcd
All checks were successful
CI / build-test (push) Successful in 31s
Release / pack-and-publish (release) Successful in 1m12s
Доработан менеджер состояний.
2025-12-03 07:15:46 +03:00

52 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using BotPages.Core;
namespace Demo.Pages
{
public sealed class MainPage : Page
{
public override string Id => nameof(MainPage);
public override Task<PageResult> EnterAsync(UpdateContext ctx, CancellationToken ct)
{
var actions = new[]
{
new PageAction(MainPageButtons.Inline) { Placement = ActionPlacement.Reply, Row = 0 },
new PageAction(MainPageButtons.Reply) { Placement = ActionPlacement.Reply, Row = 1 },
new PageAction(MainPageButtons.Files) { Placement = ActionPlacement.Reply, Row = 2 },
};
return Task.FromResult(
PageResultBuilder.Empty()
.WithText("🏠 Главная страница.\nВыберите куда перейти:")
.WithKeyboard(actions)
.Build()
);
}
public override Task<PageResult> HandleAsync(UpdateContext ctx, CancellationToken ct)
{
var button = ActionExtensions.FromActionLabel<MainPageButtons>(ctx.Text);
return button switch
{
MainPageButtons.Inline => Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(InlinePage)).Build()),
MainPageButtons.Reply => Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(ReplyPage)).Build()),
MainPageButtons.Files => Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(FilesPage)).Build()),
_ => Task.FromResult(PageResultBuilder.Empty().WithText("Выберите действие с кнопок.").Build())
};
}
}
public enum MainPageButtons
{
[Action("📌 Inline")]
Inline,
[Action("⌨️ Reply")]
Reply,
[Action("📂 Файлы")]
Files,
}
}