Skip to content

Commit e2be87d

Browse files
committed
update navigation bar
1 parent b925533 commit e2be87d

2 files changed

Lines changed: 120 additions & 98 deletions

File tree

src/Modulus.App/Controls/NavigationBar.axaml

Lines changed: 69 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,28 @@
1313
<UserControl.Resources>
1414
<cv:NavHighlightConverter x:Key="NavHighlightConverter" />
1515
</UserControl.Resources>
16-
<DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="80">
16+
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="80">
17+
<Grid.RowDefinitions>
18+
<RowDefinition Height="Auto" />
19+
<!-- Header -->
20+
<RowDefinition Height="*" />
21+
<!-- Body -->
22+
<RowDefinition Height="Auto" />
23+
<!-- Footer -->
24+
</Grid.RowDefinitions>
25+
1726
<!-- Header -->
18-
<StackPanel DockPanel.Dock="Top" Spacing="8" Margin="0,16,0,0" HorizontalAlignment="Center">
27+
<StackPanel Grid.Row="0" Margin="0,16,0,0" HorizontalAlignment="Center">
1928
<Image Source="avares://Modulus.App/Assets/avalonia-logo.ico" Width="32" Height="32" Stretch="Uniform"/>
2029
<TextBlock Text="Modulus" FontSize="16" FontWeight="Bold" Foreground="#3B82F6" HorizontalAlignment="Center"/>
2130
<TextBlock Text="v1.0.0" FontSize="11" Foreground="#888" HorizontalAlignment="Center"/>
2231
<!-- Header Items -->
2332
<ItemsControl ItemsSource="{Binding HeaderItems}">
33+
<ItemsControl.ItemsPanel>
34+
<ItemsPanelTemplate>
35+
<StackPanel Spacing="8"/>
36+
</ItemsPanelTemplate>
37+
</ItemsControl.ItemsPanel>
2438
<ItemsControl.ItemTemplate>
2539
<DataTemplate x:DataType="vm:NavigationMenuItemViewModel">
2640
<Button Background="{Binding IsActive, Converter={StaticResource NavHighlightConverter}}"
@@ -44,53 +58,59 @@
4458
</StackPanel>
4559

4660
<!-- Body: Main Menu Items -->
47-
<StackPanel DockPanel.Dock="Top" Spacing="8" Margin="0,32,0,0" HorizontalAlignment="Center">
48-
<ItemsControl ItemsSource="{Binding BodyItems}">
49-
<ItemsControl.ItemTemplate>
50-
<DataTemplate x:DataType="vm:NavigationMenuItemViewModel">
51-
<Button Background="{Binding IsActive, Converter={StaticResource NavHighlightConverter}}"
52-
Foreground="White"
53-
ToolTip.Tip="{Binding Tooltip}"
54-
Width="{Binding Width}"
55-
Height="{Binding Height}"
56-
CornerRadius="{Binding CornerRadius}"
57-
Command="{Binding Command}"
58-
Margin="0,0,0,4">
59-
<StackPanel>
60-
<TextBlock Text="{Binding Icon}"
61-
FontFamily="Segoe MDL2 Assets"
62-
FontSize="{Binding FontSize}"
63-
HorizontalAlignment="Center"/>
64-
</StackPanel>
65-
</Button>
66-
</DataTemplate>
67-
</ItemsControl.ItemTemplate>
68-
</ItemsControl>
69-
</StackPanel>
61+
<ItemsControl Grid.Row="1" ItemsSource="{Binding BodyItems}" Margin="0,32,0,0" HorizontalAlignment="Center">
62+
<ItemsControl.ItemsPanel>
63+
<ItemsPanelTemplate>
64+
<StackPanel Spacing="8"/>
65+
</ItemsPanelTemplate>
66+
</ItemsControl.ItemsPanel>
67+
<ItemsControl.ItemTemplate>
68+
<DataTemplate x:DataType="vm:NavigationMenuItemViewModel">
69+
<Button Background="{Binding IsActive, Converter={StaticResource NavHighlightConverter}}"
70+
Foreground="White"
71+
ToolTip.Tip="{Binding Tooltip}"
72+
Width="{Binding Width}"
73+
Height="{Binding Height}"
74+
CornerRadius="{Binding CornerRadius}"
75+
Command="{Binding Command}"
76+
Margin="0,0,0,4">
77+
<StackPanel>
78+
<TextBlock Text="{Binding Icon}"
79+
FontFamily="Segoe MDL2 Assets"
80+
FontSize="{Binding FontSize}"
81+
HorizontalAlignment="Center"/>
82+
</StackPanel>
83+
</Button>
84+
</DataTemplate>
85+
</ItemsControl.ItemTemplate>
86+
</ItemsControl>
7087

