Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,31 @@ private static void CreateShareableListEntry(BasisShareableEntry entry, RectTran
itemTextInfo.Descriptor.SetHeight(50);
itemTextInfo.Descriptor.SetWidth(400);

// Optional secondary action (registered by the entry's provider —
// e.g. a Share/Unshare toggle): a labeled button beside the trash,
// with an optional consent-style yes/no dialog in front of it.
if (!string.IsNullOrEmpty(entry.ActionLabel))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be action labels?

if we made it a array then we could move a lot of stuff to just piggy backing off of this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image re-routed buttons through one API

{
PanelButton actionItem = PanelButton.CreateNew(ButtonStyles.AcceptButton, itemListPanel.TabButtonParent);
actionItem.Descriptor.SetTitle(entry.ActionLabel);
actionItem.SetSize(new Vector2(180, 80));
actionItem.OnClicked += async () =>
{
if (!string.IsNullOrEmpty(entry.ActionConfirmTitle))
{
DialogBox<bool> confirmDialog = DialogBox<bool>.Create(panel, new Vector2(650, 180),
entry.ActionConfirmTitle,
entry.ActionConfirmBody ?? string.Empty,
AddressableAssets.Sprites.Information,
true
);
LibraryProviderDialogRemove.BuildDialogButtons(confirmDialog);
if (!await confirmDialog.WaitAsync()) return;
}
entry.Action?.Invoke();
};
}

PanelButton removeItem = PanelButton.CreateNew(ButtonStyles.CancelButton, itemListPanel.TabButtonParent);
removeItem.Descriptor.SetTitle(string.Empty);
removeItem.SetIcon(AddressableAssets.Sprites.Trash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ public sealed class BasisShareableEntry
public string Title;
public string SharerName;
public Action Remove;

/// <summary>Optional secondary action, rendered as a labeled button next to the
/// remove button (e.g. a "Share"/"Unshare" toggle). Null/empty label = no button.
/// The registering package owns the semantics; the Library UI just presents it.</summary>
public string ActionLabel;
public Action Action;
/// <summary>Non-null = the Library shows a yes/no dialog with this title/body
/// before invoking <see cref="Action"/> (for consent-style actions).</summary>
public string ActionConfirmTitle;
public string ActionConfirmBody;
}

/// <summary>
Expand Down Expand Up @@ -55,5 +65,33 @@ public static void SetDetail(string id, string detail)
}
}

/// <summary>Update an entry's secondary action presentation (label + optional
/// confirm text) — e.g. flipping a Share button to Unshare after it's invoked.
/// A null/empty label removes the button. The Action delegate itself stays as
/// registered.</summary>
public static void SetAction(string id, string label, string confirmTitle = null, string confirmBody = null)
{
if (string.IsNullOrEmpty(id)) return;
if (Entries.TryGetValue(id, out BasisShareableEntry entry))
{
entry.ActionLabel = label;
entry.ActionConfirmTitle = confirmTitle;
entry.ActionConfirmBody = confirmBody;
OnChanged?.Invoke();
}
}

/// <summary>Update who shared an entry (rendered as "shared by …") after
/// registration — e.g. once a received share's sharer is identified.</summary>
public static void SetSharerName(string id, string sharerName)
{
if (string.IsNullOrEmpty(id)) return;
if (Entries.TryGetValue(id, out BasisShareableEntry entry))
{
entry.SharerName = sharerName;
OnChanged?.Invoke();
}
}

public static IReadOnlyCollection<BasisShareableEntry> GetAll() => Entries.Values;
}
Loading