52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Cysharp.Threading.Tasks;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using YandexQuest.Models;
|
|
using Zenject;
|
|
|
|
public class DescriptionCard : MonoBehaviour
|
|
{
|
|
[Inject] private readonly NetworkService _networkService;
|
|
[Inject] private readonly ClientDataService _clientDataService;
|
|
private TagDescriptionsPanel _tagDescPanel;
|
|
|
|
[SerializeField] public Games game;
|
|
[SerializeField] private TMP_InputField _descriptionField;
|
|
[SerializeField] private Button _acceptChangesButton;
|
|
|
|
private void Awake()
|
|
{
|
|
_tagDescPanel = FindObjectOfType<TagDescriptionsPanel>();
|
|
_tagDescPanel.cards.Add(this);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
_descriptionField.text = "Для данной QR-метки ещё нет описания...";
|
|
|
|
_acceptChangesButton.onClick
|
|
.AddListener(() => SetTagDescription().Forget());
|
|
}
|
|
|
|
public void Init(Tag tag)
|
|
{
|
|
_descriptionField.text = tag.description;
|
|
}
|
|
|
|
private async UniTaskVoid SetTagDescription()
|
|
{
|
|
Tag tag = new Tag()
|
|
{
|
|
id = string.Empty,
|
|
game = game,
|
|
description = _descriptionField.text,
|
|
city = (Cities)_clientDataService.city
|
|
};
|
|
|
|
await _networkService.PostAsync<Tag>("game/tags/add", tag);
|
|
}
|
|
}
|