Skip to content

Commit

Permalink
Add: Add setting selection front end
Browse files Browse the repository at this point in the history
  • Loading branch information
whats2000 committed Sep 7, 2024
1 parent c0f0c01 commit 70cd8b4
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Shared/EditSettingSlideBar.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Paragraph>
Not Implemented Yet
</Paragraph>
7 changes: 7 additions & 0 deletions Shared/EditSettingSlideBar.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Microsoft.AspNetCore.Components;

namespace PearlCalculatorBlazor.Shared;

public partial class EditSettingSlideBar : ComponentBase
{
}
58 changes: 51 additions & 7 deletions Shared/SharedHeader.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,49 @@
<Flex Align="center" Gap="10" Justify="center" Wrap="wrap" Style="height: 100%;">
<Dropdown Placement="Placement.BottomRight">
<Overlay>
<Menu DefaultSelectedKeys=@(new[] { "en" })>
<MenuItem @onclick="@(() => OnClickChangeLanguage("en"))" Key="en">@TranslateText.LanguageDict["en"]</MenuItem>
<Menu SelectedKeys="@(new[] { _selectedValue })">
@foreach (var name in _settingsList)
{
<MenuItem
Icon="@IconType.Outline.Swap"
@key=name
@onclick="@(() => OnSelectSettings(name))">
<ChildContent>
<Text Style="margin-left: 10px;">@name</Text>
</ChildContent>
</MenuItem>
}
<MenuItem
Icon="@IconType.Outline.Tool"
@onclick="OnEditSettings">
<ChildContent>
<Text Style="margin-left: 10px;">
@TranslateText.GetTranslateText("EditCannonSettings")
</Text>
</ChildContent>
</MenuItem>
</Menu>
</Overlay>
<ChildContent>
<Button
Shape="@ButtonShape.Round"
Type="@ButtonType.Default"
Size="Large"
Icon="@IconType.Outline.Swap">
@_selectedValue
</Button>
</ChildContent>
</Dropdown>
<Dropdown Placement="Placement.BottomRight">
<Overlay>
<Menu DefaultSelectedKeys="@(new[] { TranslateText.GetCurrentLanguage() })">
@foreach (var pair in TranslateText.LanguageDict)
{
if (pair.Key == "en")
continue;
<MenuItem @onclick="@(() => OnClickChangeLanguage(pair.Key))" @key=pair.Key>@pair.Value</MenuItem>
<MenuItem @onclick="@(() => OnClickChangeLanguage(pair.Key))" @key=pair.Key>
<ChildContent>
@pair.Value
</ChildContent>
</MenuItem>
}
</Menu>
</Overlay>
Expand All @@ -38,7 +74,7 @@
Shape="@ButtonShape.Round"
Type="@ButtonType.Default"
Size="Large"
Icon="translation">
Icon="@IconType.Outline.Translation">
Language
</Button>
</ChildContent>
Expand Down Expand Up @@ -95,4 +131,12 @@
}
</ul>
</Paragraph>
</Modal>
</Modal>

<Drawer
Title="@TranslateText.GetTranslateText("EditCannonSettings")"
Visible="@_editSettingsVisible"
OnClose="@OnCloseEditSettings"
Placement="left">
<EditSettingSlideBar/>
</Drawer>
24 changes: 24 additions & 0 deletions Shared/SharedHeader.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public partial class SharedHeader
private string _currentVersion = "Loading...";
private string _latestVersion;
private string _modalContent = "";
private string _selectedValue = "Default Cannon";
private bool _editSettingsVisible = false;

private List<string> _settingsList = new()
{
"Default Cannon"
};

private string[] _updateNotes = Array.Empty<string>();
private bool _visible = false;
[Inject] private IJSRuntime JsRuntime { get; set; }
Expand Down Expand Up @@ -91,6 +99,22 @@ protected Theme CurrentTheme
}
}

private void OnSelectSettings(string value)
{
_selectedValue = value;
StateHasChanged();
}

private void OnEditSettings()
{
_editSettingsVisible = true;
}

private void OnCloseEditSettings()
{
_editSettingsVisible = false;
}

private void ShowVersionModal(string[] updateNotes)
{
_modalContent = TranslateText.GetTranslateText("NewVersionFound")
Expand Down
1 change: 1 addition & 0 deletions wwwroot/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"DisplayYMotion": "Y Motion",
"DisplayZMotion": "Z Motion",
"East": "East",
"EditCannonSettings": "Edit Cannon Settings",
"GeneralFtlAdvanced": "Advanced",
"GeneralFtlGeneral": "General",
"GeneralFtlSettings": "Settings",
Expand Down
1 change: 1 addition & 0 deletions wwwroot/assets/i18n/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"DisplayYMotion": "Vel. Y",
"DisplayZMotion": "Vel. Z",
"East": "Este",
"EditCannonSettings": "Editar Configuración de Cañón",
"GeneralFtlAdvanced": "Avanzado",
"GeneralFtlGeneral": "General",
"GeneralFtlSettings": "Configuración",
Expand Down
1 change: 1 addition & 0 deletions wwwroot/assets/i18n/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"DisplayXMotion": "X矢量",
"DisplayYMotion": "Y矢量",
"DisplayZMotion": "Z矢量",
"EditCannonSettings": "编辑炮台设置",
"GeneralFtlAdvanced": "进阶选项",
"GeneralFtlGeneral": "一般选项",
"GeneralFtlSettings": "更多基础选项",
Expand Down
1 change: 1 addition & 0 deletions wwwroot/assets/i18n/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"DisplayXMotion": "X動量",
"DisplayYMotion": "Y動量",
"DisplayZMotion": "Z動量",
"EditCannonSettings": "編輯炮台設定",
"GeneralFtlAdvanced": "進階設定",
"GeneralFtlGeneral": "一般設定",
"GeneralFtlSettings": "更多基礎設定",
Expand Down

0 comments on commit 70cd8b4

Please sign in to comment.