Neighbourhood.omg.lol/Components/Layout/MainLayout.razor

36 lines
1,019 B
Text
Raw Normal View History

2024-05-30 01:06:08 +00:00
@inherits LayoutComponentBase
@implements IDisposable
@inject NavigatorService NavigatorService
@inject NavigationManager NavigationManager
@inject State State
<NavMenu />
<main class="responsive max">
@Body
</main>
@code {
protected override void OnInitialized() {
base.OnInitialized();
NavigatorService.NavigationManager = NavigationManager;
State.IntentReceived += IntentRecieved;
if (!string.IsNullOrEmpty(State.ShareString) || !string.IsNullOrEmpty(State.SharePhoto)) {
IntentRecieved();
}
}
private void IntentRecieved(object? sender = null, EventArgs? e = null) {
if (!string.IsNullOrEmpty(State.ShareString)) {
NavigationManager.NavigateTo($"/sharetext/{State.ShareString}");
State.ShareString = null;
}
else if (!string.IsNullOrEmpty(State.SharePhoto)) {
NavigationManager.NavigateTo($"/sharepic/{State.SharePhoto}");
2024-06-18 01:43:38 +00:00
State.SharePhoto = null;
}
}
void IDisposable.Dispose() {
State.IntentReceived -= IntentRecieved;
}
}