Skip to content
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

This PR enables to add footer component to info reference asset in android #411

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class InfoTest : AssetTest("reference-assets") {
private fun verifyAndProceed(view: Int, action: PlayerAction? = null) {
val infoTitle = currentView?.findViewById<FrameLayout>(R.id.info_title) ?: throw AssertionError("current view is null")
val infoActions = currentView?.findViewById<LinearLayout>(R.id.info_actions) ?: throw AssertionError("current view is null")
val infoFooter =
currentView?.findViewById<FrameLayout>(R.id.info_footer) ?: throw AssertionError("current view is null")

infoTitle[0].shouldBeView<TextView> {
assertEquals("View $view", text.toString())
Expand All @@ -35,6 +37,10 @@ class InfoTest : AssetTest("reference-assets") {
blockUntilRendered()
}
}

infoFooter[0].shouldBeView<TextView> {
assertEquals("Footer Text", text.toString())
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Info(assetContext: AssetContext) : SuspendableAsset<Info.Data>(assetContex
val title: RenderableAsset? = null,
val primaryInfo: RenderableAsset? = null,
val actions: List<RenderableAsset?> = emptyList(),
val footer: RenderableAsset? = null,
)

override suspend fun initView(data: Data) = LayoutInflater.from(context).inflate(R.layout.info, null).rootView
Expand All @@ -27,5 +28,6 @@ class Info(assetContext: AssetContext) : SuspendableAsset<Info.Data>(assetContex
data.actions.filterNotNull().map {
it.render()
} into findViewById(R.id.info_actions)
data.footer?.render() into findViewById(R.id.info_footer)
}
}
10 changes: 10 additions & 0 deletions plugins/reference-assets/android/src/main/res/layout/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/info_primary_info" />

<FrameLayout
android:id="@+id/info_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/info_actions" />

</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 8 additions & 0 deletions plugins/reference-assets/components/src/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ describe("JSON serialization", () => {
<Action.Label>Continue</Action.Label>
</Action>
</Info.Actions>
<Info.Footer>Footer Text</Info.Footer>
</Info>,
)
).jsonValue,
Expand Down Expand Up @@ -158,6 +159,13 @@ describe("JSON serialization", () => {
},
},
],
footer: {
asset: {
id: "info-view-footer",
type: "text",
value: "Footer Text",
},
},
});
});
});
Expand Down
3 changes: 3 additions & 0 deletions plugins/reference-assets/mocks/info/info-modal-flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const view1 = (
<Action.Label>Continue</Action.Label>
</Action>
</Info.Actions>
<Info.Footer>Footer Text</Info.Footer>
</Info>
);

Expand All @@ -24,6 +25,7 @@ const view2 = (
<Action.Label>Dismiss</Action.Label>
</Action>
</Info.Actions>
<Info.Footer>Footer Text</Info.Footer>
</Info>
);

Expand All @@ -35,6 +37,7 @@ const view3 = (
<Action.Label>Next</Action.Label>
</Action>
</Info.Actions>
<Info.Footer>Footer Text</Info.Footer>
</Info>
);

Expand Down