mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2025-11-17 20:00:06 +00:00
complete panel
This commit is contained in:
8
posts/panel/src/commonMain/kotlin/PanelButtonBuilder.kt
Normal file
8
posts/panel/src/commonMain/kotlin/PanelButtonBuilder.kt
Normal file
@@ -0,0 +1,8 @@
|
||||
package dev.inmo.plaguposter.posts.panel
|
||||
|
||||
import dev.inmo.plaguposter.posts.models.RegisteredPost
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
||||
|
||||
fun interface PanelButtonBuilder {
|
||||
suspend fun buildButton(post: RegisteredPost): InlineKeyboardButton?
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package dev.inmo.plaguposter.posts.panel
|
||||
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PanelButtonSettings(
|
||||
val button: InlineKeyboardButton
|
||||
)
|
||||
29
posts/panel/src/commonMain/kotlin/PanelButtonsAPI.kt
Normal file
29
posts/panel/src/commonMain/kotlin/PanelButtonsAPI.kt
Normal file
@@ -0,0 +1,29 @@
|
||||
package dev.inmo.plaguposter.posts.panel
|
||||
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton
|
||||
|
||||
class PanelButtonsAPI(
|
||||
private val preset: List<PanelButtonBuilder>,
|
||||
private val rootPanelButtonText: String
|
||||
) {
|
||||
private val _buttons = mutableSetOf<PanelButtonBuilder>().also {
|
||||
it.addAll(preset)
|
||||
}
|
||||
internal val buttonsBuilders: List<PanelButtonBuilder>
|
||||
get() = _buttons.toList()
|
||||
|
||||
val RootPanelButtonBuilder = PanelButtonBuilder {
|
||||
CallbackDataInlineKeyboardButton(
|
||||
rootPanelButtonText,
|
||||
"$openGlobalMenuDataPrefix${it.id.string}"
|
||||
)
|
||||
}
|
||||
|
||||
fun add(button: PanelButtonBuilder) = _buttons.add(button)
|
||||
fun remove(button: PanelButtonBuilder) = _buttons.remove(button)
|
||||
|
||||
companion object {
|
||||
internal const val openGlobalMenuData = "force_refresh_panel"
|
||||
internal const val openGlobalMenuDataPrefix = "$openGlobalMenuData "
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user