瀏覽代碼

Fixed theming of text box and Searchbar

Kenric Nugteren 4 月之前
父節點
當前提交
9617abdb1e

+ 11 - 8
InABox.Avalonia/Components/MenuPanel/AvaloniaMenuItem.cs

@@ -66,15 +66,18 @@ public partial class AvaloniaMenuItem : ObservableObject
 
             else if (sourceItem is CoreMenuItem<IImage> item)
             {
-                var targetItem = new MenuItem
+                if(item.IsVisible is null || item.IsVisible())
                 {
-                    Header = item.Header,
-                    Icon = new Image { Source = item.Image },
-                    Command = item.Action != null
-                        ? new RelayCommand(() => item.Action())
-                        : null
-                };
-                targetItems.Add(targetItem);
+                    var targetItem = new MenuItem
+                    {
+                        Header = item.Header,
+                        Icon = new Image { Source = item.Image },
+                        Command = item.Action != null
+                            ? new RelayCommand(() => item.Action())
+                            : null
+                    };
+                    targetItems.Add(targetItem);
+                }
             }
             else if (sourceItem is CoreMenuHeader<IImage> header)
             {

+ 3 - 1
InABox.Avalonia/Components/SearchBar/SearchBar.axaml

@@ -7,6 +7,7 @@
              x:Class="InABox.Avalonia.Components.SearchBar"
 			 x:DataType="components:SearchBar">
 	<Border Background="{StaticResource PrsTileBackground}"
+			BorderThickness="{StaticResource PrsBorderThickness}"
 			BorderBrush="{StaticResource PrsTileBorder}"
 			CornerRadius="{StaticResource PrsCornerRadius}"
 			Height="40"
@@ -28,7 +29,8 @@
 					 Background="Transparent"
 					 Margin="0"
 					 BorderBrush="Transparent"
-					 BorderThickness="0"/>
+					 BorderThickness="0">
+			</TextBox>
 		</Grid>
 	</Border>
 </UserControl>

+ 1 - 0
InABox.Avalonia/DataModels/CoreRepository.cs

@@ -477,6 +477,7 @@ namespace InABox.Avalonia
                     Dispatcher.UIThread.Post(() => OnPropertyChanged(nameof(FiltersVisible)));
                 }
                 
+
                 DoBeforeLoad();
                 BeforeLoad(_query);
                 

+ 1 - 1
InABox.Avalonia/Theme/Classes/Border.axaml

@@ -1,7 +1,7 @@
 <Styles xmlns="https://github.com/avaloniaui"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 
-    <Style Selector="Border">
+    <Style Selector="Border.Standard">
         <Setter Property="BorderBrush" Value="{DynamicResource PrsTileBorder}" />
         <Setter Property="BorderThickness">
             <Setter.Value>

+ 9 - 15
InABox.Avalonia/Theme/Classes/TextBox.axaml

@@ -1,14 +1,12 @@
 <Styles xmlns="https://github.com/avaloniaui"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
-
     <Style Selector="TextBox">
-        <Setter Property="BorderThickness" Value="0" />
-        <!-- <Setter Property="BorderBrush" Value="{DynamicResource PrsTileBorder}" /> -->
-        <!-- <Setter Property="BorderThickness"> -->
-        <!--     <Setter.Value> -->
-        <!--         <DynamicResource ResourceKey="PrsBorderThickness" /> -->
-        <!--     </Setter.Value> -->
-        <!-- </Setter> -->
+        <Setter Property="BorderBrush" Value="{DynamicResource PrsTileBorder}" />
+        <Setter Property="BorderThickness">
+            <Setter.Value>
+                <DynamicResource ResourceKey="PrsBorderThickness" />
+            </Setter.Value>
+        </Setter>
         <Setter Property="Background" Value="{DynamicResource PrsTileBackground}" />
         <Setter Property="Foreground" Value="{DynamicResource PrsTileForeground}" />
         <Setter Property="CornerRadius" Value="{DynamicResource PrsCornerRadius}" />
@@ -34,12 +32,8 @@
     </Style>
     
     <Style Selector="TextBox:focus /template/ Border#PART_BorderElement">
-        <Setter Property="BorderThickness" Value="0" />
-        <Setter Property="Background" Value="{DynamicResource PrsTileBackground}" />
+        <Setter Property="BorderBrush" Value="{TemplateBinding BorderBrush}" />
+		<Setter Property="BorderThickness" Value="{TemplateBinding BorderThickness}"/>
+        <Setter Property="Background" Value="{TemplateBinding Background}" />
     </Style>
-
-
-
-
-
 </Styles>

+ 4 - 4
InABox.Core/CoreMenu/CoreMenu.cs

@@ -9,16 +9,16 @@ namespace InABox.Core
     {
         public List<ICoreMenuItem> Items { get; } = new List<ICoreMenuItem>();
 
-        public CoreMenu<T> AddItem(string header, T? image, Func<Task<bool>> action)
+        public CoreMenu<T> AddItem(string header, T? image, Func<Task<bool>> action, Func<bool>? isVisible = null)
         {
-            var result = new CoreMenuItem<T>(header, image, action);
+            var result = new CoreMenuItem<T>(header, image, action, isVisible);
             Items.Add(result);
             return this;
         }
 
-        public CoreMenu<T> AddItem(string header, Func<Task<bool>> action)
+        public CoreMenu<T> AddItem(string header, Func<Task<bool>> action, Func<bool>? isVisible = null)
         {
-            var result = new CoreMenuItem<T>(header, null, action);
+            var result = new CoreMenuItem<T>(header, null, action, isVisible);
             Items.Add(result);
             return this;
         }

+ 4 - 1
InABox.Core/CoreMenu/CoreMenuItem.cs

@@ -9,11 +9,14 @@ namespace InABox.Core
         public T? Image { get; set; }
         public Func<Task<bool>>? Action { get; set; }
 
-        public CoreMenuItem(string header, T? image = null, Func<Task<bool>>? action = null)
+        public Func<bool>? IsVisible { get; set; }
+
+        public CoreMenuItem(string header, T? image = null, Func<Task<bool>>? action = null, Func<bool>? isVisible = null)
         {
             Header = header;
             Image = image;
             Action = action;
+            IsVisible = isVisible;
         }
     }
 }