Archived
Adjusted UI elements in CanteenFragment.kt to clean up the UI
This commit is contained in:
@@ -69,6 +69,19 @@ class CanteenFragment : AppFragment() {
|
|||||||
// Set the title to be selected so it scrolls (marquee)
|
// Set the title to be selected so it scrolls (marquee)
|
||||||
binding.appTitleBar.isSelected = true
|
binding.appTitleBar.isSelected = true
|
||||||
|
|
||||||
|
// Set up button for viewing the opening hours
|
||||||
|
binding.buttonOpeningHours.setOnClickListener {
|
||||||
|
openBottomSheet(
|
||||||
|
getTextSheet(
|
||||||
|
getString(
|
||||||
|
R.string.canteen_opening_hours,
|
||||||
|
getCurrentlySelectedCanteenName()
|
||||||
|
),
|
||||||
|
contentId = TextSheetContentId.OPENING_HOURS,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Set up observer for the selected canteen
|
// Set up observer for the selected canteen
|
||||||
viewModel.getCanteen().observe(viewLifecycleOwner) { canteen ->
|
viewModel.getCanteen().observe(viewLifecycleOwner) { canteen ->
|
||||||
if (canteen == null || canteen.news.isBlank()) {
|
if (canteen == null || canteen.news.isBlank()) {
|
||||||
@@ -140,19 +153,6 @@ class CanteenFragment : AppFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up floating action button for viewing the opening hours
|
|
||||||
binding.fabOpeningHours.setOnClickListener {
|
|
||||||
openBottomSheet(
|
|
||||||
getTextSheet(
|
|
||||||
getString(
|
|
||||||
R.string.canteen_opening_hours,
|
|
||||||
getCurrentlySelectedCanteenName()
|
|
||||||
),
|
|
||||||
contentId = TextSheetContentId.OPENING_HOURS,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up floating action button for switching the canteen
|
// Set up floating action button for switching the canteen
|
||||||
binding.fabSwitchCanteen.setOnClickListener {
|
binding.fabSwitchCanteen.setOnClickListener {
|
||||||
PopupMenu(binding.root.context, binding.fabSwitchCanteen).apply {
|
PopupMenu(binding.root.context, binding.fabSwitchCanteen).apply {
|
||||||
@@ -188,15 +188,6 @@ class CanteenFragment : AppFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up floating action button for refreshing the canteen offers
|
|
||||||
binding.fabRefreshOffers.setOnClickListener {
|
|
||||||
// Display to the user that a refresh is in progress
|
|
||||||
binding.swipeRefreshLayout.isRefreshing = true
|
|
||||||
|
|
||||||
// Refresh the offers
|
|
||||||
refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up the view pager's adapter
|
// Set up the view pager's adapter
|
||||||
viewPagerAdapter = CanteenOfferPageAdapter(
|
viewPagerAdapter = CanteenOfferPageAdapter(
|
||||||
childFragmentManager,
|
childFragmentManager,
|
||||||
@@ -229,7 +220,7 @@ class CanteenFragment : AppFragment() {
|
|||||||
positionOffsetPixels: Int
|
positionOffsetPixels: Int
|
||||||
) {
|
) {
|
||||||
super.onPageScrolled(position, positionOffset, positionOffsetPixels)
|
super.onPageScrolled(position, positionOffset, positionOffsetPixels)
|
||||||
binding.fabRefreshOffers.extend()
|
binding.fabSwitchCanteen.extend()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -261,14 +252,14 @@ class CanteenFragment : AppFragment() {
|
|||||||
* Shrinks the FAB.
|
* Shrinks the FAB.
|
||||||
*/
|
*/
|
||||||
fun shrinkFab() {
|
fun shrinkFab() {
|
||||||
binding.fabRefreshOffers.shrink()
|
binding.fabSwitchCanteen.shrink()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends the FAB.
|
* Extends the FAB.
|
||||||
*/
|
*/
|
||||||
fun extendFab() {
|
fun extendFab() {
|
||||||
binding.fabRefreshOffers.extend()
|
binding.fabSwitchCanteen.extend()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
|
|
||||||
android:id="@+id/snackbar_container"
|
android:id="@+id/snackbar_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@@ -41,7 +40,21 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/button_notifications"/>
|
app:layout_constraintEnd_toStartOf="@id/button_opening_hours"/>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
style="@style/Widget.Material3.Button.IconButton.Outlined"
|
||||||
|
android:id="@+id/button_opening_hours"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minWidth="0dp"
|
||||||
|
app:icon="@drawable/clock"
|
||||||
|
app:iconPadding="0dp"
|
||||||
|
app:strokeColor="?attr/colorOutlineVariant"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/app_title_bar"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/app_title_bar"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/button_notifications"
|
||||||
|
app:iconTint="?attr/colorOnSurfaceVariant"/>
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
style="@style/Widget.Material3.Button.IconButton.Outlined"
|
style="@style/Widget.Material3.Button.IconButton.Outlined"
|
||||||
@@ -244,47 +257,14 @@
|
|||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
|
android:id="@+id/fab_switch_canteen"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
app:icon="@drawable/switch_arrows"
|
||||||
|
android:text="@string/canteen_fab_switch_canteen"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
app:layout_dodgeInsetEdges="bottom">
|
android:layout_marginHorizontal="@dimen/fab_margin"
|
||||||
|
android:layout_marginBottom="@dimen/fab_margin"/>
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
style="?attr/floatingActionButtonSmallStyle"
|
|
||||||
android:id="@+id/fab_opening_hours"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:srcCompat="@drawable/clock"
|
|
||||||
android:contentDescription="@string/canteen_fab_opening_hours_content_desc"
|
|
||||||
android:tooltipText="@string/canteen_fab_opening_hours_content_desc"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
tools:ignore="UnusedAttribute"/>
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
style="?attr/floatingActionButtonSmallStyle"
|
|
||||||
android:id="@+id/fab_switch_canteen"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:srcCompat="@drawable/switch_arrows"
|
|
||||||
android:contentDescription="@string/canteen_fab_switch_canteen_content_desc"
|
|
||||||
android:tooltipText="@string/canteen_fab_switch_canteen_content_desc"
|
|
||||||
android:layout_marginBottom="4dp"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
tools:ignore="UnusedAttribute"/>
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
|
||||||
android:id="@+id/fab_refresh_offers"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:icon="@drawable/refresh"
|
|
||||||
android:text="@string/canteen_fab_refresh_text"
|
|
||||||
android:layout_marginHorizontal="@dimen/fab_margin"
|
|
||||||
android:layout_marginBottom="@dimen/fab_margin"/>
|
|
||||||
|
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:paddingBottom="72dp"
|
android:paddingBottom="84dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:scrollbarStyle="outsideOverlay"
|
android:scrollbarStyle="outsideOverlay"
|
||||||
android:layoutAnimation="@anim/layout_animation_fall_down"/>
|
android:layoutAnimation="@anim/layout_animation_fall_down"/>
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
<string name="canteen_no_offer_desc">Für diesen Tag sind keine Angebote vorhanden</string>
|
<string name="canteen_no_offer_desc">Für diesen Tag sind keine Angebote vorhanden</string>
|
||||||
<string name="canteen_news_sheet_title">Neuigkeiten für diese Mensa</string>
|
<string name="canteen_news_sheet_title">Neuigkeiten für diese Mensa</string>
|
||||||
<string name="canteen_fab_opening_hours_content_desc">Zeige Öffnungszeiten</string>
|
<string name="canteen_fab_opening_hours_content_desc">Zeige Öffnungszeiten</string>
|
||||||
<string name="canteen_fab_switch_canteen_content_desc">Wechsle Mensa</string>
|
<string name="canteen_fab_switch_canteen">Wechsle Mensa</string>
|
||||||
<string name="canteen_fab_refresh_content_desc">Aktualisiere Angebote</string>
|
<string name="canteen_fab_refresh_content_desc">Aktualisiere Angebote</string>
|
||||||
<string name="canteen_fab_refresh_text">Aktualisieren</string>
|
<string name="canteen_fab_refresh_text">Aktualisieren</string>
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
<string name="canteen_no_offer_desc">There are no offers available for this day</string>
|
<string name="canteen_no_offer_desc">There are no offers available for this day</string>
|
||||||
<string name="canteen_news_sheet_title">News for this canteen</string>
|
<string name="canteen_news_sheet_title">News for this canteen</string>
|
||||||
<string name="canteen_fab_opening_hours_content_desc">Show opening hours</string>
|
<string name="canteen_fab_opening_hours_content_desc">Show opening hours</string>
|
||||||
<string name="canteen_fab_switch_canteen_content_desc">Switch canteen</string>
|
<string name="canteen_fab_switch_canteen">Switch canteen</string>
|
||||||
<string name="canteen_fab_refresh_content_desc">Refresh offers</string>
|
<string name="canteen_fab_refresh_content_desc">Refresh offers</string>
|
||||||
<string name="canteen_fab_refresh_text">Refresh</string>
|
<string name="canteen_fab_refresh_text">Refresh</string>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user