import 'package:betting/data/model/res/competitions/competitions.dart';
import 'package:betting/data/model/res/matches/matches.dart';
import 'package:betting/view/mobile/scores/football/detail_tournament/player_stats/player_stats_page.dart';
import 'package:betting/view/mobile/scores/football/detail_tournament/table_tournament/table_tournament_page.dart';
import 'package:betting/view/mobile/scores/football/detail_tournament/team_stats/team_stats_page.dart';
import 'package:betting/view/mobile/scores/football/detail_tournament/tournament_new/tournament_new_page.dart';
import 'package:betting/view/mobile/scores/football/detail_tournament/tournament_video/tournament_video_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';

import 'matches/matches_football_page.dart';
import 'overview/overview_page.dart';

class DetailTournamentController extends GetxController {
  var listTitle = ["Overview","Matches","News","Player Stats"];
  RxInt indexClick = 0.obs;
  PageController pageController = PageController(
    initialPage: 0,
    keepPage: true,
  );
  var listPage = <Widget>[];
  String typeTournament = "";
  RxString competitionId = ''.obs;
  RxString competitionName = ''.obs;
  RxBool isFavourite = false.obs;

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

  @override
  void onInit() {
    if(Get.arguments.runtimeType == ItemsMatches) {
      competitionId.value = Get.arguments.sId;
      isFavourite.value = Get.arguments.favourite ?? false;
    } else if(Get.arguments.runtimeType == ItemsCompetitions) {
      competitionId.value = Get.arguments.id;
      isFavourite.value = true;
    }

    var tmpTypeTournament = Get.arguments.isCup;
    competitionName.value = Get.arguments.name;


    if(tmpTypeTournament != null){
      typeTournament = tmpTypeTournament;
      if(typeTournament == 'CUP'){
        listTitle = ["Overview","Matches","News","Player Stats"];
        listPage = [OverviewTournamentPage(),MatchesFootballPage(),TournamentNewPage(),TournamentPlayerStatsPage()];
      }else{
        listTitle = ["Overview","Matches","Table","News","Video","Player Stats","Team Stats"];
        listPage = [OverviewTournamentPage(),MatchesFootballPage(),TableTournamentPage(),TournamentNewPage(),TournamentVideoPage(),TournamentPlayerStatsPage(),TournamentTeamStatsPage()];
      }
    }
    super.onInit();
  }
}



