<commit_before>//import 'dart:io';
// import 'dart:js';

import 'package:barcode_widget/barcode_widget.dart';
import 'package:campus_mobile_experimental/core/constants/app_constants.dart';
import 'package:campus_mobile_experimental/core/data_providers/cards_data_provider.dart';
import 'package:campus_mobile_experimental/core/data_providers/student_id_data_provider.dart';
import 'package:campus_mobile_experimental/core/models/student_id_barcode_model.dart';
import 'package:campus_mobile_experimental/core/models/student_id_name_model.dart';
import 'package:campus_mobile_experimental/core/models/student_id_photo_model.dart';
import 'package:campus_mobile_experimental/core/models/student_id_profile_model.dart';
import 'package:campus_mobile_experimental/ui/reusable_widgets/card_container.dart';
import 'package:campus_mobile_experimental/ui/theme/app_layout.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:provider/provider.dart';

class StudentIdCard extends StatelessWidget {
  String cardId = "student_id";
  var barcodeImage;

  createAlertDialog(BuildContext context, Column image) {
    return showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
            title: Text("Student ID"),
            content: Container(
              child: image,
            ),
            actions: <Widget>[
              FlatButton(
                  child: Text("X"),
                  onPressed: () {
                    Navigator.of(context).pop();
                  })
            ],
          );
        });
  }

  @override
  Widget build(BuildContext context) {
    SizeConfig().init(context);

    return CardContainer(
      /// TODO: need to hook up hidden to state using provider
      active: Provider.of<CardsDataProvider>(context).cardStates[cardId],
      hide: () => Provider.of<CardsDataProvider>(context, listen: false)
          .toggleCard(cardId),
      reload: () => Provider.of<StudentIdDataProvider>(context, listen: false)
          .fetchData(),
      isLoading: Provider.of<StudentIdDataProvider>(context).isLoading,
      titleText: CardTitleConstants.titleMap[cardId],
      errorText: Provider.of<StudentIdDataProvider>(context).error,
      child: () => buildCardContent(
          Provider.of<StudentIdDataProvider>(context).studentIdBarcodeModel,
          Provider.of<StudentIdDataProvider>(context).studentIdNameModel,
          Provider.of<StudentIdDataProvider>(context).studentIdPhotoModel,
          Provider.of<StudentIdDataProvider>(context).studentIdProfileModel,
          context),
    );
  }

  Widget buildTitle() {
    return Text(
      "Student ID",
      textAlign: TextAlign.left,
    );
  }

  Widget buildCardContent(
      StudentIdBarcodeModel barcodeModel,
      StudentIdNameModel nameModel,
      StudentIdPhotoModel photoModel,
      StudentIdProfileModel profileModel,
      BuildContext context) {
    return Row(
        children: <Widget>[
          Padding(
           padding: EdgeInsets.only(left: cardMargin * 1.5),
          ),
      Container(
        child: Column(
          children: <Widget>[
            Image.network(
              photoModel.photoUrl,
              fit: BoxFit.contain,
              height: 125,
            ),
            SizedBox(height: 10),
            Text(profileModel.classificationType),
          ],
        ),
        padding: EdgeInsets.only(
          left: cardMargin,
          right: 20,
        ),
      ),
      Expanded(
        child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
        Container(
          padding: new EdgeInsets.only(right: cardMargin),
          child: Text(
              (nameModel.firstName + " " + nameModel.lastName),
              overflow: TextOverflow.ellipsis,
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
              textAlign: TextAlign.left,
              softWrap: false,
            maxLines: 1,
                ),
        ),
          SizedBox(height: 5),
          Container(
            padding: new EdgeInsets.only(right: cardMargin),
            child: Text(
              profileModel.collegeCurrent,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(color: Colors.grey, fontSize: 16),
              textAlign: TextAlign.left,
              softWrap: false,
              maxLines: 1,
            ),
          ),
          SizedBox(height: 5),

          Container(
            padding: new EdgeInsets.only(right: cardMargin),
            child: Text(
              profileModel.ugPrimaryMajorCurrent ,
              style: TextStyle( fontSize: 16),
              textAlign: TextAlign.left,
              softWrap: false,
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
            ),
          ),
          Padding(
            padding: EdgeInsets.only(top: 15),
          ),

          FlatButton(
            child: returnBarcodeContainer(barcodeModel.barCode.toString(), false, context),
            padding: EdgeInsets.all(0),
            onPressed: () {
              createAlertDialog(context,
                  returnBarcodeContainer(barcodeModel.barCode.toString(), true, context));
            },
          ),
        ]),
      ),
    ]);
  }

  returnBarcodeContainer(String cardNumber, bool rotated, BuildContext context) {
    var barcodeWithText;
    SizeConfig().init(context);
    if (rotated) {

     barcodeWithText = BarcodeWidget(
       barcode: Barcode.codabar(),
       data: "A" + cardNumber + "B",
       width: SizeConfig.safeBlockVertical * 60 ,
       height: 80,
       style: TextStyle(
         letterSpacing: SizeConfig.safeBlockVertical * 2.5
       ),
     );
    } else {
      barcodeWithText = BarcodeWidget(
      barcode: Barcode.codabar(),
    data: "A" + cardNumber + "B",
    width: SizeConfig.safeBlockHorizontal * 50 ,
    height: 50,
        style: TextStyle(
            letterSpacing: SizeConfig.safeBlockHorizontal * 1
        ),
    );
    }

    if (rotated) {
      return
      Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.all(25),
            ),
            RotatedBox(
              quarterTurns: 1,<commit_msg>Updated data displayed<commit_after>//import 'dart:io';
// import 'dart:js';

import 'package:barcode_widget/barcode_widget.dart';
import 'package:campus_mobile_experimental/core/constants/app_constants.dart';
import 'package:campus_mobile_experimental/core/data_providers/cards_data_provider.dart';
import 'package:campus_mobile_experimental/core/data_providers/student_id_data_provider.dart';
import 'package:campus_mobile_experimental/core/models/student_id_barcode_model.dart';
import 'package:campus_mobile_experimental/core/models/student_id_name_model.dart';
import 'package:campus_mobile_experimental/core/models/student_id_photo_model.dart';
import 'package:campus_mobile_experimental/core/models/student_id_profile_model.dart';
import 'package:campus_mobile_experimental/ui/reusable_widgets/card_container.dart';
import 'package:campus_mobile_experimental/ui/theme/app_layout.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:provider/provider.dart';

class StudentIdCard extends StatelessWidget {
  String cardId = "student_id";
  var barcodeImage;

  createAlertDialog(BuildContext context, Column image) {
    return showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
            title: Text("Student ID"),
            content: Container(
              child: image,
            ),
            actions: <Widget>[
              FlatButton(
                  child: Text("X"),
                  onPressed: () {
                    Navigator.of(context).pop();
                  })
            ],
          );
        });
  }

  @override
  Widget build(BuildContext context) {
    SizeConfig().init(context);

    return CardContainer(
      /// TODO: need to hook up hidden to state using provider
      active: Provider.of<CardsDataProvider>(context).cardStates[cardId],
      hide: () => Provider.of<CardsDataProvider>(context, listen: false)
          .toggleCard(cardId),
      reload: () => Provider.of<StudentIdDataProvider>(context, listen: false)
          .fetchData(),
      isLoading: Provider.of<StudentIdDataProvider>(context).isLoading,
      titleText: CardTitleConstants.titleMap[cardId],
      errorText: Provider.of<StudentIdDataProvider>(context).error,
      child: () => buildCardContent(
          Provider.of<StudentIdDataProvider>(context).studentIdBarcodeModel,
          Provider.of<StudentIdDataProvider>(context).studentIdNameModel,
          Provider.of<StudentIdDataProvider>(context).studentIdPhotoModel,
          Provider.of<StudentIdDataProvider>(context).studentIdProfileModel,
          context),
    );
  }

  Widget buildTitle() {
    return Text(
      "Student ID",
      textAlign: TextAlign.left,
    );
  }

  Widget buildCardContent(
      StudentIdBarcodeModel barcodeModel,
      StudentIdNameModel nameModel,
      StudentIdPhotoModel photoModel,
      StudentIdProfileModel profileModel,
      BuildContext context) {
    return Row(
        children: <Widget>[
          Padding(
           padding: EdgeInsets.only(left: cardMargin * 1.5),
          ),
      Container(
        child: Column(
          children: <Widget>[
            Image.network(
              photoModel.photoUrl,
              fit: BoxFit.contain,
              height: 125,
            ),
            SizedBox(height: 10),
            Text(profileModel.classificationType),
          ],
        ),
        padding: EdgeInsets.only(
          left: cardMargin,
          right: 20,
        ),
      ),
      Expanded(
        child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
        Container(
          padding: new EdgeInsets.only(right: cardMargin),
          child: Text(
              (nameModel.firstName + " " + nameModel.lastName),
              overflow: TextOverflow.ellipsis,
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
              textAlign: TextAlign.left,
              softWrap: false,
            maxLines: 1,
                ),
        ),
          SizedBox(height: 5),
          Container(
            padding: new EdgeInsets.only(right: cardMargin),
            child: Text(
              profileModel.collegeCurrent,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(color: Colors.grey, fontSize: 16),
              textAlign: TextAlign.left,
              softWrap: false,
              maxLines: 1,
            ),
          ),
          SizedBox(height: 5),

          Container(
            padding: new EdgeInsets.only(right: cardMargin),
            child: Text(
              profileModel.ugPrimaryMajorCurrent ,
              style: TextStyle( fontSize: 16),
              textAlign: TextAlign.left,
              softWrap: false,
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
            ),
          ),
          Padding(
            padding: EdgeInsets.only(top: 15),
          ),

          FlatButton(
            child: returnBarcodeContainer(barcodeModel.barCode.toString(), false, context),
            padding: EdgeInsets.all(0),
            onPressed: () {
              createAlertDialog(context,
                  returnBarcodeContainer(barcodeModel.barCode.toString(), true, context));
            },
          ),
        ]),
      ),
    ]);
  }

  returnBarcodeContainer(String cardNumber, bool rotated, BuildContext context) {
    var barcodeWithText;
    SizeConfig().init(context);
    if (rotated) {

     barcodeWithText = BarcodeWidget(
       barcode: Barcode.codabar(),
       data: cardNumber,
       width: SizeConfig.safeBlockVertical * 60 ,
       height: 80,
       style: TextStyle(
         letterSpacing: SizeConfig.safeBlockVertical * 3
       ),
     );
    } else {
      barcodeWithText = BarcodeWidget(
      barcode: Barcode.codabar(),
    data:  cardNumber ,
    width: SizeConfig.safeBlockHorizontal * 50 ,
    height: 50,
        style: TextStyle(
            letterSpacing: SizeConfig.safeBlockHorizontal * 1.5
        ),
    );
    }

    if (rotated) {
      return
      Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.all(25),
            ),
            RotatedBox(
              quarterTurns: 1,
{'fraction_non_alphanumeric': 0.1006239633520259, 'fraction_numerical': 0.005844720006318616, 'mean_word_length': 2.2096324461343473, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, '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': '6071879', 'n_tokens_mistral': 3564, 'n_tokens_neox': 3421, 'n_words': 611}