Skip to content

Commit

Permalink
bazel-6-android-base-Add-footer-to-info-reference-asset (#411)
Browse files Browse the repository at this point in the history
Rebased onto main branch
  • Loading branch information
sakuntala-motukuri authored Jul 15, 2024
1 parent aafb87a commit ab58074
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
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

0 comments on commit ab58074

Please sign in to comment.