Skip to content

Commit

Permalink
TextBlock のスタイルをResourceDictionaryに移動
Browse files Browse the repository at this point in the history
  • Loading branch information
yuto-trd committed Nov 3, 2023
1 parent d62881a commit 6527df3
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/Beutl.Controls/Styles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="/Styling/ButtonStyles.axaml" />
<ResourceInclude Source="/Styling/ComboBoxStyles.axaml" />
<ResourceInclude Source="/Styling/TextBlockStyles.axaml" />
<ResourceInclude Source="/Styling/ToggleSwitchStyles.axaml" />
<ResourceInclude Source="/Styling/ToggleButtonStyles.axaml" />
<ResourceInclude Source="/Styling/SimpleBreadcrumbBar.axaml" />
Expand Down
25 changes: 25 additions & 0 deletions src/Beutl.Controls/Styling/TextBlockStyles.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Design.PreviewWith>
<StackPanel>
<TextBlock Text="Label" Theme="{DynamicResource LabelTextBlockStyle}" />
<TextBlock Text="Error" Theme="{DynamicResource ErrorTextBlockStyle}" />
</StackPanel>
</Design.PreviewWith>

<ControlTheme x:Key="LabelTextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="XamlAutoFontFamily" />
<Setter Property="FontSize" Value="14" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}" />
</ControlTheme>


<ControlTheme x:Key="ErrorTextBlockStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource SystemFillColorCriticalBrush}" />
<Setter Property="FontWeight" Value="SemiBold" />
</ControlTheme>

</ResourceDictionary>
14 changes: 0 additions & 14 deletions src/Beutl/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
<ResourceDictionary>
<aconverters:ColorToBrushConverter x:Key="ColorToBrushConverter" />

<ControlTheme x:Key="LabelTextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="XamlAutoFontFamily" />
<Setter Property="FontSize" Value="14" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}" />
</ControlTheme>

<KeyGesture x:Key="CreateNewProjectKeyGesture">Ctrl+Shift+N</KeyGesture>
<KeyGesture x:Key="CreateNewKeyGesture">Ctrl+N</KeyGesture>
<KeyGesture x:Key="OpenProjectKeyGesture">Ctrl+Shift+O</KeyGesture>
Expand Down Expand Up @@ -64,11 +55,6 @@
</Setter>
</Style>

<Style Selector="TextBlock.error">
<Setter Property="Foreground" Value="{DynamicResource SystemFillColorCriticalBrush}" />
<Setter Property="FontWeight" Value="SemiBold" />
</Style>

<Style Selector="TextBox">
<Setter Property="(TextBoxAttachment.EnterDownBehavior)" Value="Auto" />
</Style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
Theme="{StaticResource LabelTextBlockStyle}" />
<TextBox Text="{CompiledBinding Version.Value}" ToolTip.Tip="{x:Static lang:ExtensionsPage.Release_Version_Tip}" />

<TextBlock Classes="error"
IsVisible="{CompiledBinding Error.Value, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
<TextBlock IsVisible="{CompiledBinding Error.Value, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Text="{CompiledBinding Error.Value}"
TextWrapping="WrapWithOverflow" />
TextWrapping="WrapWithOverflow"
Theme="{StaticResource ErrorTextBlockStyle}" />
</StackPanel>
</ui:ContentDialog>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ProgressBar IsIndeterminate="{Binding IsFileLoading.Value}" IsVisible="{Binding IsFileLoading.Value}" />
</FileInputArea>

<TextBlock Classes="error"
<TextBlock Theme="{StaticResource ErrorTextBlockStyle}"
IsVisible="{Binding Error.Value, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Text="{Binding Error.Value}"
TextWrapping="WrapWithOverflow" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ProgressBar IsIndeterminate="{Binding IsFileLoading.Value}" IsVisible="{Binding IsFileLoading.Value}" />
</FileInputArea>

<TextBlock Classes="error"
<TextBlock Theme="{StaticResource ErrorTextBlockStyle}"
IsVisible="{Binding Error.Value, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Text="{Binding Error.Value}"
TextWrapping="WrapWithOverflow" />
Expand Down
2 changes: 1 addition & 1 deletion src/Beutl/Pages/SettingsPages/SignInScreen.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

<TextBlock MinHeight="16"
Margin="0,16,0,0"
Classes="error"
Theme="{StaticResource ErrorTextBlockStyle}"
Text="{CompiledBinding Error.Value}" />

<Button Height="40"
Expand Down
6 changes: 3 additions & 3 deletions src/Beutl/Views/Dialogs/CreateAsset.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@
<TextBlock Text="{Binding ProgressStatus.Value}" Theme="{StaticResource BodyStrongTextBlockStyle}" />
<ProgressBar Maximum="100" Value="{Binding ProgressValue.Value}" />

<TextBlock Classes="error"
IsVisible="{Binding Error.Value, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
<TextBlock IsVisible="{Binding Error.Value, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Text="{Binding Error.Value}"
TextWrapping="WrapWithOverflow" />
TextWrapping="WrapWithOverflow"
Theme="{StaticResource ErrorTextBlockStyle}" />
</StackPanel>

</Carousel.Items>
Expand Down

0 comments on commit 6527df3

Please sign in to comment.