using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MapDetailController : MonoBehaviour
{
    // Start is called before the first frame update
    [HideInInspector] public int id = 0;
    [HideInInspector] public MapRoute map;
    void Start()
    {
        if (id != 0) 
        {
            var r = ConfigHelper.mapApi.GetById(id);
            if (r.result)
            {
                map = r.data;
            }
            else
            {
                Utils.showToast(gameObject, r.errMsg, 1);
            }
        }
        if (transform.Find("BtnGoRide") != null) 
        {
            transform.Find("BtnGoRide").GetComponent<Button>().onClick.AddListener(GoRide);
        }
        if (transform.Find("Name") != null) 
        {
            transform.Find("Name").GetComponent<Text>().text = map.Name;
        }
        if (transform.Find("BtnReturn") != null)
        {
            transform.Find("BtnReturn").GetComponent<Button>().onClick.AddListener(() =>
            {
                UIManager.ShowHomePanel();
            });
        }
    }

    private void GoRide()
    {
        Utils.showToast(gameObject, "去骑行", 1);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
