import'package:flutter/material.dart';
import'package:line_awesome_flutter/line_awesome_flutter.dart';
import'package:provider/provider.dart';
import'package:quickcheck/model/user_exam_with_question.dart';
import'package:quickcheck/view/TestTab/test_type_interface.dart';
import'package:quickcheck/widget/test_type_02_widget.dart';
import'package:flutter_screenutil/flutter_screenutil.dart';

import'../../style.dart';

classTestType01extendsTestTypeInterface {
var_alphabetList;
  String answerLength = '';
  List<Map<String,dynamic>> _userAnswer = [];
  List<String> questionAlphabets = [
    'q', 'w', "e", 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', "v", 'b', 'n', 'm'
  ];
  Map vocaPos = {
    'V': '동사',
    'N': '명사',
    'R': '부사',
    'J': '형용사',
  };

  @override
  Widget buildAnswerUI(
      UserQuestion userProblem, Function(AnswerState, String) answerPressed, Function() questionPress) {
if(_alphabetList ==null) {
// _alphabetList = initAlphabets(userProblem.label);
_alphabetList = questionAlphabets;
    }

///1회차 답안 첫글자 제공
// _userAnswer.add({'index': 0, 'char': userProblem.label.substring(0, 1)});
_userAnswer.add({'index': 0, 'char': userProblem.label.substring(0, 2)});

returnTestType02Widget(userProblem.label, (answer) {
      answerPressed(validateAnswer(userProblem, answerWord: answer), answer);
    }, _alphabetList, _userAnswer, questionPress);
  }

  @override
  Widget buildProblemUI(CorrectVocabulary _coreectVocabulary) {
returnColumn(
      children: <Widget>[
        Container(
          padding: EdgeInsets.only(top: 10),
          width: double.infinity,
//문제내는 부분
child: Text(
            "다음 뜻에 해당하는 단어를 적으세요.",
            textAlign: TextAlign.center,
            style: boldTextStyle().copyWith(color: Color(0xffCCCCCC)),
          ),
        ),
        Padding(
          padding:constEdgeInsets.only(top: 10.0),
          child: Container(
            width: 40,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(20),
              color: Colors.yellow,
            ),
            child: Center(child: Text('${vocaPos[_coreectVocabulary.pos]}',
            style: TextStyle(fontSize: 13.sp, fontWeight: FontWeight.bold),
            ),),
          ),
        ),
        Container(
          padding: EdgeInsets.only(top: 10.0),
          width: double.infinity,
//문제내는 부분
child: _coreectVocabulary.meaning2 == '' ?
          Text('${_coreectVocabulary.meaning}',
            textAlign: TextAlign.center,
            style: baseTextEBStyle().copyWith(fontSize: 16.sp),
          )
              :  Text('${_coreectVocabulary.meaning}, ${_coreectVocabulary.meaning2}',
            textAlign: TextAlign.center,
            style: baseTextEBStyle().copyWith(fontSize: 16.sp),
          ),
        ),
//   //문제내는 부분
Container(
          padding: EdgeInsets.only(top: 10.0),
          width: double.infinity,
          child: Text('${_coreectVocabulary.media.first.english.replaceAll('${_coreectVocabulary.word}', '[   ]')}',
            textAlign: TextAlign.center,
            style: baseTextEBStyle().copyWith(fontSize: 14.sp),
          ),
        ),

        Container(
          padding: EdgeInsets.only(top: 10.0),
          width: double.infinity,
          child: Text('${_coreectVocabulary.media.first.korean}',
            textAlign: TextAlign.center,
            style: baseTextEBStyle().copyWith(fontSize: 14.sp),
          ),
        ),
      ],
    );
  }

  @override
voidnextQuestion() {
    _alphabetList =null;
    _userAnswer.clear();
  }

  @override
  AnswerState validateAnswer(UserQuestion userProblem,
      {int answerWordId, String answerWord}) {
if(userProblem.label == answerWord) {
      print('O');
returnAnswerState.CORRECT;
    }else{
      print('X');
//틀린거 표시
returnAnswerState.INCORRECT;
    }
  }
}