-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
native, js, wasm platforms support (#73)
* native, js, wasm support * 2.5.0-alpha06
- Loading branch information
1 parent
7ce968d
commit 35d059f
Showing
14 changed files
with
392 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../androidMain/kotlin/com/atiurin/ultron/core/compose/list/UltronComposeListItem.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.atiurin.ultron.core.compose.list | ||
|
||
import androidx.compose.ui.test.SemanticsMatcher | ||
import com.atiurin.ultron.exceptions.UltronException | ||
|
||
actual inline fun <reified T : UltronComposeListItem> getComposeListItemInstance( | ||
ultronComposeList: UltronComposeList, | ||
itemMatcher: SemanticsMatcher | ||
): T { | ||
val item = createUltronComposeListItemInstance<T>() | ||
item.setExecutor(ultronComposeList, itemMatcher) | ||
return item | ||
} | ||
|
||
actual inline fun <reified T : UltronComposeListItem> getComposeListItemInstance( | ||
ultronComposeList: UltronComposeList, | ||
position: Int, | ||
isPositionPropertyConfigured: Boolean | ||
): T { | ||
val item = createUltronComposeListItemInstance<T>() | ||
item.setExecutor(ultronComposeList, position, isPositionPropertyConfigured) | ||
return item | ||
} | ||
|
||
inline fun <reified T : UltronComposeListItem> createUltronComposeListItemInstance(): T { | ||
return try { | ||
T::class.java.newInstance() | ||
} catch (ex: Exception) { | ||
val desc = when { | ||
T::class.isInner -> { | ||
"${T::class.simpleName} is an inner class so you have to delete inner modifier (It is often when kotlin throws 'has no zero argument constructor' but real reason is an inner modifier)" | ||
} | ||
|
||
T::class.constructors.find { it.parameters.isEmpty() } == null -> { | ||
"${T::class.simpleName} doesn't have a constructor without params (create an empty constructor)" | ||
} | ||
|
||
else -> ex.message | ||
} | ||
throw UltronException( | ||
""" | ||
|Couldn't create an instance of ${T::class.simpleName}. | ||
|Possible reason: $desc | ||
|Original exception: ${ex.message}, cause ${ex.cause} | ||
""".trimMargin() | ||
) | ||
} | ||
} |
Oops, something went wrong.