Skip to content

Commit

Permalink
Remove the need for several styling classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Apr 21, 2024
1 parent a9eb2f7 commit 2b8cd08
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 39 deletions.
5 changes: 5 additions & 0 deletions LightBulb/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
<Setter Property="TextElement.FontStretch" Value="Normal" />
</Style>

<!-- Toggle switch -->
<Style Selector="ToggleButton">
<Setter Property="TextElement.FontWeight" Value="Medium" />
</Style>

<!-- Toggle switch -->
<Style Selector="ToggleSwitch">
<Setter Property="materialAssists:ToggleSwitchAssist.SwitchThumbOffBackground" Value="{DynamicResource MaterialBackgroundBrush}" />
Expand Down
3 changes: 0 additions & 3 deletions LightBulb/ViewModels/Components/DashboardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,6 @@ private void DisableUntilSunrise()
DisableTemporarily(timeUntilSunrise);
}

[RelayCommand]
private void ToggleCyclePreview() => IsCyclePreviewEnabled = !IsCyclePreviewEnabled;

[RelayCommand]
private void ResetConfigurationOffset()
{
Expand Down
58 changes: 22 additions & 36 deletions LightBulb/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,14 @@
Theme="{DynamicResource MaterialIconToggleButton}"
ToolTip.Tip="Toggle LightBulb on/off">
<ToggleButton.Content>
<materialIcons:MaterialIcon
Width="24"
Height="24"
Classes.checked="{Binding $parent[ToggleButton].IsChecked}"
Classes.unchecked="{Binding !$parent[ToggleButton].IsChecked}">
<materialIcons:MaterialIcon Width="24" Height="24">
<materialIcons:MaterialIcon.Styles>
<Style Selector="materialIcons|MaterialIcon">
<Style Selector="^.unchecked">
<Setter Property="Kind" Value="LightbulbOffOutline" />
<Setter Property="Opacity" Value="0.5" />
</Style>
<Style Selector="^.checked">
<Setter Property="Kind" Value="LightbulbOutline" />
</Style>
<Style Selector="ToggleButton materialIcons|MaterialIcon">
<Setter Property="Kind" Value="LightbulbOutline" />
</Style>
<Style Selector="ToggleButton:unchecked materialIcons|MaterialIcon">
<Setter Property="Kind" Value="LightbulbOffOutline" />
<Setter Property="Opacity" Value="0.5" />
</Style>
</materialIcons:MaterialIcon.Styles>
</materialIcons:MaterialIcon>
Expand Down Expand Up @@ -110,36 +104,28 @@
HorizontalAlignment="Center"
Orientation="Horizontal">
<!-- Start/stop cycle preview -->
<Button
<ToggleButton
Margin="8"
Classes.start="{Binding !Dashboard.IsCyclePreviewEnabled}"
Classes.stop="{Binding Dashboard.IsCyclePreviewEnabled}"
Command="{Binding Dashboard.ToggleCyclePreviewCommand}"
Theme="{DynamicResource MaterialFlatButton}">
IsChecked="{Binding Dashboard.IsCyclePreviewEnabled}"
Theme="{DynamicResource MaterialFlatToggleButton}">
<Button.Styles>
<Style Selector="Button">
<Style Selector="^.start">
<Setter Property="ToolTip.Tip" Value="Preview 24-hour cycle" />
</Style>
<Style Selector="^.stop">
<Style Selector="ToggleButton">
<Style Selector="^:checked">
<Setter Property="ToolTip.Tip" Value="Stop preview" />
</Style>
<Style Selector="^:unchecked">
<Setter Property="ToolTip.Tip" Value="Preview 24-hour cycle" />
</Style>
</Style>
</Button.Styles>
<StackPanel Orientation="Horizontal">
<materialIcons:MaterialIcon
Width="24"
Height="24"
Classes.start="{Binding !Dashboard.IsCyclePreviewEnabled}"
Classes.stop="{Binding Dashboard.IsCyclePreviewEnabled}">
<materialIcons:MaterialIcon Width="24" Height="24">
<materialIcons:MaterialIcon.Styles>
<Style Selector="materialIcons|MaterialIcon">
<Style Selector="^.start">
<Setter Property="Kind" Value="PlayCircleOutline" />
</Style>
<Style Selector="^.stop">
<Setter Property="Kind" Value="StopCircleOutline" />
</Style>
<Style Selector="ToggleButton materialIcons|MaterialIcon">
<Setter Property="Kind" Value="PlayCircleOutline" />
</Style>
<Style Selector="ToggleButton:checked materialIcons|MaterialIcon">
<Setter Property="Kind" Value="StopCircleOutline" />
</Style>
</materialIcons:MaterialIcon.Styles>
</materialIcons:MaterialIcon>
Expand All @@ -148,7 +134,7 @@
VerticalAlignment="Center"
Text="PREVIEW" />
</StackPanel>
</Button>
</ToggleButton>

<!-- Settings -->
<Button
Expand Down

0 comments on commit 2b8cd08

Please sign in to comment.