Skip to content

Commit

Permalink
add power to ui generator
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg committed Jul 10, 2024
1 parent 69fe9da commit 61aae45
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 61aae45

Please sign in to comment.