Skip to content

Commit fb27f40

Browse files
authored
Started work on widgets (#1384)
1 parent 69ae24b commit fb27f40

File tree

7 files changed

+584
-500
lines changed

7 files changed

+584
-500
lines changed

Files/Files.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@
228228
<Compile Include="UserControls\StatusCenter.xaml.cs">
229229
<DependentUpon>StatusCenter.xaml</DependentUpon>
230230
</Compile>
231+
<Compile Include="UserControls\Widgets\LibraryCards.xaml.cs">
232+
<DependentUpon>LibraryCards.xaml</DependentUpon>
233+
</Compile>
234+
<Compile Include="UserControls\Widgets\RecentFiles.xaml.cs">
235+
<DependentUpon>RecentFiles.xaml</DependentUpon>
236+
</Compile>
231237
<Compile Include="View Models\CurrentInstanceViewModel.cs" />
232238
<Compile Include="View Models\ItemViewModel.cs" />
233239
<Compile Include="Filesystem\ListedItem.cs" />
@@ -441,6 +447,14 @@
441447
<SubType>Designer</SubType>
442448
<Generator>MSBuild:Compile</Generator>
443449
</Page>
450+
<Page Include="UserControls\Widgets\LibraryCards.xaml">
451+
<Generator>MSBuild:Compile</Generator>
452+
<SubType>Designer</SubType>
453+
</Page>
454+
<Page Include="UserControls\Widgets\RecentFiles.xaml">
455+
<Generator>MSBuild:Compile</Generator>
456+
<SubType>Designer</SubType>
457+
</Page>
444458
<Page Include="Views\LayoutModes\GenericFileBrowser.xaml">
445459
<SubType>Designer</SubType>
446460
<Generator>MSBuild:Compile</Generator>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<UserControl
2+
x:Class="Files.LibraryCards"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:list="using:Locations"
8+
xmlns:local="using:Files"
9+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
11+
mc:Ignorable="d">
12+
<UserControl.Resources>
13+
<Style
14+
x:Key="AdaptiveGridViewItemContainerStyle2"
15+
BasedOn="{StaticResource GridViewItemExpanded}"
16+
TargetType="GridViewItem">
17+
<Setter Property="Background" Value="Transparent" />
18+
<Setter Property="BorderThickness" Value="0" />
19+
<Setter Property="CornerRadius" Value="4" />
20+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
21+
<Setter Property="VerticalContentAlignment" Value="Stretch" />
22+
<Setter Property="Margin" Value="0,0,8,0" />
23+
</Style>
24+
</UserControl.Resources>
25+
26+
<Grid>
27+
<controls:AdaptiveGridView
28+
x:Name="CardsList"
29+
Grid.Row="0"
30+
HorizontalAlignment="Stretch"
31+
DesiredWidth="100"
32+
IsItemClickEnabled="True"
33+
ItemContainerStyle="{StaticResource AdaptiveGridViewItemContainerStyle2}"
34+
ItemHeight="90"
35+
ItemsSource="{x:Bind list:ItemLoader.itemsAdded}"
36+
OneRowModeEnabled="True"
37+
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
38+
SelectionMode="None"
39+
StretchContentForSingleRow="True">
40+
<controls:AdaptiveGridView.ItemTemplate>
41+
<DataTemplate x:DataType="list:FavoriteLocationItem">
42+
<Grid>
43+
<Grid>
44+
<Grid.Resources>
45+
<ResourceDictionary>
46+
<ResourceDictionary.ThemeDictionaries>
47+
<ResourceDictionary x:Name="Light">
48+
<SolidColorBrush x:Key="YourHomeCardBackgroundColor" Color="#f3f1ef" />
49+
</ResourceDictionary>
50+
<ResourceDictionary x:Name="Dark">
51+
<SolidColorBrush x:Key="YourHomeCardBackgroundColor" Color="Black" />
52+
</ResourceDictionary>
53+
<ResourceDictionary x:Name="HighContrast">
54+
<SolidColorBrush x:Key="YourHomeCardBackgroundColor" Color="Black" />
55+
</ResourceDictionary>
56+
</ResourceDictionary.ThemeDictionaries>
57+
</ResourceDictionary>
58+
</Grid.Resources>
59+
<Button
60+
Padding="0"
61+
HorizontalAlignment="Stretch"
62+
VerticalAlignment="Stretch"
63+
HorizontalContentAlignment="Stretch"
64+
VerticalContentAlignment="Stretch"
65+
Background="{ThemeResource YourHomeCardBackgroundColor}"
66+
BorderThickness="1"
67+
Click="Button_Click"
68+
CornerRadius="4"
69+
Style="{StaticResource ButtonRevealStyle}"
70+
Tag="{x:Bind Tag}">
71+
72+
<Grid
73+
Margin="8,14"
74+
HorizontalAlignment="Stretch"
75+
VerticalAlignment="Stretch"
76+
RowSpacing="2">
77+
<Grid.RowDefinitions>
78+
<RowDefinition Height="*" />
79+
<RowDefinition Height="Auto" />
80+
</Grid.RowDefinitions>
81+
<FontIcon
82+
Grid.Row="0"
83+
HorizontalAlignment="Stretch"
84+
VerticalAlignment="Stretch"
85+
FontSize="28"
86+
Glyph="{x:Bind Icon}" />
87+
<TextBlock
88+
x:Name="ItemLocationName"
89+
Grid.Row="1"
90+
HorizontalAlignment="Stretch"
91+
VerticalAlignment="Stretch"
92+
FontSize="14"
93+
FontWeight="Medium"
94+
HorizontalTextAlignment="Center"
95+
Text="{x:Bind Text}"
96+
TextWrapping="WrapWholeWords" />
97+
</Grid>
98+
</Button>
99+
</Grid>
100+
</Grid>
101+
</DataTemplate>
102+
</controls:AdaptiveGridView.ItemTemplate>
103+
</controls:AdaptiveGridView>
104+
</Grid>
105+
</UserControl>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Files.View_Models;
2+
using Windows.UI.Xaml;
3+
using Windows.UI.Xaml.Controls;
4+
5+
namespace Files
6+
{
7+
public sealed partial class LibraryCards : UserControl
8+
{
9+
public SettingsViewModel AppSettings => App.AppSettings;
10+
11+
public LibraryCards()
12+
{
13+
InitializeComponent();
14+
15+
Locations.ItemLoader.itemsAdded.Clear();
16+
Locations.ItemLoader.DisplayItems();
17+
}
18+
19+
private void Button_Click(object sender, RoutedEventArgs e)
20+
{
21+
string NavigationPath = ""; // path to navigate
22+
string ClickedCard = (sender as Button).Tag.ToString();
23+
24+
switch (ClickedCard)
25+
{
26+
case "Downloads":
27+
NavigationPath = AppSettings.DownloadsPath;
28+
break;
29+
30+
case "Documents":
31+
NavigationPath = AppSettings.DocumentsPath;
32+
break;
33+
34+
case "Pictures":
35+
NavigationPath = AppSettings.PicturesPath;
36+
break;
37+
38+
case "Music":
39+
NavigationPath = AppSettings.MusicPath;
40+
break;
41+
42+
case "Videos":
43+
NavigationPath = AppSettings.VideosPath;
44+
break;
45+
46+
case "RecycleBin":
47+
NavigationPath = AppSettings.RecycleBinPath;
48+
break;
49+
}
50+
51+
App.CurrentInstance.ContentFrame.Navigate(AppSettings.GetLayoutType(), NavigationPath);
52+
53+
App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome = true; // show controls that were hidden on the home page
54+
}
55+
}
56+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<UserControl
2+
x:Class="Files.RecentFiles"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:list="using:Locations"
8+
xmlns:local="using:Files"
9+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
11+
mc:Ignorable="d">
12+
<UserControl.Resources>
13+
<Style
14+
x:Key="ListViewItemContainerStyle1"
15+
BasedOn="{StaticResource ListViewItemRevealStyle}"
16+
TargetType="ListViewItem">
17+
<Setter Property="Padding" Value="12,0" />
18+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
19+
<Setter Property="VerticalContentAlignment" Value="Stretch" />
20+
</Style>
21+
</UserControl.Resources>
22+
23+
<Grid>
24+
<Grid
25+
x:Name="RecentsListGrid"
26+
Grid.Row="1"
27+
Grid.Column="0">
28+
<StackPanel Orientation="Vertical">
29+
<TextBlock
30+
x:Uid="RecentItems"
31+
Margin="0,0,0,0"
32+
HorizontalAlignment="Left"
33+
FontFamily="Segoe UI"
34+
FontSize="14"
35+
FontWeight="Medium"
36+
Text="Recent files" />
37+
<TextBlock
38+
x:Uid="RecentItemDescription"
39+
Margin="0,24,0,0"
40+
HorizontalAlignment="Stretch"
41+
FontSize="14"
42+
Text="Files you've accessed before will show up here"
43+
TextAlignment="Center"
44+
TextWrapping="WrapWholeWords"
45+
Visibility="{x:Bind Empty.Visibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
46+
<ListView
47+
x:Name="RecentsView"
48+
HorizontalAlignment="Stretch"
49+
VerticalAlignment="Stretch"
50+
IsItemClickEnabled="True"
51+
IsRightTapEnabled="True"
52+
ItemClick="RecentsView_ItemClick"
53+
ItemContainerStyle="{StaticResource ListViewItemContainerStyle1}"
54+
ItemsSource="{x:Bind recentItemsCollection}"
55+
SelectionMode="None">
56+
<ListView.ItemTemplate>
57+
<DataTemplate x:DataType="local:RecentItem">
58+
<Grid
59+
Padding="2.5"
60+
HorizontalAlignment="Stretch"
61+
VerticalAlignment="Stretch"
62+
Background="Transparent"
63+
ColumnSpacing="14"
64+
ToolTipService.ToolTip="{x:Bind RecentPath}">
65+
<Grid.ContextFlyout>
66+
<MenuFlyout>
67+
<MenuFlyoutItem
68+
x:Name="mfi_RemoveOneItem"
69+
x:Uid="RecentItemRemove"
70+
Click="RemoveOneFrequentItem"
71+
Icon="Remove"
72+
Text="Remove this item" />
73+
<MenuFlyoutItem
74+
x:Uid="RecentItemClearAll"
75+
Click="MenuFlyoutItem_Click"
76+
Icon="Delete"
77+
Text="Clear all items" />
78+
<MenuFlyoutItem
79+
x:Uid="RecentItemOpenFileLocation"
80+
Click="OpenFileLocation_Click"
81+
Text="Open file location"
82+
Visibility="{x:Bind IsFile}">
83+
<MenuFlyoutItem.Icon>
84+
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE838;" />
85+
</MenuFlyoutItem.Icon>
86+
</MenuFlyoutItem>
87+
</MenuFlyout>
88+
</Grid.ContextFlyout>
89+
<Grid.ColumnDefinitions>
90+
<ColumnDefinition Width="Auto" />
91+
<ColumnDefinition Width="*" />
92+
<ColumnDefinition Width="*" />
93+
</Grid.ColumnDefinitions>
94+
<Grid
95+
Grid.Column="0"
96+
Margin="0,0,0,0"
97+
VerticalAlignment="Stretch">
98+
<FontIcon
99+
FontFamily="Segoe MDL2 Assets"
100+
FontSize="24"
101+
Foreground="#ffe793"
102+
Glyph="&#xE8D5;"
103+
Visibility="{x:Bind FolderImg}" />
104+
<FontIcon
105+
FontFamily="Segoe MDL2 Assets"
106+
FontSize="24"
107+
Glyph="&#xE7C3;"
108+
Visibility="{x:Bind EmptyImgVis}" />
109+
<Image
110+
Width="24"
111+
Height="24"
112+
Source="{x:Bind FileImg}"
113+
Stretch="UniformToFill"
114+
Visibility="{x:Bind FileIconVis}" />
115+
</Grid>
116+
<TextBlock
117+
Grid.Column="1"
118+
VerticalAlignment="Center"
119+
Text="{x:Bind Name}"
120+
TextTrimming="CharacterEllipsis"
121+
TextWrapping="NoWrap" />
122+
<TextBlock
123+
Grid.Column="2"
124+
Margin="0,0,0,0"
125+
VerticalAlignment="Center"
126+
FontSize="10"
127+
Foreground="DimGray"
128+
Text="{x:Bind RecentPath}"
129+
TextTrimming="CharacterEllipsis"
130+
TextWrapping="NoWrap" />
131+
</Grid>
132+
</DataTemplate>
133+
</ListView.ItemTemplate>
134+
</ListView>
135+
</StackPanel>
136+
</Grid>
137+
</Grid>
138+
</UserControl>

0 commit comments

Comments
 (0)