UniWebViewChannelMethodEmbeddedToolbarItemAction.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // UniWebViewChannelMethodEmbeddedToolbarItemAction.cs
  3. // Created by Wang Wei(@onevcat) on 2026-03-05.
  4. //
  5. // This file is a part of UniWebView Project (https://uniwebview.com)
  6. // By purchasing the asset, you are allowed to use this code in as many as projects
  7. // you want, only if you publish the final products under the name of the same account
  8. // used for the purchase.
  9. //
  10. // This asset and all corresponding files (such as source code) are provided on an
  11. // "as is" basis, without warranty of any kind, express of implied, including but not
  12. // limited to the warranties of merchantability, fitness for a particular purpose, and
  13. // noninfringement. In no event shall the authors or copyright holders be liable for any
  14. // claim, damages or other liability, whether in action of contract, tort or otherwise,
  15. // arising from, out of or in connection with the software or the use of other dealing in the software.
  16. //
  17. using System;
  18. using UnityEngine;
  19. /// <summary>
  20. /// Represents an embedded toolbar item action request from native side.
  21. /// </summary>
  22. [Serializable]
  23. public class UniWebViewChannelMethodEmbeddedToolbarItemAction {
  24. [Serializable]
  25. public enum GestureType {
  26. Tap,
  27. LongPress
  28. }
  29. internal const string GestureTypeTap = "tap";
  30. internal const string GestureTypeLongPress = "longPress";
  31. [SerializeField]
  32. private string identifier;
  33. [SerializeField]
  34. private string gesture;
  35. [SerializeField]
  36. private string copyToastText;
  37. /// <summary>
  38. /// The toolbar item identifier. Built-in identifiers are prefixed with "uwv.toolbar.".
  39. /// </summary>
  40. public string Identifier => identifier;
  41. /// <summary>
  42. /// The gesture type from native side. Unsupported values fallback to <see cref="GestureType.Tap"/>.
  43. /// </summary>
  44. public GestureType Gesture {
  45. get {
  46. if (string.Equals(gesture, GestureTypeLongPress, StringComparison.OrdinalIgnoreCase)) {
  47. return GestureType.LongPress;
  48. }
  49. return GestureType.Tap;
  50. }
  51. }
  52. /// <summary>
  53. /// Optional toast text from title long-press interaction config.
  54. /// </summary>
  55. public string CopyToastText => string.IsNullOrEmpty(copyToastText) ? null : copyToastText;
  56. }