From 61aae45cd4b2abdc9240074899b9ab6d4f011d06 Mon Sep 17 00:00:00 2001 From: makeevrserg Date: Wed, 10 Jul 2024 12:39:55 +0300 Subject: [PATCH] add power to ui generator --- .../ifrmvp/parser/UiGeneratorImpl.kt | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/ui-generator/src/main/kotlin/com/flipperdevices/ifrmvp/parser/UiGeneratorImpl.kt b/modules/ui-generator/src/main/kotlin/com/flipperdevices/ifrmvp/parser/UiGeneratorImpl.kt index a3ea9a0..1402e24 100644 --- a/modules/ui-generator/src/main/kotlin/com/flipperdevices/ifrmvp/parser/UiGeneratorImpl.kt +++ b/modules/ui-generator/src/main/kotlin/com/flipperdevices/ifrmvp/parser/UiGeneratorImpl.kt @@ -5,6 +5,7 @@ import com.flipperdevices.ifrmvp.model.IfrButton import com.flipperdevices.ifrmvp.model.IfrKeyIdentifier import com.flipperdevices.ifrmvp.model.PageLayout import com.flipperdevices.ifrmvp.model.PagesLayout +import com.flipperdevices.ifrmvp.model.buttondata.IconButtonData import com.flipperdevices.ifrmvp.model.buttondata.TextButtonData import com.flipperdevices.infrared.editor.viewmodel.InfraredKeyParser @@ -20,11 +21,23 @@ class UiGeneratorImpl : UiGenerator { PageLayout( buttons = signals.map { signal -> x += 1 + val keyIdentifier = IfrKeyIdentifier.Name(signal.name) IfrButton( - data = TextButtonData( - keyIdentifier = IfrKeyIdentifier.Name(signal.name), - text = signal.name - ), + data = when { + signal.name.contains("pwr", true) + || signal.name.contains("power", true) + || signal.name.contains("on", true) -> { + IconButtonData( + keyIdentifier = keyIdentifier, + iconId = IconButtonData.IconType.POWER + ) + } + + else -> TextButtonData( + keyIdentifier = keyIdentifier, + text = signal.name + ) + }, position = IfrButton.Position( y = (x / MAX_COLUMNS) % MAX_ROWS, x = x % MAX_COLUMNS