Skip to content

Commit af74b67

Browse files
authored
[Reply] Set container colors for MaterialContainerTransforms and get rid of extra FrameLayout wrapper (material-components#42)
1 parent abeb6e4 commit af74b67

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
lines changed

Reply/app/src/main/java/com/materialstudies/reply/ui/compose/ComposeFragment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import com.materialstudies.reply.data.Email
3434
import com.materialstudies.reply.data.EmailStore
3535
import com.materialstudies.reply.databinding.ComposeRecipientChipBinding
3636
import com.materialstudies.reply.databinding.FragmentComposeBinding
37+
import com.materialstudies.reply.util.themeColor
3738
import com.materialstudies.reply.util.themeInterpolator
3839
import kotlin.LazyThreadSafetyMode.NONE
3940

@@ -117,6 +118,9 @@ class ComposeFragment : Fragment() {
117118
duration = resources.getInteger(R.integer.reply_motion_duration_large).toLong()
118119
interpolator = requireContext().themeInterpolator(R.attr.motionInterpolatorPersistent)
119120
scrimColor = Color.TRANSPARENT
121+
containerColor = requireContext().themeColor(R.attr.colorSurface)
122+
startContainerColor = requireContext().themeColor(R.attr.colorSecondary)
123+
endContainerColor = requireContext().themeColor(R.attr.colorSurface)
120124
}
121125
returnTransition = Slide().apply {
122126
duration = resources.getInteger(R.integer.reply_motion_duration_medium).toLong()

Reply/app/src/main/java/com/materialstudies/reply/ui/email/EmailFragment.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.google.android.material.transition.MaterialContainerTransform
2929
import com.materialstudies.reply.R
3030
import com.materialstudies.reply.data.EmailStore
3131
import com.materialstudies.reply.databinding.FragmentEmailBinding
32+
import com.materialstudies.reply.util.themeColor
3233
import com.materialstudies.reply.util.themeInterpolator
3334
import kotlin.LazyThreadSafetyMode.NONE
3435

@@ -94,18 +95,12 @@ class EmailFragment : Fragment() {
9495

9596
sharedElementEnterTransition = MaterialContainerTransform().apply {
9697
// Scope the transition to a view in the hierarchy so we know it will be added under
97-
// the bottom app bar but over the Hold transition from the exiting HomeFragment.
98+
// the bottom app bar but over the elevation scale of the exiting HomeFragment.
9899
drawingViewId = R.id.nav_host_fragment
99100
duration = resources.getInteger(R.integer.reply_motion_duration_large).toLong()
100101
interpolator = requireContext().themeInterpolator(R.attr.motionInterpolatorPersistent)
101102
scrimColor = Color.TRANSPARENT
102-
}
103-
sharedElementReturnTransition = MaterialContainerTransform().apply {
104-
// Again, scope the return transition so it is added below the bottom app bar.
105-
drawingViewId = R.id.home_root
106-
duration = resources.getInteger(R.integer.reply_motion_duration_large).toLong()
107-
interpolator = requireContext().themeInterpolator(R.attr.motionInterpolatorPersistent)
108-
scrimColor = Color.TRANSPARENT
103+
setAllContainerColors(requireContext().themeColor(R.attr.colorSurface))
109104
}
110105
}
111106

Reply/app/src/main/res/layout/fragment_home.xml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,17 @@
1515
xmlns:android="http://schemas.android.com/apk/res/android"
1616
xmlns:app="http://schemas.android.com/apk/res-auto">
1717

18-
<!-- Add a wrapper layout so we can run return transitions independent of any reenter
19-
transitions that may be running on the RecyclerView. -->
20-
<FrameLayout
21-
android:id="@+id/home_root"
18+
<androidx.recyclerview.widget.RecyclerView
19+
android:id="@+id/recycler_view"
2220
android:layout_width="match_parent"
23-
android:layout_height="match_parent">
24-
25-
<androidx.recyclerview.widget.RecyclerView
26-
android:id="@+id/recycler_view"
27-
android:layout_width="match_parent"
28-
android:layout_height="wrap_content"
29-
android:clipToPadding="false"
30-
android:paddingTop="@dimen/grid_0_25"
31-
android:paddingBottom="@dimen/bottom_app_bar_height"
32-
android:transitionGroup="true"
33-
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
34-
app:layout_behavior="@string/appbar_scrolling_view_behavior"
35-
app:paddingTopSystemWindowInsets="@{true}"
36-
app:paddingBottomSystemWindowInsets="@{true}"/>
37-
38-
</FrameLayout>
21+
android:layout_height="wrap_content"
22+
android:clipToPadding="false"
23+
android:paddingTop="@dimen/grid_0_25"
24+
android:paddingBottom="@dimen/bottom_app_bar_height"
25+
android:transitionGroup="true"
26+
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
27+
app:layout_behavior="@string/appbar_scrolling_view_behavior"
28+
app:paddingTopSystemWindowInsets="@{true}"
29+
app:paddingBottomSystemWindowInsets="@{true}"/>
3930

4031
</layout>

0 commit comments

Comments
 (0)