spierce7
04/14/2021, 7:10 PMYASAN
04/14/2021, 7:20 PMprivate val DarkColors = darkColors(
primary = Yellow200,
secondary = Blue200,
// ...
)
private val LightColors = lightColors(
primary = Yellow500,
primaryVariant = Yellow400,
secondary = Blue700,
// ...
)
but these can hold like 10 variables, I need my own custom color variables which change depending on the theme. Its super easy to do using XML resources but I am unsure if that's what I should do. Should I just use xml resources for this? or is there a way to handle those in Compose?YASAN
04/14/2021, 10:07 PMJason Ankers
04/15/2021, 2:26 AMworkouts/{id}/edit
) it navigates to the next shortest route instead (workouts/{id}
)Deepak Gahlot
04/15/2021, 6:38 AMYuri Drigin
04/15/2021, 8:23 AMHeikki Rauhala
04/15/2021, 10:25 AMModifier.focusModifier().onFocusChanged { ... }
, the onFocusChanged
handler is not called, while if they're reversed Modifier.onFocusChanged { ... }.focusModifier()
, it is called.Daniele Segato
04/15/2021, 11:08 AMBox
, Row
, Column
, it used functions like h1
which are closer to html.ste
04/15/2021, 12:07 PMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
var clicksAmount by remember { mutableStateOf(0) }
fun onItemClick(index: Int): () -> Unit = { repeat(index) { clicksAmount++ } }
BasicText(text = "Clicks: $clicksAmount")
LazyRow(
contentPadding = PaddingValues(12.dp),
content = { items(listOf(1, 2, 3)) { Example(it, onItemClick(it)) } }
)
}
}
}
@Composable
fun Example(index: Int, onClick: () -> Unit) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(top = 12.dp).clickable { onClick() }
) {
Image(painterResource(android.R.drawable.star_on), contentDescription = null)
BasicText(text = index.toString())
}
}
I get a huge build error when trying to build it.
By the way, the combination of by
(var clicksAmount by
) and ++
(clicksAmount++
) is the cause. For instance, var clicksAmount = remember { ... }
or clicksAmount += 1
builds just fine.
Is this an issue? I tried to google but didn't find anything, probably missed the right keywordsaiidziis
04/15/2021, 12:26 PM./gradlew check
to fail with weird lint errors we never had before.PHondogo
04/15/2021, 12:58 PMjames
04/15/2021, 1:10 PMColton Idle
04/15/2021, 4:52 PMSocheat KHAUV
04/15/2021, 5:33 PMYASAN
04/15/2021, 6:20 PMval parentViewModel = hiltNavGraphViewModel<ParentViewModel>("Parent")
but no matter what I do it imports the wrong hiltNavGraphViewModel which takes backStackEntry as a param and does not work in the end.
When I type hiltNavGraphViewModel I can see the option for the one that has a String param but even after I select it and Android Studio auto completes the code to
hiltNavGraphViewModel(route = )
it is still the one that requires backStackEntry and route is redFunkyMuse
04/16/2021, 12:04 AMSpikey Sanju
04/16/2021, 5:55 AMReorder LazyColumn
items with drag & drop
?Yoshio Schermer
04/16/2021, 7:05 AMYASAN
04/16/2021, 7:10 AMPiotr Prus
04/16/2021, 7:21 AMAdvancedNavigationSample
, so every Tab has its own navGraph. I got three main screens: Map, List and settings(which is also the list TBH). The screens with lists works fine, the scroll position is maintained, nested fragments are maintained, etc. The Map view is recreated each time. Not all the components, but the map, which is added in AndroidView
composable is recreated. I am saving the last location as a state, so the map shown the exact same place when I am coming back to it, but it always “calculates” or draw tiles again.
Is that something for map specific that cannot be changed or something might be wrong with my AndroidView
implementation?YASAN
04/16/2021, 9:23 AMMaxr1998
04/16/2021, 9:39 AMorangy
04/16/2021, 3:04 PMinteractionSource
. Indication
only allows to draw something, but not change how component renders itself, e.g. pseudo-3d button actually moving slightly when pressed, or a component shaking a bit if attempted to interact with it, doing component-specific hover effects, etc. I wonder if anyone already gave it a thought and have ideas/approaches on how to design it?Cicero
04/16/2021, 3:04 PMMjahangiry75
04/16/2021, 4:14 PMText
) to the a LazyVerticalGrid
?enighma
04/16/2021, 6:40 PMYASAN
04/16/2021, 7:01 PMby remember { mutableStateOf(X) }
Using remember takes less time but I am not sure if its recommended over livedata? Although I am not sure if it matters in the end of the day at all or notSe7eN
04/16/2021, 10:18 PMrnett
04/17/2021, 1:54 AMinit
blocks my plugin adds. Things work fine without the compose plugin, but adding it causes the my init blocks to not be present in bytecode (despite them showing up when dumping the IrClass from my plugin). Any idea how to debug this?Colton Idle
04/17/2021, 2:07 AMsetContent
in an Activity seems to kill the ability to use Activity.onTouchEvent()
Is this a bug? 🧵Colton Idle
04/17/2021, 2:07 AMsetContent
in an Activity seems to kill the ability to use Activity.onTouchEvent()
Is this a bug? 🧵class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<Button>(R.id.myButton).setOnClickListener {
Toast.makeText(this, "XML BUTTON CLICKED", Toast.LENGTH_SHORT).show()
}
}
override fun onTouchEvent(event: MotionEvent): Boolean {
if (event.action == MotionEvent.ACTION_UP) {
Toast.makeText(this, "ACTIVITY CLICKED", Toast.LENGTH_SHORT).show()
return true
}
return false
}
}
The xml based layout has a button in the top left corner. When I click the button, I see the XML BUTTON CLICKED toast... and anywhere I click in the Activity I see ACTIVITY CLICKEDclass MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val context = LocalContext.current
Column(Modifier.fillMaxSize()) {
Button({
Toast.makeText(context, "COMPOSE BUTTON CLICKED", Toast.LENGTH_SHORT)
.show()
}) {
Text("Button")
}
}
}
}
override fun onTouchEvent(event: MotionEvent): Boolean {
if (event.action == MotionEvent.ACTION_UP) {
Toast.makeText(this, "ACTIVITY CLICKED", Toast.LENGTH_SHORT).show()
return true
}
return false
}
}
Which does not work. The activity clicked never shows. But the COMPOSE CLICKED does.
Ideas?Albert Chang
04/17/2021, 2:44 AMonTouchEvent
says
Called when a touch screen event was not handled by any of the views under it.
And ComposeView is intercepting all the touch events.
Colton Idle
04/17/2021, 2:47 AMAlbert Chang
04/17/2021, 2:47 AMdispatchTouchEvent
.Colton Idle
04/17/2021, 2:50 AMAlbert Chang
04/17/2021, 2:51 AMColton Idle
04/17/2021, 2:54 AM