build_expandable_content function

dynamic build_expandable_content(
  1. Course course,
  2. BuildContext context,
  3. Function get_courses_and_units,
  4. Color language_picker_items_text_color,
  5. bool language_picker,
  6. Color topbar_color,
  7. Color text_color,
)

Implementation

build_expandable_content(
  Course course,
  BuildContext context,
  Function get_courses_and_units,
  Color language_picker_items_text_color,
  bool language_picker,
  Color topbar_color,
  Color text_color,
) {
  List<Widget> column_content = [];

  for (String content in course.contents) {
    int content_index = course.contents.indexOf(content);
    column_content.add(
      GestureDetector(
        onTap: () async {
          String unit_id = course.unit_ids[content_index];

          if (content_index == 0) {
            open_class_session(
              course_id: course.id,
              course_name: course.title,
              unit_id: unit_id,
              language_picker_items_text_color:
                  language_picker_items_text_color,
              language_picker: language_picker,
              topbar_color: topbar_color,
              text_color: text_color,
            );
          } else {
            if (course.units_completed_status[content_index - 1]) {
              open_class_session(
                course_id: course.id,
                course_name: course.title,
                unit_id: unit_id,
                language_picker_items_text_color:
                    language_picker_items_text_color,
                language_picker: language_picker,
                topbar_color: topbar_color,
                text_color: text_color,
              );
            }
          }
        },
        child: ListTile(
          title: Text(
            content,
            style: TextStyle(fontSize: 18.0),
          ),
          leading: Icon(
            course.icon,
            color: course.units_completed_status[content_index]
                ? Colors.lightGreen
                : Colors.transparent,
          ),
        ),
      ),
    );
  }

  return column_content;
}