last update
This commit is contained in:
@@ -1,12 +1,51 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Zenject;
|
||||
using YandexQuest.Models;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Linq;
|
||||
|
||||
public class TagDescriptionsPanel : MonoBehaviour
|
||||
{
|
||||
public List<DescriptionCard> cards { get; set; } = new List<DescriptionCard>();
|
||||
|
||||
[Inject] private readonly NetworkService _networkService;
|
||||
[Inject] private readonly ClientDataService _clientDataService;
|
||||
|
||||
private List<Tag> _tags;
|
||||
|
||||
private async UniTaskVoid OnEnable()
|
||||
{
|
||||
var result = await _networkService
|
||||
.GetAsync<List<Tag>>($"game/tags/{(int)_clientDataService.city}");
|
||||
|
||||
if (result.responseData != null)
|
||||
{
|
||||
_tags = result.responseData;
|
||||
|
||||
foreach (var card in cards)
|
||||
{
|
||||
var data = _tags.Find(x => x.game == card.game);
|
||||
if (data != null) card.Init(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1acb4224a2cc1884295feba5466f5da0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user