Skip to content

Commit

Permalink
Clean up reading app bar (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
TinasheMzondiwa authored Feb 2, 2023
1 parent 486bf76 commit 57d9aa0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 124 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class SSReadingActivity : SlidingActivity(), SSReadingViewModel.DataListener, Sh
private val viewModel by viewModels<ReadingsViewModel>()
private val playbackViewModel by viewModels<PlaybackViewModel>()

private var appbarChangeListener: AppbarOffsetChangeListener? = null

private var currentReadPosition: Int? = null

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -236,6 +234,7 @@ class SSReadingActivity : SlidingActivity(), SSReadingViewModel.DataListener, Sh
binding.ssReadingAppBar.apply {
ssReadingCollapsingToolbar.title = title
ssCollapsingToolbarSubtitle.text = subTitle
ssCollapsingToolbarBackdrop.contentDescription = title
}
}

Expand All @@ -250,12 +249,6 @@ class SSReadingActivity : SlidingActivity(), SSReadingViewModel.DataListener, Sh
override fun onChanged() {
super.onChanged()
binding.ssReadingViewPager.currentItem = index
ssReads.getOrNull(index)?.let { read ->
setPageTitleAndSubtitle(
read.title,
DateHelper.formatDate(read.date, SSConstants.SS_DATE_FORMAT_OUTPUT_DAY)
)
}
}
}
with(readingViewAdapter) {
Expand All @@ -277,7 +270,6 @@ class SSReadingActivity : SlidingActivity(), SSReadingViewModel.DataListener, Sh
private fun observeData() {
ssPrefs.displayOptionsFlow().collectIn(this) { displayOptions ->
readingViewAdapter.readingOptions = displayOptions
appbarChangeListener?.readingOptions = displayOptions
ssReadingViewModel.onSSReadingDisplayOptions(displayOptions)
window.navigationBarColor = displayOptions.colorTheme(this@SSReadingActivity.isDarkTheme())
}
Expand Down
53 changes: 25 additions & 28 deletions features/lessons/src/main/res/layout/ss_reading_app_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
-->

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

Expand All @@ -33,27 +34,28 @@
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/ss_reading_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/ss_reading_toolbar_height"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay"
android:visibility="@{viewModel.ssLessonCoordinatorVisibility}"
app:expanded="true">

<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/ss_reading_collapsing_toolbar"
style="?attr/collapsingToolbarLayoutLargeStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:layout_height="@dimen/ss_reading_toolbar_height"
app:collapsedTitleTextAppearance="@style/AppThemeAppBarTextStyle"
app:contentScrim="@{viewModel.primaryColor}"
app:expandedTitleGravity="start|bottom"
app:expandedTitleMarginBottom="@dimen/ss_reading_toolbar_title_margin_bottom"
app:expandedTitleMarginEnd="0dp"
app:expandedTitleMarginStart="@dimen/ss_reading_toolbar_title_margin_left"
app:expandedTitleTextAppearance="@style/AppThemeAppBarTextStyleExpanded"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed|enterAlways"
app:maxLines="2"
app:statusBarScrim="@{viewModel.secondaryColor}"
app:toolbarId="@+id/ss_reading_toolbar">
app:toolbarId="@+id/ss_reading_toolbar"
tools:title="How to Get Out of Debt">

<ImageView
android:id="@+id/ss_collapsing_toolbar_backdrop"
Expand All @@ -62,36 +64,31 @@
android:contentDescription="@string/blank"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
app:layout_collapseMode="parallax"
tools:src="?attr/colorAccent" />

<RelativeLayout
<TextView
android:id="@+id/ss_collapsing_toolbar_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/ss_reading_toolbar_date_margin_top"
android:fitsSystemWindows="true"
android:layout_alignParentTop="true"
android:layout_gravity="bottom"
android:layout_marginHorizontal="@dimen/ss_reading_toolbar_title_margin_left"
android:layout_marginBottom="@dimen/spacing_medium"
android:fontFamily="@font/lato_bold"
android:maxLines="1"
android:textAllCaps="true"
android:textColor="@color/ss_color_secondary_lighter"
android:textSize="@dimen/ss_reading_app_bar_subtitle_size"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.4">

<TextView
android:id="@+id/ss_collapsing_toolbar_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="@dimen/ss_reading_toolbar_title_margin_left"
android:layout_marginTop="@dimen/spacing_medium_large"
android:fitsSystemWindows="true"
android:fontFamily="@font/lato_bold"
android:maxLines="1"
android:textAllCaps="true"
android:textColor="@color/ss_color_secondary_lighter"
android:textSize="@dimen/ss_reading_app_bar_subtitle_size" />

</RelativeLayout>
app:layout_collapseParallaxMultiplier="0.4"
tools:text="Tuesday, January 31" />

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/ss_reading_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
Expand Down
1 change: 0 additions & 1 deletion features/lessons/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<dimen name="ss_reading_toolbar_height">340dp</dimen>
<dimen name="ss_reading_toolbar_title_margin_bottom">50dp</dimen>
<dimen name="ss_reading_toolbar_title_margin_left">20dp</dimen>
<dimen name="ss_reading_toolbar_date_margin_top">280dp</dimen>

<dimen name="ss_reading_context_controls_padding">10dp</dimen>
<dimen name="ss_reading_context_highlight_button_padding">13dp</dimen>
Expand Down
6 changes: 5 additions & 1 deletion features/lessons/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
</style>

<style name="AppThemeAppBarTextStyleExpanded" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">30sp</item>
<item name="android:textSize">26sp</item>
<item name="fontFamily">@font/lato_bold</item>
<item name="android:fontFamily">@font/lato_bold</item>
<item name="android:shadowColor">#7F000000</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">2</item>
</style>

<style name="display_options_text_view">
Expand Down

0 comments on commit 57d9aa0

Please sign in to comment.