1
This commit is contained in:
@@ -134,6 +134,8 @@ namespace BITKit.UX
|
||||
_confirmButton.clicked += Close;
|
||||
_cancelButton.clicked += Close;
|
||||
|
||||
BITInputSystem.AllowInput.AddDisableElements(this);
|
||||
|
||||
|
||||
if (message.OnConfirm is not null)
|
||||
{
|
||||
@@ -156,6 +158,7 @@ namespace BITKit.UX
|
||||
}
|
||||
private void Close()
|
||||
{
|
||||
BITInputSystem.AllowInput.RemoveDisableElements(this);
|
||||
Dispose();
|
||||
BITAppForUnity.AllowCursor.RemoveElement(this);
|
||||
}
|
||||
|
@@ -41,6 +41,12 @@ namespace Net.BITKit.UX
|
||||
x.text = _localizationService.GetLocalizedString('#'+x.viewDataKey);
|
||||
}
|
||||
|
||||
foreach (var x in visualElement.Query<ProgressBar>(className:USS).ToList())
|
||||
{
|
||||
if(string.IsNullOrEmpty(x.viewDataKey))continue;
|
||||
x.title = _localizationService.GetLocalizedString('#'+x.viewDataKey);
|
||||
}
|
||||
|
||||
foreach (var x in visualElement.Query(className:USS).ToList())
|
||||
{
|
||||
if(string.IsNullOrEmpty(x.viewDataKey))continue;
|
||||
|
@@ -239,7 +239,7 @@ namespace BITKit.UX
|
||||
await UniTask.NextFrame();
|
||||
|
||||
await OnExitAsync.UniTaskFunc();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
@@ -249,6 +249,10 @@ namespace BITKit.UX
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
await UniTask.NextFrame();
|
||||
}
|
||||
|
||||
RootVisualElement?.RemoveFromClassList(USSExit);
|
||||
RootVisualElement?.RemoveFromClassList(USSExitAsync);
|
||||
|
8
Src/Unity/Scripts/UX/SnackBar.meta
Normal file
8
Src/Unity/Scripts/UX/SnackBar.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8133ef90cc55fcd47b52169ff7a8acab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
70
Src/Unity/Scripts/UX/SnackBar/UXSnackBar.cs
Normal file
70
Src/Unity/Scripts/UX/SnackBar/UXSnackBar.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using BITKit.Tween;
|
||||
using BITKit.UX;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Net.BITKit.UX.SnackBar
|
||||
{
|
||||
public class UXSnackBar<TPanel> : UIToolkitSubPanel<TPanel>,ISnackBar where TPanel :IUXPanel
|
||||
{
|
||||
[UXBindPath("snack_bar-container")] private VisualElement _snackBarContainer;
|
||||
|
||||
private VisualTreeAsset _template;
|
||||
|
||||
private readonly ValidHandle _waitHandle = new ValidHandle();
|
||||
|
||||
public UXSnackBar(IServiceProvider serviceProvider) : base(serviceProvider)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnInitiated()
|
||||
{
|
||||
base.OnInitiated();
|
||||
_template = _snackBarContainer.Q<TemplateContainer>().templateSource;
|
||||
|
||||
_snackBarContainer.Clear();
|
||||
|
||||
BITAppForUnity.AllowCursor.AddListener(OnAllowCursor);
|
||||
}
|
||||
|
||||
private void OnAllowCursor(bool obj)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
_waitHandle.AddElement(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
_waitHandle.RemoveElement(this);
|
||||
}
|
||||
}
|
||||
|
||||
public async void Add(string message, Severity severity = Severity.Normal)
|
||||
{
|
||||
var ve = _snackBarContainer.Create(_template);
|
||||
|
||||
ve.AddToClassList($"severity-{severity.ToString().ToLower()}");
|
||||
|
||||
ve.Get<Label>().text = message;
|
||||
|
||||
if (ve.Q("VisualElement--1") is { } bar)
|
||||
{
|
||||
await BITween.Lerp(x => bar.style.width = new StyleLength(Length.Percent(x)), 0f, 100, 5, Mathf.Lerp);
|
||||
}
|
||||
else
|
||||
{
|
||||
await UniTask.Delay(5000);
|
||||
}
|
||||
|
||||
await _waitHandle;
|
||||
|
||||
ve.RemoveFromHierarchy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Src/Unity/Scripts/UX/SnackBar/UXSnackBar.cs.meta
Normal file
11
Src/Unity/Scripts/UX/SnackBar/UXSnackBar.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f50e7ab406d7dc418e3837c536dff2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user