createVisualBar method

void createVisualBar ()

Create the initial _visualBar and append it in the _lane This is called in LevelController

Implementation

void createVisualBar() {
  _visualBar = DivElement()..setAttribute("class", "visual-bar");

  ImageElement menuButton = ImageElement(src: "resources/back.svg")..setAttribute("id", "button_back_in_level");

  DivElement progressBar = DivElement()..setAttribute("class", "progress-bar");

  DivElement currentLevel = DivElement()
    ..setAttribute("class", "level first-level")
    ..appendText(_level.getLevel().toString());

  ProgressElement scoreProgress = ProgressElement()
    ..setAttribute("class", "score-progress")
    ..setAttribute("min", "0")
    ..setAttribute("max", _level.targetScore.toString());

  DivElement nextLevel = DivElement()
    ..setAttribute("class", "level next-level")
    ..appendText((_level.getLevel() + 1).toString());

  SpanElement timer = SpanElement()
    ..setAttribute("class", "countdown")
    ..appendText((_level.timeLimit / 1000).toStringAsFixed(2));

  progressBar.append(currentLevel);
  progressBar.append(scoreProgress);
  progressBar.append(nextLevel);

  _visualBar.append(menuButton);
  _visualBar.append(progressBar);
  _visualBar.append(timer);

  _lane.append(_visualBar);
}