<commit_before>import 'package:campus_mobile_experimental/ui/theme/app_layout.dart';
import 'package:campus_mobile_experimental/ui/theme/app_theme.dart';
import 'package:flutter/material.dart';

class CardContainer extends StatelessWidget {
  const CardContainer({
    Key key,
    @required this.titleText,
    @required this.isLoading,
    @required this.reload,
    @required this.errorText,
    @required this.child,
    @required this.active,
    @required this.hide,
    this.overFlowMenu,
    this.actionButtons,
    this.hideMenu,
  }) : super(key: key);

  /// required parameters
  final String titleText;
  final bool isLoading;
  final bool active;
  final Function hide;
  final Function reload;
  final Widget Function() child;
  final String errorText;

  /// optional parameters
  final Map<String, Function> overFlowMenu;
  final bool hideMenu;
  final List<Widget> actionButtons;

  @override
  Widget build(BuildContext context) {
    if (active) {
      return Card(
        margin: EdgeInsets.only(top: 0.0, right: 0.0, bottom: cardMargin * 1.5, left: 0.0),
        semanticContainer: false,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            ListTile(
              title: Text(
                titleText,
                style: TextStyle(
                  color: Colors.grey,
                  fontSize: 20.0,
                ),
              ),
              trailing: ButtonBar(
                mainAxisSize: MainAxisSize.min,
                children: [
                  buildMenu(),
                ],
              ),
            ),
            buildBody(context),
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 0),
              child: actionButtons != null
                  ? Row(
                      children: actionButtons,
                    )
                  : Container(),
            ),
          ],
        ),
      );
    }
    return Container();
  }

  Widget buildBody(context) {
    if (errorText != null) {
      if (titleText == 'News') {
        return Text('No articles found.');
      } else if (titleText == 'Events') {
        return Text('No events found.');
      } else if (titleText == 'Finals') {
        return Text('No finals found.');
      } else if (titleText == 'Classes') {
        return Text('No classes found.');
      } else {
        return Text('An error occurred, please try again.');
      }
    } else if (isLoading) {<commit_msg>Resolve card_container issues Fix error alignment on cards without action buttons Fix ref error text on Schedule card title<commit_after>import 'package:campus_mobile_experimental/ui/theme/app_layout.dart';
import 'package:campus_mobile_experimental/ui/theme/app_theme.dart';
import 'package:flutter/material.dart';

class CardContainer extends StatelessWidget {
  const CardContainer({
    Key key,
    @required this.titleText,
    @required this.isLoading,
    @required this.reload,
    @required this.errorText,
    @required this.child,
    @required this.active,
    @required this.hide,
    this.overFlowMenu,
    this.actionButtons,
    this.hideMenu,
  }) : super(key: key);

  /// required parameters
  final String titleText;
  final bool isLoading;
  final bool active;
  final Function hide;
  final Function reload;
  final Widget Function() child;
  final String errorText;

  /// optional parameters
  final Map<String, Function> overFlowMenu;
  final bool hideMenu;
  final List<Widget> actionButtons;

  @override
  Widget build(BuildContext context) {
    if (active) {
      return Card(
        margin: EdgeInsets.only(top: 0.0, right: 0.0, bottom: cardMargin * 1.5, left: 0.0),
        semanticContainer: false,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            ListTile(
              title: Text(
                titleText,
                style: TextStyle(
                  color: Colors.grey,
                  fontSize: 20.0,
                ),
              ),
              trailing: ButtonBar(
                mainAxisSize: MainAxisSize.min,
                children: [
                  buildMenu(),
                ],
              ),
            ),
            buildBody(context),
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 0),
              child: actionButtons != null
                  ? Row(
                      children: actionButtons,
                    )
                  : Container(),
            ),
          ],
        ),
      );
    }
    return Container();
  }

  Widget buildBody(context) {
    if (errorText != null) {
      if (titleText == 'News') {
        return Text('No articles found.');
      } else if (titleText == 'Events') {
        return Text('No events found.');
      } else if (titleText == 'Finals') {
        // TODO: Resolve alignment issues on cards without action buttons
        return Padding(
          padding: const EdgeInsets.only(bottom: 42.0),
          child: Text('No finals found.'),
        );
      } else if (titleText == 'Schedule') {
        return Text('No classes found.');
      } else {
        return Text('An error occurred, please try again.');
      }
    } else if (isLoading) {
{'fraction_non_alphanumeric': 0.1028636021100226, 'fraction_numerical': 0.005086661642803316, 'mean_word_length': 1.8821932681867535, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7381004', 'n_tokens_mistral': 1449, 'n_tokens_neox': 1406, 'n_words': 379}