Skip to content

Commit 54da3d1

Browse files
authored
Merge pull request MicaApps#94 from MicaApps/ruofan
Code cleanup
2 parents b2f4375 + 8cc4420 commit 54da3d1

5 files changed

+325
-370
lines changed

Diff for: Mail/Models/LoadMailMessageOption.cs

+5-13
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@
66
/// 创建者: GaN<br/>
77
/// 创建时间: 2023/06/20
88
/// </summary>
9-
public class LoadMailMessageOption
9+
public sealed class LoadMailMessageOption
1010
{
11-
public LoadMailMessageOption(string FolderId)
12-
{
13-
this.FolderId = FolderId;
14-
}
15-
16-
public LoadMailMessageOption(string FolderId, bool IsFocusedTab)
17-
{
18-
this.FolderId = FolderId;
19-
this.IsFocusedTab = IsFocusedTab;
20-
}
21-
2211
public string FolderId { get; set; }
23-
public bool IsFocusedTab { get; set; } = true;
12+
2413
public int StartIndex { get; set; }
14+
2515
public int LoadCount { get; set; } = 30;
16+
17+
public bool IsFocusedTab { get; set; } = true;
2618
}

Diff for: Mail/Pages/HomePage.xaml.cs

+10-18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.Extensions.DependencyInjection;
66
using Microsoft.Identity.Client;
77
using System;
8+
using System.Collections.Generic;
89
using System.Collections.ObjectModel;
910
using System.Collections.Specialized;
1011
using System.Diagnostics;
@@ -80,34 +81,25 @@ private void HomePage_Loaded(object sender, RoutedEventArgs e)
8081

8182
protected override async void OnNavigatedTo(NavigationEventArgs e)
8283
{
83-
base.OnNavigatedTo(e);
84-
if (e.NavigationMode != NavigationMode.New) return;
85-
// 这是分割线
86-
MailFolderSource.Add(0);
87-
var isFirstOther = true;
84+
MailFolderSource.Add(new NavigationViewItemSeparator());
85+
8886
try
8987
{
90-
// the specified folder could not be found in the store
91-
var orderedAsyncEnumerable = Service.GetMailSuperFoldersAsync()
92-
.OrderBy(item => item.Type);
93-
await foreach (var item in orderedAsyncEnumerable)
88+
IReadOnlyList<MailFolderData> MailFolders = await Service.GetMailSuperFoldersAsync().OrderBy((Data) => Data.Type).ToArrayAsync();
89+
90+
if (MailFolders.Count > 0)
9491
{
95-
if (item.Type == MailFolderType.Other && isFirstOther)
96-
{
97-
// 这是分割线
98-
MailFolderSource.Add(1);
99-
isFirstOther = false;
100-
}
101-
102-
MailFolderSource.Add(item);
92+
MailFolderSource.AddRange(MailFolders.TakeWhile((Data) => Data.Type != MailFolderType.Other));
93+
MailFolderSource.Add(new NavigationViewItemSeparator());
94+
MailFolderSource.AddRange(MailFolders.Skip(MailFolderSource.Count));
10395
}
10496
}
10597
catch (Exception exception)
10698
{
10799
Trace.WriteLine(exception);
108100
}
109101

110-
NavView.SelectedItem = MailFolderSource.FirstOrDefault(item => item is MailFolderData);
102+
NavView.SelectedItem = MailFolderSource.OfType<MailFolderData>().FirstOrDefault();
111103

112104
Service.MailFoldersTree.CollectionChanged += (Sender, Args) =>
113105
{

Diff for: Mail/Pages/MailFolderDetailsPage.xaml

+18-8
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
<WebView HorizontalAlignment="Stretch"
277277
NavigationCompleted="Browser_NavigationCompleted"
278278
DefaultBackgroundColor="Transparent"
279-
NavigationStarting="WebView_OnNavigationStarting"
279+
NavigationStarting="Browser_OnNavigationStarting"
280280
VerticalAlignment="Stretch" />
281281
</StackPanel>
282282
</ScrollViewer>
@@ -304,21 +304,33 @@
304304
BackButtonBehavior="Manual"
305305
Background="Transparent"
306306
DetailsPaneBackground="Transparent"
307-
IsTapEnabled="True"
308307
ListPaneBackground="Transparent"
309308
Loaded="ListDetailsView_Loaded"
310309
NoSelectionContent="Select an item to view"
311310
SelectionChanged="DetailsView_SelectionChanged"
312-
Tapped="ListDetailsView_Tapped"
313311
ViewStateChanged="DetailsView_ViewStateChanged"
314312
DetailsContentTemplateSelector="{StaticResource MailFolderDetailsContentDataTemplateSelector}">
315313
<controls:ListDetailsView.ListHeader>
316314
<Grid>
315+
<Grid.ColumnDefinitions>
316+
<ColumnDefinition Width="*"/>
317+
<ColumnDefinition Width="Auto"/>
318+
</Grid.ColumnDefinitions>
319+
<Grid.RowDefinitions>
320+
<RowDefinition />
321+
<RowDefinition />
322+
</Grid.RowDefinitions>
323+
<TextBlock x:Name="FolderName"
324+
Margin="0,10,0,0"
325+
Grid.ColumnSpan="2"
326+
FontSize="15"
327+
FontWeight="Bold"
328+
VerticalAlignment="Center" />
317329
<muxc:NavigationView x:Name="NavigationTab"
330+
Grid.Row="1"
318331
IsBackButtonVisible="Collapsed"
319332
IsSettingsVisible="False"
320333
SelectionChanged="NavigationView_SelectionChanged"
321-
Visibility="Collapsed"
322334
PaneDisplayMode="Top">
323335
<muxc:NavigationView.MenuItems>
324336
<muxc:NavigationViewItem x:Uid="FocusedTab"
@@ -327,11 +339,9 @@
327339
x:Name="OtherTab" />
328340
</muxc:NavigationView.MenuItems>
329341
</muxc:NavigationView>
330-
<TextBlock x:Name="FolderName"
331-
FontWeight="Bold"
332-
Visibility="Collapsed"
333-
VerticalAlignment="Center" />
334342
<Button Margin="5"
343+
Grid.Row="1"
344+
Grid.Column="1"
335345
HorizontalAlignment="Right"
336346
VerticalAlignment="Center"
337347
Style="{ThemeResource AlternateCloseButtonStyle}"

0 commit comments

Comments
 (0)