Skip to content

Commit

Permalink
Merge pull request #17 from strem-app/add-more-tasks
Browse files Browse the repository at this point in the history
Added ability to zoom UI
  • Loading branch information
grofit authored Aug 19, 2022
2 parents e9937cd + 87853d8 commit c92fd1d
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/Strem.Core/Variables/UIVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public class UIVariables
public static readonly VariableEntry ShowHelpersVariable = new VariableEntry("show-helpers", "ui");
public static readonly VariableEntry BackupFrequencyInDays = new VariableEntry("backup.frequency", "ui");
public static readonly VariableEntry LastBackupDate = new VariableEntry("backup.last-run", "ui");
public static readonly VariableEntry ZoomVariable = new VariableEntry("zoom", "ui");
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public async Task StartPlugin()
{
AppState.UserVariables.OnVariableChanged
.Throttle(TimeSpan.FromSeconds(5))
.Subscribe(_ => AppFileHandler.SaveAppState(AppState))
.Subscribe(_ => AppFileHandler.SaveUserState(AppState))
.AddTo(_subs);

AppState.AppVariables.OnVariableChanged
.Throttle(TimeSpan.FromSeconds(5))
.Subscribe(_ => AppFileHandler.SaveUserState(AppState))
.Subscribe(_ => AppFileHandler.SaveAppState(AppState))
.AddTo(_subs);

AppState.UserVariables.OnVariableChanged
Expand Down
68 changes: 57 additions & 11 deletions src/Strem.UI/Pages/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,55 @@
@using Strem.Core.Extensions
@using Strem.Core.Variables

@inject IJSRuntime JS
@inject IAppState AppState;

<div class="container is-fluid">
<h3 class="title is-3">Settings</h3>
<div class="box">
<label class="label is-size-4">UI Settings</label>
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" @bind="ShowHelpers">
Show Helper Text On UI?
</label>

<h3 class="title is-3">Settings</h3>
<div class="box">
<label class="label is-size-4">UI Settings</label>

<div class="field">
<label class="label">Helpers</label>
<div class="control">
<label class="checkbox">
<input type="checkbox" @bind="ShowHelpers">
Show Helper Text On UI?
</label>
</div>
<HelperInfo>This is an example of a helper, if you turn this off you wont see them throughout the system</HelperInfo>
</div>
<HelperInfo>This is an example of a helper, if you turn this off you wont see them throughout the system</HelperInfo>

<div class="field">
<label class="label">Zoom Level</label>
<div class="control">
<nav class="level">
<div class="level-item has-text-left">
<div>
<span class="tag">75%</span>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<span class="tag">100%</span>
</div>
</div>
<div class="level-item has-text-right">
<div>
<span class="tag">125%</span>
</div>
</div>
</nav>
</div>
<div class="control">
<input class="slider is-fullwidth" step="5" min="75" max="125" type="range" @bind="ZoomRate">
</div>
<HelperInfo>This will make everything bigger/smaller throughout the app</HelperInfo>
</div>

</div>
</div>
</div>

@code {
Expand All @@ -31,5 +64,18 @@
set => AppState.AppVariables.Set(UIVariables.ShowHelpersVariable, value);
}

public int ZoomRate
{
get => AppState.AppVariables.Get<int>(UIVariables.ZoomVariable);
set
{
if(value is < 50 or > 150){ return; }
AppState.AppVariables.Set(UIVariables.ZoomVariable, value);
UpdateZoom(value);
}
}

public void UpdateZoom(int newValue)
{ JS.InvokeVoidAsync("setZoom", newValue);}

}
32 changes: 30 additions & 2 deletions src/Strem.UI/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
@inherits LayoutComponentBase
@using Strem.Core.State
@using Strem.Core.Variables
@using Strem.Core.Extensions
@inherits LayoutComponentBase

@inject NavigationManager NavManager
@inject IJSRuntime JS
@inject IAppState AppState;

@implements IDisposable

<section class="hero is-dark is-fullheight">
@if (!IsSplashScreen)
Expand All @@ -26,5 +33,26 @@
@code {

public bool IsSplashScreen => (NavManager.Uri == NavManager.BaseUri);


protected override async Task OnInitializedAsync()
{
UpdateZoom(null, null);
NavManager.LocationChanged += UpdateZoom;
}

private void UpdateZoom(object sender, LocationChangedEventArgs e)
{
if (IsSplashScreen){ return; }
if (!AppState.AppVariables.Has(UIVariables.ZoomVariable)) { return; }

var zoomVar = AppState.AppVariables.Get<int>(UIVariables.ZoomVariable);
if (zoomVar >= 75 && zoomVar <= 125)
{ JS.InvokeVoidAsync("setZoom", zoomVar); }
}

public void Dispose()
{
NavManager.LocationChanged -= UpdateZoom;
}

}
7 changes: 6 additions & 1 deletion src/Strem/wwwroot/css/app-styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,9 @@ body
}

.accordion .paged-content-header .title
{ color: #000; }
{ color: #000; }

.level-item {
&.has-text-left { flex-grow: 0 !important; }
&.has-text-right { flex-grow: 0 !important; }
}
1 change: 1 addition & 0 deletions src/Strem/wwwroot/css/bulma-slider.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Strem/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
<base href="/" />
<link href="css/bulma.css" rel="stylesheet" />
<link href="css/bulma-tooltip.css" rel="stylesheet" />
<link href="css/bulma-slider.css" rel="stylesheet" />
<link href="css/all.css" rel="stylesheet" />
<link href="css/app-styles.less" type="text/css" rel="stylesheet/less" />
</head>
<body>
<div id="app" class="has-background-dark"></div>

<script src="js/less.min.js" ></script>
<script src="js/bulma-slider.js" ></script>
<script src="js/interop-methods.js" ></script>
<script src="_framework/blazor.webview.js"></script>
</body>
</html>
Loading

0 comments on commit c92fd1d

Please sign in to comment.