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

View File

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