7188
<!-- Footer: Settings/User/Feedback etc. -->
72-
<StackPanel DockPanel.Dock="Bottom" Spacing="8" Margin="0,0,0,24" HorizontalAlignment="Center">
73-
<ItemsControl ItemsSource="{Binding FooterItems}">
74-
<ItemsControl.ItemTemplate>
75-
<DataTemplate x:DataType="vm:NavigationMenuItemViewModel">
76-
<Button Background="{Binding IsActive, Converter={StaticResource NavHighlightConverter}}"
77-
Foreground="White"
78-
ToolTip.Tip="{Binding Tooltip}"
79-
Width="{Binding Width}"
80-
Height="{Binding Height}"
81-
CornerRadius="{Binding CornerRadius}"
82-
Command="{Binding Command}"
83-
Margin="0,0,0,4">
84-
<StackPanel>
85-
<TextBlock Text="{Binding Icon}"
86-
FontFamily="Segoe MDL2 Assets"
87-
FontSize="{Binding FontSize}"
88-
HorizontalAlignment="Center"/>
89-
</StackPanel>
90-
</Button>
91-
</DataTemplate>
92-
</ItemsControl.ItemTemplate>
93-
</ItemsControl>
94-
</StackPanel>
95-
</DockPanel>
89+
<ItemsControl Grid.Row="2" ItemsSource="{Binding FooterItems}" Margin="0,0,0,24" HorizontalAlignment="Center">
90+
<ItemsControl.ItemsPanel>
91+
<ItemsPanelTemplate>
92+
<StackPanel Spacing="8"/>
93+
</ItemsPanelTemplate>
94+
</ItemsControl.ItemsPanel>
95+
<ItemsControl.ItemTemplate>
96+
<DataTemplate x:DataType="vm:NavigationMenuItemViewModel">
97+
<Button Background="{Binding IsActive, Converter={StaticResource NavHighlightConverter}}"
98+
Foreground="White"
99+
ToolTip.Tip="{Binding Tooltip}"
100+
Width="{Binding Width}"
101+
Height="{Binding Height}"
102+
CornerRadius="{Binding CornerRadius}"
103+
Command="{Binding Command}"
104+
Margin="0,0,0,4">
105+
<StackPanel>
106+
<TextBlock Text="{Binding Icon}"
107+
FontFamily="Segoe MDL2 Assets"
108+
FontSize="{Binding FontSize}"
109+
HorizontalAlignment="Center"/>
110+
</StackPanel>
111+
</Button>
112+
</DataTemplate>
113+
</ItemsControl.ItemTemplate>
114+
</ItemsControl>
115+
</Grid>
96116
</UserControl>

