improve LessonDetailsDialog

This commit is contained in:
Franek 2024-06-15 12:18:05 +02:00
parent 8fa2ca5bd5
commit 2a93cd5ebd
No known key found for this signature in database
GPG Key ID: 0329F871B2079351
2 changed files with 35 additions and 14 deletions

View File

@ -49,8 +49,6 @@ class LessonDetailsDialog(
DialogLessonDetailsBinding.inflate(layoutInflater)
override fun getPositiveButtonText() = R.string.close
override fun getNegativeButtonText() = R.string.notes_button
override fun getNeutralButtonText() = R.string.add
private lateinit var adapter: EventListAdapter
private val manager
@ -58,7 +56,7 @@ class LessonDetailsDialog(
private val attendanceManager
get() = app.attendanceManager
override suspend fun onNeutralClick(): Boolean {
fun openAddEventDialog(): Boolean {
EventManualDialog(
activity,
lesson.profileId,
@ -68,6 +66,7 @@ class LessonDetailsDialog(
).show()
return NO_DISMISS
}
override suspend fun onShow() {
if (App.devMode)
b.lessonId.visibility = View.VISIBLE
@ -227,6 +226,8 @@ class LessonDetailsDialog(
addItemDecoration(SimpleDividerItemDecoration(context))
}
}
@Suppress("NotifyDataSetChanged")
adapter.notifyDataSetChanged()
if (events != null && events.isNotEmpty()) {
@ -240,7 +241,6 @@ class LessonDetailsDialog(
lesson.displayTeacherName?.let { name ->
lesson.displayTeacherId ?: return@let
/*
BetterLink.attach(
b.teacherNameView,
teachers = mapOf(lesson.displayTeacherId!! to name),
@ -251,9 +251,9 @@ class LessonDetailsDialog(
teachers = mapOf(lesson.displayTeacherId!! to name),
onActionSelected = dialog::dismiss
)
*/
}
/*
b.addEventButton.onClick { openAddEventDialog() }
b.notesButton.isVisible = showNotes
b.notesButton.setupNotesButton(
activity = activity,
@ -261,9 +261,9 @@ class LessonDetailsDialog(
onShowListener = onShowListener,
onDismissListener = onDismissListener,
)
b.legend.isVisible = showNotes
if (showNotes)
NoteManager.setLegendText(lesson, b.legend)
*/
}
}

View File

@ -398,14 +398,35 @@
tools:visibility="visible"
tools:listitem="@layout/event_list_item" />
<com.google.android.material.button.MaterialButton
android:id="@+id/notesButton"
style="@style/Widget.Material3.Button.TextButton.Icon"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/notes_button"
android:visibility="gone"/>
android:layout_marginHorizontal="8dp"
android:layout_marginTop="8dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/addEventButton"
style="@style/Widget.Material3.Button.OutlinedButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="8dp"
android:text="@string/add"
app:icon="@drawable/ic_action_add"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/notesButton"
style="@style/Widget.Material3.Button.OutlinedButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="8dp"
android:text="@string/notes_button"
app:icon="@drawable/ic_note_legacy"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</layout>