-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for Compose assets and reference assets #537
base: main
Are you sure you want to change the base?
Changes from all commits
aa0e0b3
c50b5c8
0e13402
097b3ce
9bba89b
3c384f0
b7e6b9e
56bf5b5
eaff6b7
9dc9994
1390fad
fce89cf
e4e5544
e0474c5
5bdf6d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ _backup | |
.eslintcache | ||
.next | ||
android-tools | ||
*.iml | ||
|
||
|
||
# Xcode | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,7 @@ It's been tested on Andriod Studio Chipmunk(2021.2.1) and Android Studio Giraffe | |
Assuming you have read the [requirements on the root contributing guide](https://github.com/player-ui/player/blob/main/CONTRIBUTING.md). | ||
|
||
1. Once you have Android Studio installed, you will need to go to tools->SDK Manager->SDK Platforms. | ||
1. Make sure you have **only** the following SDK installed: Android API 32. | ||
*If you are using Android Giraffe, you may need to click on show package details and it will be under Android12L. (Android SDK Platrform 32)* | ||
1. Make sure you have **only** the following SDK installed: Android API 33. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this is needed but I couldnt get it to build with API 32 |
||
2. The next step will be to make sure you have the right (and _only_ the right) SDK Build tools and NDK. Click on the SDK Tools tab and make sure you have only the following clicked: | ||
1. 30.0.3 | ||
2. 21.4.7075529 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.intuit.playerui.android.reference.demo.test.assets.badge | ||
|
||
import androidx.compose.ui.test.onNodeWithText | ||
import com.intuit.playerui.android.reference.demo.test.base.ComposeUITest | ||
import com.intuit.playerui.android.reference.demo.test.base.shouldBePlayerState | ||
import com.intuit.playerui.core.player.state.InProgressState | ||
import org.junit.Test | ||
|
||
class BadgeUITest : ComposeUITest("badge") { | ||
|
||
@Test | ||
fun basic() { | ||
launchMock("badge-all") | ||
|
||
androidComposeRule.onNodeWithText("INFO") | ||
.assertExists() | ||
androidComposeRule.onNodeWithText("ERROR") | ||
.assertExists() | ||
currentState.shouldBePlayerState<InProgressState>() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.intuit.playerui.android.reference.demo.test.base | ||
|
||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import com.intuit.playerui.android.reference.demo.ui.main.MainActivity | ||
import org.junit.Rule | ||
|
||
abstract class ComposeUITest(group: String? = null) : AssetUITest(group) { | ||
@get:Rule | ||
val androidComposeRule = createAndroidComposeRule<MainActivity>() | ||
|
||
override fun getActivityRule(): ActivityScenarioRule<MainActivity> { | ||
return androidComposeRule.activityRule | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"id": "collection-badge", | ||
"type": "collection", | ||
"label": { | ||
"asset": { | ||
"id": "collection-label", | ||
"type": "text", | ||
"value": "Badge variants" | ||
} | ||
}, | ||
"values": [ | ||
{ | ||
"asset": { | ||
"id": "item-1", | ||
"type": "badge", | ||
"label": "INFO", | ||
"status": "info" | ||
} | ||
}, | ||
{ | ||
"asset": { | ||
"id": "item-2", | ||
"type": "badge", | ||
"label": "ERROR", | ||
"status": "error" | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,7 +186,7 @@ public constructor(public val assetContext: AssetContext) : NodeWrapper { | |
.render() | ||
|
||
/** Render a [View] with specific [styles] */ | ||
public fun RenderableAsset.render(@StyleRes styles: Styles): View = assetContext | ||
public fun RenderableAsset.render(@StyleRes styles: Styles?): View = assetContext | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated these to avoid have to call multiple render implementations here Any concerns? |
||
.withContext([email protected]()) | ||
.withStyles(styles) | ||
.build() | ||
|
@@ -208,7 +208,7 @@ public constructor(public val assetContext: AssetContext) : NodeWrapper { | |
.render() | ||
|
||
/** Render a [View] with specific [styles] */ | ||
public fun RenderableAsset.render(@StyleRes styles: Styles, tag: String): View = assetContext | ||
public fun RenderableAsset.render(@StyleRes styles: Styles?, tag: String): View = assetContext | ||
.withContext([email protected]()) | ||
.withTag(tag) | ||
.withStyles(styles) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.intuit.playerui.android.compose | ||
|
||
import androidx.compose.ui.text.TextStyle | ||
import com.intuit.playerui.android.extensions.Style | ||
|
||
interface AssetStyle { | ||
val textStyle: TextStyle? | ||
val xmlStyles: List<Style>? | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason in particular we have to downgrade rules versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mainly due to point 5 in the PR description. This was the highest version I could stay at with the least amount of changes. I will give another combination of dependencies a shot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to upgrade to a few different versions till v1.8.20 but all such changes open a can of worms that require several other dependencies to be updated