This commit is contained in:
CortexCore
2024-08-08 23:07:50 +08:00
parent dffda3663b
commit 5038fe33d1
9 changed files with 66 additions and 22 deletions

View File

@@ -196,17 +196,13 @@ namespace BITKit
//需要下载的文件总数和总大小
int totalDownloadCount = downloader.TotalDownloadCount;
long totalDownloadBytes = downloader.TotalDownloadBytes;
downloader.OnDownloadProgressCallback = (downloadedCount, downloadedBytes, downloadCount, downloadBytes) =>
downloader.OnDownloadProgressCallback = (totalDownloadCount, currentDownloadCount, totalDownloadBytes, currentDownloadBytes) =>
{
BIT4Log.Log<BITFramework>($"{totalDownloadCount},{currentDownloadCount},{totalDownloadBytes},{currentDownloadBytes}");
//下载进度
float progress = (float)downloadedBytes / downloadBytes;
//下载速度
float speed = 1;
//剩余时间
float remainTime = (downloadCount - downloadedCount) / speed;
float progress = (float)currentDownloadBytes / totalDownloadBytes;
_setProgressValue?.Invoke(progress);
_setProgressLabel?.Invoke($"下载速度:{speed}KB/s,剩余时间:{remainTime}s");
_setProgressLabel?.Invoke($"{currentDownloadBytes}/{totalDownloadBytes}");
};
downloader.OnDownloadErrorCallback=(fileName,error) =>
{

View File

@@ -40,6 +40,18 @@ namespace BITKit.UX
public new class UxmlFactory : UxmlFactory<TabBar, UxmlTraits> { }
// These are USS class names for the control overall and the label.
public TabBar()
{
RegisterCallback<AttachToPanelEvent>(UpdateI);
RegisterCallback<DetachFromPanelEvent>(UpdateI);
RegisterCallback<GeometryChangedEvent>(UpdateI);
}
private void UpdateI(object _)
{
CurrentTab = _currentTab;
}
public event Action<int> OnTabChanged;
private Button[] _buttons = Array.Empty<Button>();

View File

@@ -73,15 +73,20 @@ namespace BITKit.UX
{
_externalTabBar.OnTabChanged -= EntryTab;
}
if (panel?.visualTree != null)
if (parent is not null)
{
_externalTabBar = panel.visualTree.Q<TabBar>(value);
_externalTabBar = parent.Q<TabBar>(value);
if (_externalTabBar is not null)
{
_externalTabBar.OnTabChanged += EntryTab;
}
}
viewDataKey=_externalTabBar is null ? $"找到了:{value}" :$"未找到:{value}";
}
viewDataKey=_externalTabBar is null ? "找到了TabBar" :"未找到Tab";
else
{
viewDataKey = $"{value} is null";
}
}
}
private readonly VisualElement _container;
@@ -104,12 +109,24 @@ namespace BITKit.UX
}
public void EntryTab(int index)
{
if(index == -1)return;
var isCatched = false;
foreach (var x in _container.Children())
{
x.SetActive(false);
}
if(_container.Children().TryGetElementAt(index,out var element))
if (_container.Children().TryGetElementAt(index, out var element))
{
isCatched = true;
element.SetActive(true);
}
if (index is -1 && isCatched is false && this.childCount>0)
{
this.Children().First().SetActive(true);
}
OnTabChanged?.Invoke(index);
}
}

View File

@@ -177,13 +177,12 @@ namespace BITKit.UX
{
await UniTask.NextFrame(cancellationToken);
}
OnExit?.Invoke();
}
void IEntryElement.Exited()
{
document.rootVisualElement.SetActive(false);
isActive = false;
OnExit?.Invoke();
}
public event Action OnEntry;

View File

@@ -412,3 +412,6 @@ Foldout Toggle Label {
margin-bottom: 8px;
margin-left: 8px;
}
.wechat {
}