add a complete version of the addLesson Dialog
This commit is contained in:
@ -26,10 +26,16 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import android.widget.ScrollView
|
||||
import android.widget.Spinner
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.bottomsheets.setPeekHeight
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import com.afollestad.materialdialogs.customview.getCustomView
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import kotlinx.android.synthetic.main.fragment_timetable.*
|
||||
import kotlinx.coroutines.*
|
||||
@ -82,10 +88,7 @@ class TimeTableFragment : Fragment() {
|
||||
}
|
||||
|
||||
faBtnAddLesson.setOnClickListener {
|
||||
MaterialDialog(context!!, BottomSheet())
|
||||
.title(text = resources.getString(R.string.add_lesson))
|
||||
.message(text = "wähle einen Studiengang aus:\n\nWähle eine Vorlesung aus: \n\nDiese Funktion ist noch nicht verfügbar")
|
||||
.show()
|
||||
initAddLessonDialog().show()
|
||||
}
|
||||
|
||||
// hide the btnCardValue if the user is scrolling down
|
||||
@ -160,4 +163,43 @@ class TimeTableFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO move to separate class
|
||||
private fun initAddLessonDialog(): MaterialDialog {
|
||||
val dialog = MaterialDialog(context!!, BottomSheet())
|
||||
.title(R.string.add_lesson)
|
||||
.message(R.string.add_lesson_desc)
|
||||
.customView(R.layout.dialog_add_lesson)
|
||||
.setPeekHeight(900)
|
||||
.positiveButton(R.string.add) {
|
||||
println("add course")
|
||||
}
|
||||
.negativeButton(R.string.cancel) { }
|
||||
|
||||
val spinnerCourses: Spinner = dialog.getCustomView().findViewById(R.id.spinner_Courses)
|
||||
val spinnerLessons: Spinner = dialog.getCustomView().findViewById(R.id.spinner_Lessons)
|
||||
|
||||
spinnerCourses.onItemSelectedListener = object : OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>, view: View, pos: Int, id: Long) {
|
||||
println(parent.getItemAtPosition(pos))
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>) {
|
||||
// Another interface callback
|
||||
}
|
||||
}
|
||||
|
||||
spinnerLessons.onItemSelectedListener = object : OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>, view: View, pos: Int, id: Long) {
|
||||
println(parent.getItemAtPosition(pos))
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>) {
|
||||
// Another interface callback
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user