Add support of runtime Id creation
See original GitHub issueI updated my project based on the recent commit of moko-widgets-template, so using 0.1.0-dev-18 now. And my code previously working with -dev12 throws an exception on Android run now.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.example.app.debug, PID: 18128
dev.icerock.moko.widgets.utils.AndroidIdConflictException: id 0x7F081AB9 already used by org.example.mpp.MainScreen$createInput$1$2, it conflict with org.example.mpp.MainScreen$createInput$1$2
at dev.icerock.moko.widgets.utils.IdExtKt.getAndroidId(IdExt.kt:45)
...
I stripped down the test case to minimum for reproducing the error:
- use the current moko-widgets-template
- replace MainScreen.kt with:
/*
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
package org.example.mpp
import dev.icerock.moko.fields.FormField
import dev.icerock.moko.fields.liveBlock
import dev.icerock.moko.resources.desc.StringDesc
import dev.icerock.moko.resources.desc.desc
import dev.icerock.moko.widgets.*
import dev.icerock.moko.widgets.core.Theme
import dev.icerock.moko.widgets.core.Widget
import dev.icerock.moko.widgets.screen.Args
import dev.icerock.moko.widgets.screen.WidgetScreen
import dev.icerock.moko.widgets.style.view.SizeSpec
import dev.icerock.moko.widgets.style.view.WidgetSize
import org.example.library.MR
class MainScreen(
private val theme: Theme
) : WidgetScreen<Args.Empty>() {
private fun createInput() : Widget<*>{
return with(theme) {
input(
size = WidgetSize.WrapContent,
label = const(MR.strings.hello_world.desc() as StringDesc),
field = FormField(initialValue = "", validation = liveBlock { null }),
id = object : InputWidget.Id {}
)
}
}
override fun createContentWidget() = with(theme) {
constraint(size = WidgetSize.AsParent) {
val scroll = +scroll(
size = WidgetSize.Const(SizeSpec.MatchConstraint, SizeSpec.MatchConstraint),
id = object : ScrollWidget.Id {},
child = linear(
size = WidgetSize.Const(SizeSpec.AsParent, SizeSpec.WrapContent)
) {
+createInput()
+createInput()
+createInput()
})
constraints {
scroll.topToTop(root.safeArea)
scroll.leftRightToLeftRight(root.safeArea)
scroll.bottomToBottom(root.safeArea)
}
}
}
}
- run in Android emulator
The input fields are generated dynamically, the id of the returned input field is a new object, but it seems that the moko-widgets lib thinks it’s the same. Or is the code just wrong and it’s not the right way to do it?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
<supportedRuntime> element - NET Framework
Specifies which common language runtime version and, optionally, .NET Framework version the application supports. <configuration>
Read more >Runtime Support | Cloud Functions Documentation
Here is the list of currently supported Cloud Functions runtimes, as well as runtimes that have been deprecated and/or decommissioned. Note: You use...
Read more >chrome.runtime - Chrome Developers
The Runtime API provides methods to support a number of areas of functionality that your extensions can use: Message passing: Your extension can...
Read more >Custom AWS Lambda runtimes
A runtime is responsible for running the function's setup code, reading the handler name from an environment variable, and reading invocation events from...
Read more >Add Servers to Runtime Manager - MuleSoft Documentation
If you must download the agent, you have an Enterprise support account. ... server appears on the Servers tab of Runtime Manager with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i think we can add specific implementation of ID with string id, not class name…i mark issue as enhacement
@Gamadril you can test it now on dev repo - https://bintray.com/beta/#/icerockdev/moko-dev/moko-widgets/bd962b3?tab=overview