From ab362e8c3b12a915e725f9703a9fb4e9136cc248 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 7 Sep 2024 02:43:05 +0600 Subject: [PATCH] start updating up to 18.2.0 --- .../src/main/kotlin/StarTransactionsBot.kt | 6 +-- WebApp/src/jsMain/kotlin/main.kt | 44 ++++++++++++++++++- gradle.properties | 2 +- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/StarTransactionsBot/src/main/kotlin/StarTransactionsBot.kt b/StarTransactionsBot/src/main/kotlin/StarTransactionsBot.kt index 1a5f7c2..e964cc3 100644 --- a/StarTransactionsBot/src/main/kotlin/StarTransactionsBot.kt +++ b/StarTransactionsBot/src/main/kotlin/StarTransactionsBot.kt @@ -12,10 +12,7 @@ import dev.inmo.tgbotapi.extensions.api.send.send import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* import dev.inmo.tgbotapi.extensions.utils.extensions.sameChat -import dev.inmo.tgbotapi.extensions.utils.types.buttons.dataButton -import dev.inmo.tgbotapi.extensions.utils.types.buttons.flatInlineKeyboard -import dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard -import dev.inmo.tgbotapi.extensions.utils.types.buttons.payButton +import dev.inmo.tgbotapi.extensions.utils.types.buttons.* import dev.inmo.tgbotapi.extensions.utils.withContentOrNull import dev.inmo.tgbotapi.requests.abstracts.asMultipartFile import dev.inmo.tgbotapi.types.RawChatId @@ -30,6 +27,7 @@ import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.stars.StarTransaction +import dev.inmo.tgbotapi.types.request.RequestId import dev.inmo.tgbotapi.utils.bold import dev.inmo.tgbotapi.utils.buildEntities import dev.inmo.tgbotapi.utils.regular diff --git a/WebApp/src/jsMain/kotlin/main.kt b/WebApp/src/jsMain/kotlin/main.kt index 17aed8e..6802855 100644 --- a/WebApp/src/jsMain/kotlin/main.kt +++ b/WebApp/src/jsMain/kotlin/main.kt @@ -182,7 +182,7 @@ fun main() { val hex = Color.Hex(r, g, b) webApp.setHeaderColor(hex) (this as? HTMLButtonElement) ?.style ?.backgroundColor = hex.value - textContent = "Header color: ${hex.value.uppercase()} (click to change)" + textContent = "Header color: ${webApp.headerColor ?.uppercase()} (click to change)" } addEventListener("click", { updateHeaderColor() @@ -192,6 +192,38 @@ fun main() { document.body ?.appendElement("p", {}) + document.body ?.appendElement("button") { + fun updateBackgroundColor() { + val (r, g, b) = Random.nextUBytes(3) + val hex = Color.Hex(r, g, b) + webApp.setBackgroundColor(hex) + (this as? HTMLButtonElement) ?.style ?.backgroundColor = hex.value + textContent = "Background color: ${webApp.backgroundColor ?.uppercase()} (click to change)" + } + addEventListener("click", { + updateBackgroundColor() + }) + updateBackgroundColor() + } ?: window.alert("Unable to load body") + + document.body ?.appendElement("p", {}) + + document.body ?.appendElement("button") { + fun updateBottomBarColor() { + val (r, g, b) = Random.nextUBytes(3) + val hex = Color.Hex(r, g, b) + webApp.setBottomBarColor(hex) + (this as? HTMLButtonElement) ?.style ?.backgroundColor = hex.value + textContent = "Bottom bar color: ${webApp.bottomBarColor ?.uppercase()} (click to change)" + } + addEventListener("click", { + updateBottomBarColor() + }) + updateBottomBarColor() + } ?: window.alert("Unable to load body") + + document.body ?.appendElement("p", {}) + fun Element.updateCloudStorageContent() { clear() webApp.cloudStorage.getAll { @@ -287,6 +319,16 @@ fun main() { } show() } + secondaryButton.apply { + setText("Secondary button") + onClick { + document.body ?.log("Secondary button clicked") + hapticFeedback.notificationOccurred( + HapticFeedbackType.Warning + ) + } + show() + } onSettingsButtonClicked { document.body ?.log("Settings button clicked") } diff --git a/gradle.properties b/gradle.properties index e408ba2..33e7e83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ kotlin.daemon.jvmargs=-Xmx3g -Xms500m kotlin_version=2.0.20 -telegram_bot_api_version=18.1.0 +telegram_bot_api_version=18.2.0 micro_utils_version=0.22.2 serialization_version=1.7.2 ktor_version=2.3.12