src/Modulus.App/ViewModels/MainViewModel.cs

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,37 @@ public partial class MainViewModel : ObservableObject
1818
[ObservableProperty] private bool isNotificationsActive;
1919
[ObservableProperty] private bool isSettingsActive;
2020
[ObservableProperty] private bool isProfileActive;
21-
22-
[ObservableProperty] private NavigationBarViewModel navigationBar; public MainViewModel()
21+
22+
[ObservableProperty] private NavigationBarViewModel navigationBar;
23+
public MainViewModel()
2324
{
2425
navigationBar = new NavigationBarViewModel();
25-
26+
2627
// Create the navigation service and connect it to this view model
2728
var navigationService = new NavigationPluginService(navigationBar);
2829
navigationService.SetMainViewModel(this);
29-
30+
3031
// Create the plugin manager with the navigation service
3132
_pluginManager = new PluginManager(navigationBar, navigationService);
32-
33+
3334
InitializeNavigationMenus();
3435
ShowDashboard();
35-
36+
3637
// Auto-load plugins in background
3738
Task.Run(async () => await LoadPluginsAsync());
3839
} /// <summary>
39-
/// Loads plugins from the default plugins directory.
40-
/// </summary>
40+
/// Loads plugins from the default plugins directory.
41+
/// </summary>
4142
private async Task LoadPluginsAsync()
4243
{
4344
try
4445
{
4546
// In a real implementation, this would use a configuration setting
4647
const string pluginsPath = @"c:\FileStorage\Projects\Modulus\tools\modulus-plugin";
47-
48+
4849
// Load the simple plugin example for testing
4950
await _pluginManager.LoadPluginsAsync(pluginsPath);
50-
51+
5152
// For testing, manually add our SimplePluginExample
5253
_pluginManager.AddTestPlugins();
5354
}
@@ -63,55 +64,55 @@ private async Task LoadPluginsAsync()
6364
private void InitializeNavigationMenus()
6465
{
6566
// Initialize body menu items
66-
NavigationBar.BodyItems.Add(new NavigationMenuItemViewModel
67-
{
68-
Icon = "\uE80F",
69-
Tooltip = "Dashboard",
67+
NavigationBar.BodyItems.Add(new NavigationMenuItemViewModel
68+
{
69+
Icon = "\uE80F",
70+
Tooltip = "Dashboard",
7071
Command = ShowDashboardCommand,
71-
IsActive = true
72+
IsActive = true
7273
});
73-
74-
NavigationBar.BodyItems.Add(new NavigationMenuItemViewModel
75-
{
76-
Icon = "\uE721",
77-
Tooltip = "Plugin Manager",
78-
Command = ShowPluginManagerCommand
74+
75+
NavigationBar.BodyItems.Add(new NavigationMenuItemViewModel
76+
{
77+
Icon = "\uE721",
78+
Tooltip = "Plugin Manager",
79+
Command = ShowPluginManagerCommand
7980
});
80-
81-
NavigationBar.BodyItems.Add(new NavigationMenuItemViewModel
82-
{
83-
Icon = "\uE7E7",
84-
Tooltip = "Notifications",
85-
Command = ShowNotificationsCommand
81+
82+
NavigationBar.BodyItems.Add(new NavigationMenuItemViewModel
83+
{
84+
Icon = "\uE7E7",
85+
Tooltip = "Notifications",
86+
Command = ShowNotificationsCommand
8687
});
8788

8889
// Initialize footer menu items
89-
NavigationBar.FooterItems.Add(new NavigationMenuItemViewModel
90-
{
91-
Icon = "\uE713",
92-
Tooltip = "Settings",
90+
NavigationBar.FooterItems.Add(new NavigationMenuItemViewModel
91+
{
92+
Icon = "\uE713",
93+
Tooltip = "Settings",
9394
Command = ShowSettingsCommand,
9495
Width = 48,
9596
Height = 48,
9697
CornerRadius = 10,
9798
FontSize = 22
9899
});
99100

100-
NavigationBar.FooterItems.Add(new NavigationMenuItemViewModel
101-
{
102-
Icon = "\uE939",
103-
Tooltip = "Feedback",
101+
NavigationBar.FooterItems.Add(new NavigationMenuItemViewModel
102+
{
103+
Icon = "\uE939",
104+
Tooltip = "Feedback",
104105
Command = new RelayCommand(ShowFeedback),
105106
Width = 48,
106107
Height = 48,
107108
CornerRadius = 10,
108109
FontSize = 22
109110
});
110111

111-
NavigationBar.FooterItems.Add(new NavigationMenuItemViewModel
112-
{
113-
Icon = "\uE77B",
114-
Tooltip = "Profile",
112+
NavigationBar.FooterItems.Add(new NavigationMenuItemViewModel
113+
{
114+
Icon = "\uE77B",
115+
Tooltip = "Profile",
115116
Command = ShowProfileCommand,
116117
Width = 48,
117118
Height = 48,
@@ -129,7 +130,7 @@ private void UpdateNavigationMenuActiveState()
129130
{
130131
item.IsActive = false;
131132
}
132-
133+
133134
foreach (var item in NavigationBar.BodyItems)
134135
{
135136
if (item.Tooltip == "Dashboard") item.IsActive = IsDashboardActive;
@@ -153,38 +154,39 @@ private void ShowDashboard()
153154
CurrentView = new DashboardPlaceholderViewModel();
154155
UpdateNavigationMenuActiveState();
155156
}
156-
157+
157158
[RelayCommand]
158159
private void ShowPluginManager()
159160
{
160161
SetActive("plugin");
161162
CurrentView = new PluginManagerViewModel(_pluginManager);
162163
UpdateNavigationMenuActiveState();
163164
}
164-
165+
165166
[RelayCommand]
166167
private void ShowNotifications()
167168
{
168169
SetActive("notifications");
169170
CurrentView = new NotificationsPlaceholderViewModel();
170171
UpdateNavigationMenuActiveState();
171172
}
172-
173+
173174
[RelayCommand]
174175
private void ShowSettings()
175176
{
176177
SetActive("settings");
177178
CurrentView = new SettingsPlaceholderViewModel();
178179
UpdateNavigationMenuActiveState();
179180
}
180-
181+
181182
[RelayCommand]
182183
private void ShowProfile()
183184
{
184185
SetActive("profile");
185186
CurrentView = new ProfilePlaceholderViewModel();
186187
UpdateNavigationMenuActiveState();
187-
} private void ShowFeedback()
188+
}
189+
private void ShowFeedback()
188190
{
189191
// TODO: Implement feedback functionality
190192
}
@@ -204,7 +206,7 @@ public void SetActive(string key)
204206
}
205207

206208
// 占位 ViewModel
207-
public class DashboardPlaceholderViewModel {}
208-
public class NotificationsPlaceholderViewModel {}
209-
public class SettingsPlaceholderViewModel {}
210-
public class ProfilePlaceholderViewModel {}
209+
public class DashboardPlaceholderViewModel { }
210+
public class NotificationsPlaceholderViewModel { }
211+
public class SettingsPlaceholderViewModel { }
212+
public class ProfilePlaceholderViewModel { }

0 commit comments

Comments
 (0)