mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-21 15:53:47 +00:00
update webapp part
This commit is contained in:
parent
d9c39d7a26
commit
860e35258c
@ -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()
|
||||
}
|
@ -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?
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user