import 'package:betting/view/mobile/favourites_view/matches_view/list_fixtures/fixtures_screen.dart';
import 'package:betting/view/mobile/favourites_view/matches_view/list_results/result_screen.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class MatchesTeamInfoController extends GetxController {
  Rx<Tournament?> selectedTournament = Rx<Tournament?>(null);
  List<Tournament> tournaments = [
    Tournament(
        'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Globe_icon.svg/1200px-Globe_icon.svg.png',
        'Premier League'),
    Tournament(
        'https://upload.wikimedia.org/wikipedia/en/thumb/b/be/Flag_of_England.svg/1200px-Flag_of_England.svg.png',
        'Premier League 1'),
    Tournament(
        'https://upload.wikimedia.org/wikipedia/en/thumb/b/be/Flag_of_England.svg/1200px-Flag_of_England.svg.png',
        'Premier League 2'),
  ];

  List<DropdownMenuEntry<Tournament>> tournamentEntries = <DropdownMenuEntry<Tournament>>[];

  List<String> options = ['FIXTURES', 'RESULTS'];
  List<Widget> pageViews = [
    FixturesScreen(),
    ResultScreen(),
  ];
  var indexClick = 0.obs;

  PageController pageController = PageController(
    initialPage: 0,
    keepPage: true,
  );

  @override
  void onInit() async {
    super.onInit();

    selectedTournament.value = tournaments[0];
    for (final Tournament tournament in tournaments) {
      tournamentEntries.add(DropdownMenuEntry<Tournament>(value: tournament, label: tournament.tournamentName));
    }
  }

  onPageViewChange(int page) {
    indexClick.value = page;

    if (page != 0) {
      indexClick.value - 1;
    } else {
      indexClick.value = 0;
    }
  }
}

class Tournament {
  String icon;
  String tournamentName;

  Tournament(this.icon, this.tournamentName);
}
