1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 00:03:48 +00:00

update webapp part

This commit is contained in:
InsanusMokrassar 2024-01-04 17:52:57 +06:00
parent d9c39d7a26
commit 860e35258c
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,11 @@
package dev.inmo.tgbotapi.webapps
external interface SettingsButton {
val isVisible: Boolean
fun onClick(callback: () -> Unit)
fun offClick(callback: () -> Unit)
fun show()
fun hide()
}

View File

@ -30,4 +30,17 @@ external interface ThemeParams {
val buttonColorHex: Color.Hex?
@JsName("button_text_color")
val buttonTextColorHex: Color.Hex?
@JsName("header_bg_color")
val headerBgColor: Color.Hex?
@JsName("accent_text_color")
val accentTextColor: Color.Hex?
@JsName("section_bg_color")
val sectionBgColor: Color.Hex?
@JsName("section_header_text_color")
val sectionHeaderTextColor: Color.Hex?
@JsName("subtitle_text_color")
val subtitleTextColor: Color.Hex?
@JsName("destructive_text_color")
val destructiveTextColor: Color.Hex?
}

View File

@ -54,6 +54,9 @@ external class WebApp {
@JsName("CloudStorage")
val cloudStorage: CloudStorage
@JsName("SettingsButton")
val settingsButton: SettingsButton
internal fun onEvent(type: String, callback: () -> Unit)
@JsName("onEvent")
internal fun onEventWithViewportChangedData(type: String, callback: (ViewportChangedData) -> Unit)
@ -69,6 +72,8 @@ external class WebApp {
internal fun onEventWithWriteAccessRequested(type: String, callback: (RequestStatus) -> Unit)
@JsName("onEvent")
internal fun onEventWithContactRequested(type: String, callback: (RequestStatus) -> Unit)
@JsName("onEvent")
internal fun onEventWithSettingsButtonClicked(type: String, callback: () -> Unit)
fun offEvent(type: String, callback: () -> Unit)
@JsName("offEvent")
@ -194,6 +199,18 @@ fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactReques
)
}
/**
* @return The callback which should be used in case you want to turn off events handling
*/
fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: EventHandler) = {
eventHandler(js("this").unsafeCast<WebApp>())
}.also {
onEventWithSettingsButtonClicked(
type.typeName,
callback = it
)
}
/**
* @return The callback which should be used in case you want to turn off events handling
*/