ursus
07/24/2019, 12:14 AMsngrekov
07/24/2019, 1:19 PMCh8n
07/25/2019, 5:56 AMLeland Richardson [G]
07/31/2019, 5:10 PMhttps://www.youtube.com/watch?v=4EFjDSijAZU▾
moetouban
08/02/2019, 11:15 PMLeland Richardson [G]
08/03/2019, 12:02 AM// normal API to create a store based on readme example
val mainStore = Store(
reducer = ::counterReducer,
state = null
)
// effect-based API to select/subscribe to store in composition
fun <TSlice, TState> Store<TState>.select(selector: (TState) -> TSlice) = effectOf<TSlice> {
val result = +state { selector(state) }
+onCommit(selector) {
val observer = StoreSubscriber<TSlice> { result.value = it }
subscribe(observer, selector)
onDispose {
unsubscribe(observer)
}
}
result.value
}
// usage
@Composable fun SomeView() {
val count = +mainStore.select { it.counter }
Text("Count: $count")
}
Adam Powell
08/04/2019, 1:38 PMLeland Richardson [G]
08/05/2019, 7:50 PMMark Murphy
08/05/2019, 10:41 PMclass SampleRosterFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
inflater.inflate(R.layout.empty_frame, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
(view as ViewGroup).setContent {
Padding(10.dp) {
}
}
}
}
This code causes the IDE and Gradle to go ballistic, with inscrutable error messages:
class SampleRosterFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
inflater.inflate(R.layout.empty_frame, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
(view as ViewGroup).setContent {
MaterialTheme {
Padding(10.dp) {
}
}
}
}
}
Yet that same MaterialTheme
construction works fine from an activity.
I notice that the demos seem activity-centric, though I'm not certain if that is due to current Compose limitations or is tied to other concerns for how you are using those activities.alexsullivan114
08/06/2019, 2:31 PMAmirul Zin
08/07/2019, 6:11 AM@Qualifiers("sw600dp")
@Composable
fun someView(){
...
}
Or maybe just pass in the current qualifiers to the composable function?
If I got off the wrong starting point, please enlighten me. Thanks!Andrey Stepankov
08/13/2019, 11:44 PMlouiscad
08/16/2019, 10:25 AMlouiscad
08/17/2019, 9:18 AM// onConfigurationChange is the correct hook to update configuration, however it is
// possible that the configuration object itself may come from a wrapped
// context / themed activity, and may not actually reflect the system. So instead we
// use this hook to grab the applicationContext's configuration, which accurately
// reflects the state of the application / system.(from https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/ui/ui-framework/src/main/java/androidx/ui/core/Wrapper.kt#170) and I'm concerned it would break the usage of
Context.createConfigurationContext()
usually used when you want to change the language to be different from the default one in the system, or use an app local custom configuration for other purposes.
Why not use the configuration from the given context instead?Mark Murphy
08/19/2019, 5:13 PM@Model
be working in the current Compose code?
I created this based on the @Model
KDoc:
@Model
data class AgreementViewState(var terms: Boolean = true, var privacy: Boolean = false) {
val canProceed = terms && privacy
}
@Composable
private fun Agreement() {
Padding(8.dp) {
val viewState = +model { AgreementViewState() }
Column(mainAxisAlignment = MainAxisAlignment.Start, crossAxisAlignment = CrossAxisAlignment.Start) {
Row(mainAxisAlignment = MainAxisAlignment.Start) {
Checkbox(
checked = viewState.terms,
onCheckedChange = { viewState.terms = it }
)
Text(text = "I agree to the terms and conditions")
}
Row(mainAxisAlignment = MainAxisAlignment.Start) {
Checkbox(
checked = viewState.privacy,
onCheckedChange = { viewState.privacy = it }
)
Text(text = "I agree to the privacy policy")
}
Text(text = if (viewState.canProceed) "You may proceed" else "Please indicate your agreement")
}
}
}
The initial state works (the top Checkbox
is checked). And via logging I can confirm that my onCheckedChange
lambdas are being called. However, the UI is not being recomposed as I update the AgreementViewState
, so the checkboxes and text remain fixed.
By contrast, this works with automatic recomposition as I update the `checkboxState`:
@Composable
private fun SimpleCheckbox() {
Padding(8.dp) {
val checkboxState = +state { true }
Checkbox(
checked = checkboxState.value,
onCheckedChange = { checkboxState.value = it }
)
}
}
I'm trying to determine if there's something that I'm doing wrong or if this is just a current limitation. Thanks!themishkun
08/19/2019, 9:44 PMthemishkun
08/20/2019, 8:47 AM@Composable
fun foo() {
+onActive {
(0..10).maxWith(Comparator<Int> { a, b -> a.compareTo(b) })
}
}
this code above throws long compilation error
but this code below runs fine
@Composable
fun foo() {
+onActive {
(0..10).maxWith(object : Comparator<Int> {
override fun compare(a: Int, b: Int): Int {
return a.compareTo(b)
}
})
}
}
Luca Nicoletti
08/21/2019, 7:58 AMCompose Activity
from the New File > Activity
menu. This creates some files but the code inside of them is broken. any clue? 🙂Luca Nicoletti
08/21/2019, 4:35 PMCaused by: java.lang.IllegalStateException: Composition requires an active composition context
mean? What are the possible causes?romainguy
08/22/2019, 8:23 PMAndrey Danilov
08/24/2019, 6:26 PMjim
08/26/2019, 5:44 PMtk
08/27/2019, 1:22 PMCompose Activity
via File -> New -> Activity
on ui-demos
folder.
But some extra xml files and codes added in build.gradle
, so that the project could not build at all.ben.oberkfell
08/28/2019, 6:36 PMSimon Schubert
08/29/2019, 10:33 AMLuca Nicoletti
08/30/2019, 7:54 PMLuca Nicoletti
09/01/2019, 10:05 AM@Model
class which has a list, adding elements to that list don’t trigger the drawing of the model on the screen. In order to have it working I added a counter
to that model class. Increasing that counter
whenever I add something to the list triggers the drawing of the model on the screen. (https://gist.github.com/lnicolet/039d2fe76e19e859582e32625ac411e7, https://gist.github.com/lnicolet/cb49c5a4021efc3b784bf95ec5755321). Working and not working examples in the links. Is there a different way to have it working with lists
?Jeremy White
09/01/2019, 6:35 PMIcaro Temponi
09/01/2019, 7:06 PMkioba
09/03/2019, 3:39 PMdebugPaintSizeEnabled
kioba
09/03/2019, 3:39 PMdebugPaintSizeEnabled
George Mount
09/03/2019, 3:39 PM