import 'package:flutter/material.dart';
import 'package:sendtrain/database/database.dart';
import 'package:sendtrain/widgets/media/media_details.dart';

showMediaDetailWidget(BuildContext context, MediaItem media) {
  showEditorSheet(context, MediaDetails(media: media));
}

showGenericSheet(BuildContext context, Widget widget,
    [Color? backgroundColor]) {
  backgroundColor ??= Theme.of(context).colorScheme.surfaceBright;

  showModalBottomSheet<void>(
      backgroundColor: backgroundColor,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.only(
            topLeft: Radius.circular(10.0), topRight: Radius.circular(10.0)),
      ),
      context: context,
      showDragHandle: true,
      isScrollControlled: true,
      useSafeArea: true,
      builder: (BuildContext context) {
        return widget;
      });
}

showEditorSheet(BuildContext context, Widget widget) {
  showGenericSheet(context, widget);
}

String jsonToDescription(List text) {
  String content = '';

  for (int i = 0; i < text.length; i++) {
    if (content.isEmpty) {
      content = text[i];
    } else {
      content = "$content\n\n${text[i]}";
    }
  }

  return content;
}
