Skip to content

Commit 38e6465

Browse files
committed
CQ: Add FlowDirectionChanged event
1 parent 31440a4 commit 38e6465

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Files.App/Data/Contracts/IRealTimeLayoutService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ namespace Files.App.Data.Contracts
1111
/// </summary>
1212
public interface IRealTimeLayoutService
1313
{
14+
/// <summary>
15+
/// Occurs when the flow direction of the layout changes.
16+
/// </summary>
17+
public event EventHandler<FlowDirection>? FlowDirectionChanged;
18+
1419
/// <summary>
1520
/// Gets the current flow direction for layout (e.g., LeftToRight or RightToLeft).
1621
/// </summary>

src/Files.App/Services/Content/RealTimeLayoutService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ internal sealed class RealTimeLayoutService : IRealTimeLayoutService
2121
/// </summary>
2222
private readonly List<(WeakReference<object> Reference, Action Callback)> _callbacks = [];
2323

24+
/// <inheritdoc/>
25+
public event EventHandler<FlowDirection>? FlowDirectionChanged;
26+
2427
/// <inheritdoc/>
2528
public FlowDirection FlowDirection => CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
2629

@@ -122,6 +125,8 @@ private void InvokeCallbacks()
122125
item.Reference.TryGetTarget(out var targetObject) && targetObject != null)
123126
.Select(item => item.Callback).ForEach(callback => callback());
124127
_callbacks.RemoveAll(item => !item.Reference.TryGetTarget(out _));
128+
129+
FlowDirectionChanged?.Invoke(this, FlowDirection);
125130
}
126131
}
127132
}

0 commit comments

Comments
 (0)