using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Threading; using BITKit; using BITKit.StateMachine; using BITKit.UX; using Cysharp.Threading.Tasks; using Net.Project.B.World; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UIElements; namespace Net.Project.B.PDA.App { [Serializable] public struct Feed : IApp { public string PackageName => "com.bndroid.feed"; public string AppName => "动态"; } public record AppFeedItem { public string UserName; public string Content; public string[] ImageNames; public DateTime Timestamp; public int LikeCount; public int Rewards; } public class AppFeed: PDAApp { protected override string DocumentPath => "ui_app_feed"; private readonly IDictionary _database; private readonly ISnapshotService _snapshotService; [UXBindPath("feed-container")] private VisualElement _feedContainer; [UXBindPath("image-selection")] private VisualElement _imageSelection; [UXBindPath("image-selected")] private VisualElement _imageSelected; [UXBindPath("select-images")] private Button _selectImageButton; [UXBindPath("confirm-images-button")] private Button _confirmImageButton; [UXBindPath("cancel-images-button")] private Button _cancelImageButton; [UXBindPath("feed-field")] private TextField _feedField; [UXBindPath("release-button")] private Button _releaseButton; private VisualTreeAsset _imageTemplate; private VisualTreeAsset _feedTemplate; private readonly HashSet _selectedImages = new(); private readonly HashSet _releaseImages = new(); private CancellationTokenSource _homeCts = new(); public AppFeed(IDictionary database, ISnapshotService snapshotService) { _database = database; _snapshotService = snapshotService; } private async void Home() { RootVisualElement.Q("SelectImage").SetActive(false); _homeCts.Cancel(); _homeCts = new CancellationTokenSource(); _feedContainer.Clear(); foreach (var (guid,item) in _database.OrderByDescending(x=>x.Value.Timestamp)) { var container = _feedContainer.Create(_feedTemplate); container.Get