APACHE-2.0 License
Proof-of-concept of a Compose for Desktop API for Macbook Touchbars.
fun main() = singleWindowApplication {
TouchBar {
var sliderValue by remember { mutableStateOf(0f) }
TextField("Hello, world!")
Button("Click me!", onClick = { println("I was clicked!") })
Group {
Button("Button1", onClick = {})
Button("Button2", onClick = {})
}
Popover(
collapsedLabel = "Expandable",
popoverContent = {
Slider(
min = 0f,
max = 10f,
onValueChanged = { sliderValue = it }
)
}
)
}
}
This is just a proof-of-concept, and there are some major issues that would need to be addressed before this could be a real thing:
NSScrubber
and maybe a picker seem like particularly good candidates. See https://developer.apple.com/documentation/appkit/nstouchbaritem?language=objc.NSObject
s all over the place.NSSlider
, that should be addressed, and I wonder if this isn't also why things like button clicks sometimes randomly crash.currentCompositeKeyHash
, the same thing that rememberSaveable
does to derive string keys for saved state. However that key is not guaranteed to be unique, and it is very easy to make that happen two calls to the same composable function from the same lambda will have the same composite key. rememberSaveable
handles this by remembering insertion order, and so we could do the same by making TouchBarScope
hash a monotomically-increasing counter with the key hash. This would generate IDs that would be stable across different instances of the same process, although not necessarily across program versions (new versions might have different composables and thus different keys), so it might also be necessary to allow passing explicit ID strings.