Skip to content

Commit 1086ab9

Browse files
feat: add set public button to photo view (#4594)
* Added Set as Public button to photo details panel * Added hide reels from public boards + hiding delete button on not owner reels * Added separator hiding in pair with Set as Public toggle * Added SetInteractable method to ToggleWithText This method swaps also additionally added sprites. * Added SetInteractable to Button This method swaps also additionally added sprites. * Added newly added SetInteractable to PhotoDetailUI * Added color change to toggle on set interactable * Code clean up + toggle color scheme * Added color change to text in ToggleWithText on noninteractive * Code cleanup * Disabled toggle and delete button for non player galleries * Code cleanup * Added event bus to photo gallery to update public state in between panels * Hidden public toggle from community gallery + post merge fix * Fixed post merge missing coma * Added reel updated text to global plugins settings * Fixed reel set as public communication between panels * Implemented proper null handling to PhotoDetailController --------- Co-authored-by: davidejensen <davidejensen@live.it>
1 parent 510a3eb commit 1086ab9

26 files changed

Lines changed: 1385 additions & 107 deletions

Explorer/Assets/DCL/Communities/CommunitiesCard/CommunityCardController.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using DCL.Diagnostics;
1111
using DCL.EventsApi;
1212
using DCL.Friends;
13+
using DCL.InWorldCamera;
1314
using DCL.InWorldCamera.CameraReelGallery;
1415
using DCL.InWorldCamera.CameraReelStorageService;
1516
using DCL.InWorldCamera.CameraReelStorageService.Schemas;
@@ -63,6 +64,7 @@ public class CommunityCardController : ControllerBase<CommunityCardView, Communi
6364
private readonly IDecentralandUrlsSource decentralandUrlsSource;
6465
private readonly IWeb3IdentityCache web3IdentityCache;
6566
private readonly LambdasProfilesProvider lambdasProfilesProvider;
67+
private readonly GalleryEventBus galleryEventBus;
6668

6769
private CameraReelGalleryController? cameraReelGalleryController;
6870
private MembersListController? membersListController;
@@ -96,7 +98,8 @@ public CommunityCardController(ViewFactoryMethod viewFactory,
9698
IChatEventBus chatEventBus,
9799
IDecentralandUrlsSource decentralandUrlsSource,
98100
IWeb3IdentityCache web3IdentityCache,
99-
LambdasProfilesProvider lambdasProfilesProvider)
101+
LambdasProfilesProvider lambdasProfilesProvider,
102+
GalleryEventBus galleryEventBus)
100103
: base(viewFactory)
101104
{
102105
this.mvcManager = mvcManager;
@@ -116,6 +119,7 @@ public CommunityCardController(ViewFactoryMethod viewFactory,
116119
this.decentralandUrlsSource = decentralandUrlsSource;
117120
this.web3IdentityCache = web3IdentityCache;
118121
this.lambdasProfilesProvider = lambdasProfilesProvider;
122+
this.galleryEventBus = galleryEventBus;
119123
this.thumbnailLoader = new ThumbnailLoader(null);
120124

121125
chatEventBus.OpenPrivateConversationRequested += CloseCardOnConversationRequested;
@@ -339,8 +343,11 @@ private void ResetSubControllers()
339343
eventListController?.Reset();
340344
}
341345

342-
private void OnThumbnailClicked(List<CameraReelResponseCompact> reels, int index, Action<CameraReelResponseCompact> reelDeleteIntention) =>
343-
mvcManager.ShowAsync(PhotoDetailController.IssueCommand(new PhotoDetailParameter(reels, index, false, reelDeleteIntention)));
346+
private void OnThumbnailClicked(List<CameraReelResponseCompact> reels, int index,
347+
Action<CameraReelResponseCompact> reelDeleteIntention, Action<CameraReelResponseCompact> reelListRefreshIntention) =>
348+
mvcManager.ShowAsync(PhotoDetailController.IssueCommand(new PhotoDetailParameter(reels, index,
349+
true, PhotoDetailParameter.CallerContext.CommunityCard, reelDeleteIntention,
350+
reelListRefreshIntention, galleryEventBus)));
344351

345352
private void OnSectionChanged(CommunityCardView.Sections section)
346353
{

Explorer/Assets/DCL/InWorldCamera/CameraReelGallery/CameraReelController.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class CameraReelController : ISection, IDisposable
2626
private readonly IWeb3IdentityCache web3IdentityCache;
2727
private readonly IMVCManager mvcManager;
2828
private readonly ICursor cursor;
29+
private readonly GalleryEventBus galleryEventBus;
2930

3031
private CancellationTokenSource showCancellationTokenSource;
3132

@@ -36,6 +37,7 @@ public CameraReelController(
3637
IWeb3IdentityCache web3IdentityCache,
3738
IMVCManager mvcManager,
3839
ICursor cursor,
40+
GalleryEventBus galleryEventBus,
3941
string storageProgressBarLabelText)
4042
{
4143
this.view = view;
@@ -44,6 +46,7 @@ public CameraReelController(
4446
this.CameraReelGalleryController = cameraReelGalleryController;
4547
this.mvcManager = mvcManager;
4648
this.cursor = cursor;
49+
this.galleryEventBus = galleryEventBus;
4750

4851
rectTransform = view.transform.parent.GetComponent<RectTransform>();
4952

@@ -61,8 +64,11 @@ private void OnGoToCameraButtonClicked()
6164
//TODO (Lorenzo): Close gallery and open camera
6265
}
6366

64-
private void ThumbnailClicked(List<CameraReelResponseCompact> reels, int index, Action<CameraReelResponseCompact> reelDeleteIntention) =>
65-
mvcManager.ShowAsync(PhotoDetailController.IssueCommand(new PhotoDetailParameter(reels, index, true, reelDeleteIntention)));
67+
private void ThumbnailClicked(List<CameraReelResponseCompact> reels, int index,
68+
Action<CameraReelResponseCompact> reelDeleteIntention, Action<CameraReelResponseCompact> reelListRefreshIntention) =>
69+
mvcManager.ShowAsync(PhotoDetailController.IssueCommand(new PhotoDetailParameter(reels, index,
70+
false, PhotoDetailParameter.CallerContext.CameraReel, reelDeleteIntention,
71+
reelListRefreshIntention, galleryEventBus)));
6672

6773
private void StorageFullIconEnter() =>
6874
view.storageFullToast.DOFade(1f, view.storageFullToastFadeTime);

Explorer/Assets/DCL/InWorldCamera/CameraReelGallery/CameraReelGalleryController.cs

Lines changed: 73 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ public ReelToDeleteInfo(string id, string datetime)
4343
}
4444
}
4545

46-
public event Action<List<CameraReelResponseCompact>, int, Action<CameraReelResponseCompact>>? ThumbnailClicked;
46+
public delegate void ThumbnailClick(
47+
List<CameraReelResponseCompact> reels,
48+
int index,
49+
Action<CameraReelResponseCompact> reelDeleteIntention,
50+
Action<CameraReelResponseCompact> reelListRefreshIntention);
51+
public event ThumbnailClick? ThumbnailClicked;
4752
public event Action<CameraReelStorageStatus>? StorageUpdated;
4853
public event Action ScreenshotDeleted;
4954
public event Action ScreenshotShared;
@@ -63,6 +68,7 @@ public ReelToDeleteInfo(string id, string datetime)
6368
private readonly IDecentralandUrlsSource? decentralandUrlsSource;
6469
private readonly ISystemClipboard? systemClipboard;
6570
private readonly IWebBrowser? webBrowser;
71+
private readonly GalleryEventBus galleryEventBus;
6672
private readonly ReelGalleryPoolManager reelGalleryPoolManager;
6773
private readonly Dictionary<DateTime, MonthGridController> monthViews = new ();
6874
private readonly Dictionary<CameraReelResponseCompact, Texture> reelThumbnailCache = new ();
@@ -96,7 +102,8 @@ public CameraReelGalleryController(CameraReelGalleryView view,
96102
IDecentralandUrlsSource? decentralandUrlsSource = null,
97103
ISystemClipboard? systemClipboard = null,
98104
ReelGalleryStringMessages? reelGalleryStringMessages = null,
99-
IMVCManager? mvcManager = null)
105+
IMVCManager? mvcManager = null,
106+
GalleryEventBus galleryEventBus = null)
100107
{
101108
this.view = view;
102109
this.cameraReelStorageService = cameraReelStorageService;
@@ -112,6 +119,7 @@ public CameraReelGalleryController(CameraReelGalleryView view,
112119
this.decentralandUrlsSource = decentralandUrlsSource;
113120
this.systemClipboard = systemClipboard;
114121
this.webBrowser = webBrowser;
122+
this.galleryEventBus = galleryEventBus;
115123

116124
this.view.scrollRect.SetScrollSensitivityBasedOnPlatform();
117125

@@ -184,7 +192,7 @@ async UniTaskVoid SetPublicFlagAsync(CancellationToken ct)
184192
{
185193
try
186194
{
187-
await this.cameraReelStorageService.UpdateScreenshotVisibilityAsync(response.id, isPublic, ct);
195+
await cameraReelStorageService.UpdateScreenshotVisibilityAsync(response.id, isPublic, ct);
188196
response.isPublic = isPublic;
189197
view.cameraReelToastMessage?.ShowToastMessage(CameraReelToastMessageType.SUCCESS, reelGalleryStringMessages?.PhotoSuccessfullyUpdatedMessage);
190198
}
@@ -244,27 +252,7 @@ private async UniTask DeleteScreenshotsAsync(ReelToDeleteInfo reelToDeleteInfo,
244252
{
245253
CameraReelStorageStatus response = await cameraReelStorageService.DeleteScreenshotAsync(reelToDeleteInfo.Id, ct);
246254

247-
int deletedIndex = -1;
248-
for (int i = 0; i < currentSize; i++)
249-
if (deletedIndex >= 0)
250-
thumbnailImages[i - 1] = thumbnailImages[i];
251-
else if (thumbnailImages[i].CameraReelResponse.id == reelToDeleteInfo.Id)
252-
deletedIndex = i;
253-
254-
thumbnailImages[currentSize - 1] = null;
255-
currentSize--;
256-
ResetThumbnailsVisibility();
257-
258-
MonthGridController monthGridView = GetMonthGrid(ReelUtility.GetMonthDateTimeFromString(reelToDeleteInfo.Datetime));
259-
monthGridView.RemoveThumbnail(reelToDeleteInfo.Id);
260-
261-
if (monthGridView.GridIsEmpty())
262-
{
263-
monthViews.Remove(monthGridView.DateTimeBucket);
264-
ReleaseGridView(monthGridView);
265-
}
266-
267-
pagedCameraReelManager.RemoveReelId(reelToDeleteInfo.Id);
255+
RemoveThumbnailFromList(reelToDeleteInfo.Id, reelToDeleteInfo.Datetime);
268256

269257
ScreenshotDeleted?.Invoke();
270258
StorageUpdated?.Invoke(response);
@@ -279,6 +267,57 @@ private async UniTask DeleteScreenshotsAsync(ReelToDeleteInfo reelToDeleteInfo,
279267
}
280268
}
281269

270+
private void HideReelFromList(CameraReelResponseCompact reelToHide)
271+
{
272+
if (reelToHide != null)
273+
RemoveThumbnailFromList(reelToHide.id, reelToHide.dateTime);
274+
}
275+
276+
private void RemoveThumbnailFromList(string reelId, string dateTime)
277+
{
278+
int indexToRemove = -1;
279+
for (int i = 0; i < currentSize; i++)
280+
{
281+
if (indexToRemove >= 0)
282+
{
283+
thumbnailImages[i - 1] = thumbnailImages[i];
284+
}
285+
else if (thumbnailImages[i].CameraReelResponse.id == reelId)
286+
{
287+
indexToRemove = i;
288+
}
289+
}
290+
291+
thumbnailImages[currentSize - 1] = null;
292+
currentSize--;
293+
ResetThumbnailsVisibility();
294+
295+
MonthGridController monthGridView = GetMonthGrid(ReelUtility.GetMonthDateTimeFromString(dateTime));
296+
monthGridView.RemoveThumbnail(reelId);
297+
298+
if (monthGridView.GridIsEmpty())
299+
{
300+
monthViews.Remove(monthGridView.DateTimeBucket);
301+
ReleaseGridView(monthGridView);
302+
}
303+
304+
pagedCameraReelManager.RemoveReelId(reelId);
305+
306+
if(currentSize <= 0)
307+
view.emptyState.SetActive(true);
308+
}
309+
310+
private void OnReelPublicStateChange(string reelId, bool isPublic)
311+
{
312+
foreach (var thumbnail in pagedCameraReelManager.AllOrderedResponses)
313+
{
314+
if(thumbnail.id != reelId) continue;
315+
316+
thumbnail.isPublic = isPublic;
317+
return;
318+
}
319+
}
320+
282321
private void PrepareShowGallery(CancellationToken ct)
283322
{
284323
view.loadingSpinner.SetActive(true);
@@ -295,6 +334,7 @@ private void FinishShowGallery()
295334
{
296335
view.scrollRect.onValueChanged.AddListener(OnScrollRectValueChanged);
297336
view.loadingSpinner.SetActive(false);
337+
galleryEventBus.ReelPublicStateChangeEvent += OnReelPublicStateChange;
298338
}
299339

300340
public async UniTask ShowWalletGalleryAsync(string walletAddress, CancellationToken ct, CameraReelStorageStatus? storageStatus = null)
@@ -382,11 +422,13 @@ private async UniTask LoadMorePageAsync(CancellationToken ct)
382422
IReadOnlyList<ReelThumbnailController> thumbnailViews = monthGridView.Setup(bucket.Key, bucket.Value, optionButtonController,
383423
(cameraReelResponse, sprite) => reelThumbnailCache.Add(cameraReelResponse, sprite),
384424
cameraReelResponse =>
385-
ThumbnailClicked?.Invoke(pagedCameraReelManager.AllOrderedResponses, pagedCameraReelManager.AllOrderedResponses.IndexOf(cameraReelResponse), compact =>
386-
{
387-
reelToDelete = compact;
388-
DeleteScreenshot();
389-
})
425+
ThumbnailClicked?.Invoke(pagedCameraReelManager.AllOrderedResponses, pagedCameraReelManager.AllOrderedResponses.IndexOf(cameraReelResponse),
426+
reelToDelete =>
427+
{
428+
this.reelToDelete = reelToDelete;
429+
DeleteScreenshot();
430+
},
431+
HideReelFromList)
390432
);
391433

392434
for (int i = 0; i < thumbnailViews.Count; i++)
@@ -551,6 +593,8 @@ private void OnDisable()
551593

552594
HideDeleteModal();
553595
optionButtonController?.HideControl();
596+
597+
galleryEventBus.ReelPublicStateChangeEvent -= OnReelPublicStateChange;
554598
}
555599

556600
public void Dispose()

Explorer/Assets/DCL/InWorldCamera/InWorldCamera/Systems/InWorldCameraPlugin.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public class InWorldCameraPlugin : IDCLGlobalPlugin<InWorldCameraSettings>
7777
private readonly NametagsData nametagsData;
7878
private readonly ISharedSpaceManager sharedSpaceManager;
7979
private readonly IWeb3IdentityCache web3IdentityCache;
80+
private readonly GalleryEventBus galleryEventBus;
8081
private readonly ProfileRepositoryWrapper profileRepositoryWrapper;
8182

8283
private ScreenRecorder recorder;
@@ -102,7 +103,8 @@ public InWorldCameraPlugin(SelfProfile selfProfile,
102103
NametagsData nametagsData,
103104
ProfileRepositoryWrapper profileDataProvider,
104105
ISharedSpaceManager sharedSpaceManager,
105-
IWeb3IdentityCache web3IdentityCache)
106+
IWeb3IdentityCache web3IdentityCache,
107+
GalleryEventBus galleryEventBus)
106108
{
107109
this.selfProfile = selfProfile;
108110
this.realmData = realmData;
@@ -131,6 +133,7 @@ public InWorldCameraPlugin(SelfProfile selfProfile,
131133
this.profileRepositoryWrapper = profileDataProvider;
132134
this.sharedSpaceManager = sharedSpaceManager;
133135
this.web3IdentityCache = web3IdentityCache;
136+
this.galleryEventBus = galleryEventBus;
134137

135138
factory = new InWorldCameraFactory();
136139
web3IdentityCache.OnIdentityChanged += FetchCameraReelStorage;
@@ -171,16 +174,20 @@ public async UniTask InitializeAsync(InWorldCameraSettings settings, Cancellatio
171174
decentralandUrlsSource,
172175
new ECSThumbnailProvider(realmData, globalWorld, assetBundleURL, webRequestController),
173176
new PassportBridgeOpener(),
177+
web3IdentityCache,
174178
rarityBackgroundsMapping,
175179
rarityColorMappings,
176180
categoryIconsMapping,
177181
profileRepositoryWrapper
178182
),
179183
cameraReelScreenshotsStorage,
184+
cameraReelStorageService,
180185
systemClipboard,
181186
decentralandUrlsSource,
182187
webBrowser,
183-
new PhotoDetailStringMessages(settings.ShareToXMessage, settings.PhotoSuccessfullyDownloadedMessage, settings.LinkCopiedMessage)));
188+
new PhotoDetailStringMessages(settings.ShareToXMessage, settings.PhotoSuccessfullyDownloadedMessage,
189+
settings.PhotoSuccessfullySetAsPublicMessage, settings.LinkCopiedMessage),
190+
galleryEventBus));
184191

185192

186193
inWorldCameraController = new InWorldCameraController(() => hud.GetComponent<InWorldCameraView>(), sidebarButton, globalWorld, mvcManager, cameraReelStorageService, sharedSpaceManager);
@@ -220,6 +227,7 @@ public class InWorldCameraSettings : IDCLPluginSettings
220227
[field: SerializeField] internal AssetReferenceGameObject PhotoDetailPrefab { get; private set; }
221228
[field: SerializeField, Tooltip("Spaces will be HTTP sanitized, care for special characters")] internal string ShareToXMessage { get; private set; }
222229
[field: SerializeField] internal string PhotoSuccessfullyDownloadedMessage { get; private set; }
230+
[field: SerializeField] internal string PhotoSuccessfullySetAsPublicMessage { get; private set; }
223231
[field: SerializeField] internal string LinkCopiedMessage { get; private set; }
224232
[field: SerializeField] internal AssetReferenceT<NftTypeIconSO> CategoryIconsMapping { get; private set; }
225233

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
3+
namespace DCL.InWorldCamera
4+
{
5+
public class GalleryEventBus
6+
{
7+
public event Action<string, bool> ReelPublicStateChangeEvent;
8+
9+
public void ReelPublicStateChanged(string reelId, bool isPublic)
10+
{
11+
ReelPublicStateChangeEvent?.Invoke(reelId, isPublic);
12+
}
13+
}
14+
}

Explorer/Assets/DCL/InWorldCamera/PhotoDetail/GalleryEventBus.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Explorer/Assets/DCL/InWorldCamera/PhotoDetail/PhotoDetail.asmdef

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"GUID:ff38b7506167d314d987b4b8e8406988",
2828
"GUID:52421c42d33594c47a6fbd48b45b1259",
2929
"GUID:9cce9838ccdc58d46b673e02f1058718",
30-
"GUID:d5368878df29ff849933a7d3586d18c6"
30+
"GUID:d5368878df29ff849933a7d3586d18c6",
31+
"GUID:ca4e81cdd6a34d1aa54c32ad41fc5b3b",
32+
"GUID:5ab29fa8ae5769b49ab29e390caca7a4"
3133
],
3234
"includePlatforms": [],
3335
"excludePlatforms": [],

0 commit comments

Comments
 (0)