Archived
Added a floating action button to add tasks in TaskOverviewFragment.kt
This commit is contained in:
@@ -32,5 +32,18 @@ class TaskOverviewFragment : AppFragment<FragmentTaskOverviewBinding>() {
|
|||||||
binding.coordinatorLayout,
|
binding.coordinatorLayout,
|
||||||
getString(R.string.task_overview_snack_unimplemented),
|
getString(R.string.task_overview_snack_unimplemented),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Set up scroll change listener to shrink and extend FAB accordingly
|
||||||
|
binding.recyclerViewLayout.recyclerView.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
|
||||||
|
// Calculate the vertical scroll difference
|
||||||
|
val dy = scrollY - oldScrollY
|
||||||
|
if (dy > 0) {
|
||||||
|
// If scrolling down, shrink the FAB
|
||||||
|
binding.fabAddTask.shrink()
|
||||||
|
} else if (dy < 0) {
|
||||||
|
// If scrolling up, extend the FAB
|
||||||
|
binding.fabAddTask.extend()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,4 +28,19 @@
|
|||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/recycler_view"
|
||||||
|
android:id="@+id/recycler_view_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
|
android:id="@+id/fab_add_task"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:icon="@drawable/plus"
|
||||||
|
android:text="@string/task_overview_fab_add_task"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginEnd="@dimen/fab_margin"
|
||||||
|
android:layout_marginBottom="@dimen/fab_margin"/>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -75,6 +75,7 @@
|
|||||||
<string name="sheet_schedule_update_time_dialog_end_hint">Schlusszeit der Veranstaltung</string>
|
<string name="sheet_schedule_update_time_dialog_end_hint">Schlusszeit der Veranstaltung</string>
|
||||||
|
|
||||||
<string name="task_overview_snack_unimplemented">Aufgaben sind noch nicht implementiert!</string>
|
<string name="task_overview_snack_unimplemented">Aufgaben sind noch nicht implementiert!</string>
|
||||||
|
<string name="task_overview_fab_add_task">Aufgabe hinzufügen</string>
|
||||||
|
|
||||||
<string name="canteen_button_opening_hours_hint">Siehe Öffnungszeiten der Mensa</string>
|
<string name="canteen_button_opening_hours_hint">Siehe Öffnungszeiten der Mensa</string>
|
||||||
<string name="canteen_button_notifications_hint">Siehe Neuigkeiten der Mensa</string>
|
<string name="canteen_button_notifications_hint">Siehe Neuigkeiten der Mensa</string>
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
<string name="sheet_schedule_update_time_dialog_end_hint">Event end time</string>
|
<string name="sheet_schedule_update_time_dialog_end_hint">Event end time</string>
|
||||||
|
|
||||||
<string name="task_overview_snack_unimplemented">Tasks are not yet implemented!</string>
|
<string name="task_overview_snack_unimplemented">Tasks are not yet implemented!</string>
|
||||||
|
<string name="task_overview_fab_add_task">Add task</string>
|
||||||
|
|
||||||
<string name="canteen_button_opening_hours_hint">View canteen opening hours</string>
|
<string name="canteen_button_opening_hours_hint">View canteen opening hours</string>
|
||||||
<string name="canteen_button_notifications_hint">View canteen notifications</string>
|
<string name="canteen_button_notifications_hint">View canteen notifications</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user