Skip to content

Commit 08e7996

Browse files
committed
Implement and enable WIP instance Tabs by default
1 parent 34eb9ef commit 08e7996

File tree

6 files changed

+270
-38
lines changed

6 files changed

+270
-38
lines changed

Files UWP/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
112112
// When the navigation stack isn't restored navigate to the first page,
113113
// configuring the new page by passing required information as a navigation
114114
// parameter
115-
rootFrame.Navigate(typeof(ProHome), e.Arguments, new SuppressNavigationTransitionInfo());
115+
rootFrame.Navigate(typeof(InstanceTabsView), e.Arguments, new SuppressNavigationTransitionInfo());
116116

117117

118118
}

Files UWP/FilesUWP.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
<Compile Include="GenericFileBrowser.xaml.cs">
118118
<DependentUpon>GenericFileBrowser.xaml</DependentUpon>
119119
</Compile>
120+
<Compile Include="InstanceTabsView.xaml.cs">
121+
<DependentUpon>InstanceTabsView.xaml</DependentUpon>
122+
</Compile>
120123
<Compile Include="Interacts\Interaction.cs" />
121124
<Compile Include="Interacts\ItemInteractions.cs" />
122125
<Compile Include="Interacts\RibbonActions\Home.cs" />
@@ -184,6 +187,10 @@
184187
<SubType>Designer</SubType>
185188
<Generator>MSBuild:Compile</Generator>
186189
</Page>
190+
<Page Include="InstanceTabsView.xaml">
191+
<SubType>Designer</SubType>
192+
<Generator>MSBuild:Compile</Generator>
193+
</Page>
187194
<Page Include="PhotoAlbum.xaml">
188195
<SubType>Designer</SubType>
189196
<Generator>MSBuild:Compile</Generator>

Files UWP/InstanceTabsView.xaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<Page
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="using:Files"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:Custom="using:Microsoft.Toolkit.Uwp.UI.Controls"
8+
x:Class="Files.InstanceTabsView"
9+
mc:Ignorable="d"
10+
Background="{ThemeResource SystemControlChromeHighAcrylicWindowMediumBrush}" Name="InstanceTabsPage">
11+
<Page.Resources>
12+
<ResourceDictionary>
13+
<ResourceDictionary.MergedDictionaries>
14+
<ResourceDictionary>
15+
<ResourceDictionary.ThemeDictionaries>
16+
<ResourceDictionary x:Key="Default">
17+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="White" />
18+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="LightGray" />
19+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="White" />
20+
</ResourceDictionary>
21+
<ResourceDictionary x:Key="Light">
22+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="White" />
23+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="LightGray" />
24+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="White" />
25+
</ResourceDictionary>
26+
<ResourceDictionary x:Key="Dark">
27+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="#191919" />
28+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="DarkGray" />
29+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="#191919" />
30+
</ResourceDictionary>
31+
<ResourceDictionary x:Key="HighContrast">
32+
<!-- This empty dictionary ensures that the default high contrast resources are used when the user turns on high contrast mode. -->
33+
</ResourceDictionary>
34+
</ResourceDictionary.ThemeDictionaries>
35+
</ResourceDictionary>
36+
</ResourceDictionary.MergedDictionaries>
37+
</ResourceDictionary>
38+
</Page.Resources>
39+
40+
<Grid Background="Transparent">
41+
<Grid.RowDefinitions>
42+
<RowDefinition Height="Auto"/>
43+
<RowDefinition/>
44+
</Grid.RowDefinitions>
45+
46+
<Grid.ColumnDefinitions>
47+
<ColumnDefinition Width="{Binding Width, ElementName=LeftPaddingColumn}"/>
48+
<ColumnDefinition/>
49+
<ColumnDefinition Width="{Binding Width, ElementName=RightPaddingColumn}"/>
50+
</Grid.ColumnDefinitions>
51+
52+
<ContentPresenter Name="tabContentPresenter" Grid.Row="1" Grid.ColumnSpan="3" Content="{x:Bind local:InstanceTabsView.ContentPresGrid, Mode=OneWay}"/>
53+
54+
<Grid Grid.ColumnSpan="3" Name="DragArea" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Loaded="DragArea_Loaded" Background="Transparent">
55+
<Grid.ColumnDefinitions>
56+
<ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/>
57+
<ColumnDefinition/>
58+
<ColumnDefinition x:Name="RightPaddingColumn" Width="0"/>
59+
</Grid.ColumnDefinitions>
60+
</Grid>
61+
62+
<Custom:TabView CanReorderItems="False" SelectionChanged="TabStrip_SelectionChanged" Name="TabStrip" SelectedTabWidth="150" IsCloseButtonOverlay="False" Background="Transparent" TabWidthBehavior="Actual" CanCloseTabs="True" ItemsSource="{x:Bind local:InstanceTabsView.instanceTabs}" TabClosing="TabStrip_TabClosing">
63+
<Custom:TabView.Resources>
64+
<x:Double x:Key="TabViewItemHeaderMinHeight">32</x:Double>
65+
<StaticResource x:Key="TabViewSelectionIndicatorForeground" ResourceKey="SystemControlTransparentBrush" />
66+
</Custom:TabView.Resources>
67+
<Custom:TabView.ItemTemplate>
68+
<DataTemplate/>
69+
</Custom:TabView.ItemTemplate>
70+
71+
<Custom:TabView.ItemHeaderTemplate>
72+
<DataTemplate>
73+
<Grid Canvas.ZIndex="5" Width="150">
74+
<TextBlock VerticalAlignment="Center" Text="{Binding HeaderText}"/>
75+
</Grid>
76+
</DataTemplate>
77+
</Custom:TabView.ItemHeaderTemplate>
78+
79+
<Custom:TabView.TabActionHeader>
80+
<Button BorderThickness="1" x:Name="NewTabButton" Canvas.ZIndex="2" Background="Transparent" Style="{StaticResource ButtonRevealStyle}" Height="32" Width="32" Click="NewTabButton_Click">
81+
<Button.Content>
82+
<FontIcon FontSize="12" Glyph="&#xE710;"/>
83+
</Button.Content>
84+
</Button>
85+
</Custom:TabView.TabActionHeader>
86+
87+
</Custom:TabView>
88+
89+
</Grid>
90+
</Page>

Files UWP/InstanceTabsView.xaml.cs

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
using Microsoft.Toolkit.Uwp.UI.Controls;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using Windows.ApplicationModel.Core;
5+
using Windows.Foundation;
6+
using Windows.UI;
7+
using Windows.UI.ViewManagement;
8+
using Windows.UI.Xaml;
9+
using Windows.UI.Xaml.Controls;
10+
11+
namespace Files
12+
{
13+
/// <summary>
14+
/// The Instance Tabs Component for Project Mumbai
15+
/// </summary>
16+
public sealed partial class InstanceTabsView : Page
17+
{
18+
public static ObservableCollection<InstanceTabItem> instanceTabs { get; set; } = new ObservableCollection<InstanceTabItem>();
19+
20+
public InstanceTabsView()
21+
{
22+
this.InitializeComponent();
23+
ApplicationView.PreferredLaunchViewSize = new Size(1080, 630);
24+
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
25+
var CoreTitleBar = CoreApplication.GetCurrentView().TitleBar;
26+
CoreTitleBar.ExtendViewIntoTitleBar = true;
27+
CoreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged; ;
28+
CoreTitleBar_LayoutMetricsChanged(CoreTitleBar, null);
29+
TabStrip.Loaded += TabStrip_Loaded;
30+
31+
32+
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
33+
titleBar.ButtonInactiveBackgroundColor = Color.FromArgb(0, 255, 255, 255);
34+
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 10, 10, 10);
35+
if (App.Current.RequestedTheme == ApplicationTheme.Dark)
36+
{
37+
titleBar.ButtonBackgroundColor = Color.FromArgb(0, 0, 0, 0);
38+
titleBar.ButtonForegroundColor = Colors.White;
39+
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 240, 240, 240);
40+
titleBar.BackgroundColor = Color.FromArgb(255, 25, 25, 25);
41+
}
42+
else if (App.Current.RequestedTheme == ApplicationTheme.Light)
43+
{
44+
titleBar.ButtonBackgroundColor = Color.FromArgb(0, 255, 255, 255);
45+
titleBar.ButtonForegroundColor = Colors.Black;
46+
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 155, 155, 155);
47+
}
48+
49+
if (this.RequestedTheme == ElementTheme.Dark)
50+
{
51+
titleBar.ButtonForegroundColor = Colors.White;
52+
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 240, 240, 240);
53+
titleBar.BackgroundColor = Color.FromArgb(255, 25, 25, 25);
54+
}
55+
else if (this.RequestedTheme == ElementTheme.Light)
56+
{
57+
titleBar.ButtonForegroundColor = Colors.Black;
58+
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 155, 155, 155);
59+
titleBar.BackgroundColor = Colors.Transparent;
60+
}
61+
//instanceTabs.Clear();
62+
63+
}
64+
65+
private void CoreTitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar sender, object args)
66+
{
67+
LeftPaddingColumn.Width = new GridLength((TabStrip.Items.Count * 150) + 32);
68+
RightPaddingColumn.Width = new GridLength(sender.SystemOverlayRightInset);
69+
}
70+
71+
public static Grid ContentPresGrid { get; set; } = new Grid();
72+
73+
private void TabStrip_Loaded(object sender, RoutedEventArgs e)
74+
{
75+
instanceTabs.CollectionChanged += InstanceTabs_CollectionChanged;
76+
Frame FirstFrame = new Frame();
77+
FirstFrame.Tag = 0;
78+
FirstFrame.Navigate(typeof(ProHome));
79+
ContentPresGrid.Children.Add(FirstFrame);
80+
instanceTabs.Add(new InstanceTabItem() { HeaderText = "Favorites", SourcePage = "ProHome", index = 0, TabContent = FirstFrame });
81+
}
82+
83+
private void InstanceTabs_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
84+
{
85+
var CoreTitleBar = CoreApplication.GetCurrentView().TitleBar;
86+
LeftPaddingColumn.Width = new GridLength((TabStrip.Items.Count * 250) + 32);
87+
RightPaddingColumn.Width = new GridLength(CoreTitleBar.SystemOverlayRightInset);
88+
//if(e.NewItems.Count > 0)
89+
//{
90+
// List<TabViewItem> tabsFound = new List<TabViewItem>();
91+
// Interacts.Interaction.FindChildren<TabViewItem>(tabsFound, InstanceTabsPage.Content as DependencyObject);
92+
93+
// List<Frame> frames = new List<Frame>();
94+
// Interacts.Interaction.FindChildren<Frame>(frames, InstanceTabsPage.Content as DependencyObject);
95+
// frames[0].Navigate((e.NewItems as List<InstanceTabItem>)[0].SourcePage);
96+
//}
97+
98+
}
99+
100+
101+
102+
private void NewTabButton_Click(object sender, RoutedEventArgs e)
103+
{
104+
Frame FirstFrame = new Frame();
105+
FirstFrame.Tag = 0;
106+
FirstFrame.Navigate(typeof(ProHome));
107+
ContentPresGrid.Children.Add(FirstFrame);
108+
instanceTabs.Add(new InstanceTabItem() { HeaderText = "Favorites", SourcePage = "ProHome", index = TabStrip.Items.Count, TabContent = FirstFrame });
109+
TabStrip.SelectedItem = instanceTabs[instanceTabs.Count - 1];
110+
}
111+
112+
private void DragArea_Loaded(object sender, RoutedEventArgs e)
113+
{
114+
Window.Current.SetTitleBar((Grid)sender);
115+
}
116+
117+
private void TabStrip_SelectionChanged(object sender, SelectionChangedEventArgs e)
118+
{
119+
List<TabViewItem> tabsFound = new List<TabViewItem>();
120+
Interacts.Interaction.FindChildren<TabViewItem>(tabsFound, InstanceTabsPage.Content as DependencyObject);
121+
if ((e.AddedItems[0] as InstanceTabItem).SourcePage == "ProHome")
122+
{
123+
foreach(TabViewItem tvi in tabsFound)
124+
{
125+
if ((e.AddedItems[0] as InstanceTabItem).index == TabStrip.Items.IndexOf(tvi))
126+
{
127+
// Applies below with selected Tab's information
128+
foreach(Frame instance in ContentPresGrid.Children)
129+
{
130+
// hide all other opened tab's content unless the instance belongs to the selected tab
131+
if( ((int) instance.Tag) != (e.AddedItems[0] as InstanceTabItem).index)
132+
{
133+
instance.Visibility = Visibility.Collapsed;
134+
}
135+
else
136+
{
137+
instance.Visibility = Visibility.Visible;
138+
}
139+
}
140+
return;
141+
}
142+
}
143+
}
144+
}
145+
146+
private void TabStrip_TabClosing(object sender, TabClosingEventArgs e)
147+
{
148+
foreach(Frame instance in ContentPresGrid.Children)
149+
{
150+
if(((int) instance.Tag) == (e.Item as InstanceTabItem).index)
151+
{
152+
ContentPresGrid.Children.Remove(instance);
153+
return;
154+
}
155+
}
156+
}
157+
}
158+
159+
public class InstanceTabItem
160+
{
161+
public string HeaderText { get; set; }
162+
public string SourcePage { get; set; }
163+
public int index { get; set; }
164+
public Frame TabContent { get; set; }
165+
166+
167+
}
168+
}

Files UWP/ProHome.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,9 @@
878878
<RowDefinition Height="*"/>
879879
</Grid.RowDefinitions>
880880
<Grid x:Name="Ribbon" Grid.Row="0" Canvas.ZIndex="2">
881-
<Custom:DropShadowPanel OffsetY="-2" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
881+
<Windows10version1903:Grid.Shadow>
882+
<Windows10version1903:ThemeShadow/>
883+
</Windows10version1903:Grid.Shadow>
882884
<StackPanel Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Orientation="Vertical">
883885
<Custom:TabView TabWidthBehavior="Actual" Background="Transparent" Template="{StaticResource TabViewTemplate1}">
884886
<Custom:TabViewItem Template="{StaticResource TabViewItemFluentTemplate}" BorderThickness="0" Header="File">
@@ -995,7 +997,6 @@
995997

996998
</Grid>
997999
</StackPanel>
998-
</Custom:DropShadowPanel>
9991000
</Grid>
10001001

10011002
<SplitView DisplayMode="Inline" OpenPaneLength="225" IsPaneOpen="True" HorizontalAlignment="Stretch" Grid.RowSpan="1" Grid.Row="1" VerticalAlignment="Stretch" PaneBackground="{ThemeResource SystemControlChromeHighAcrylicWindowMediumBrush}" >

Files UWP/ProHome.xaml.cs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,7 @@ public sealed partial class ProHome : Page
5454
public ProHome()
5555
{
5656
this.InitializeComponent();
57-
// TODO: Migrate preferred view size to page hosting tabs (when needed)
58-
ApplicationView.PreferredLaunchViewSize = new Size(1080, 630);
59-
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
60-
var CoreTitleBar = CoreApplication.GetCurrentView().TitleBar;
61-
CoreTitleBar.ExtendViewIntoTitleBar = false;
62-
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
63-
titleBar.ButtonInactiveBackgroundColor = Color.FromArgb(0, 255, 255, 255);
64-
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 10, 10, 10);
57+
this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
6558
permissionBox = PermissionDialog;
6659
locationsList = LocationsList;
6760
drivesList = DrivesList;
@@ -77,33 +70,6 @@ public ProHome()
7770
AddItemButton = addItemButton;
7871
accessiblePasteButton = PasteButton;
7972
LocationsList.SelectedIndex = 0;
80-
if (App.Current.RequestedTheme == ApplicationTheme.Dark)
81-
{
82-
titleBar.ButtonBackgroundColor = Color.FromArgb(255, 0, 0, 0);
83-
titleBar.ButtonForegroundColor = Colors.White;
84-
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 240, 240, 240);
85-
titleBar.BackgroundColor = Color.FromArgb(255, 25, 25, 25);
86-
}
87-
else if (App.Current.RequestedTheme == ApplicationTheme.Light)
88-
{
89-
titleBar.ButtonBackgroundColor = Color.FromArgb(255, 255, 255, 255);
90-
titleBar.ButtonForegroundColor = Colors.Black;
91-
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 240, 240, 240);
92-
titleBar.BackgroundColor = Colors.White;
93-
}
94-
95-
if (this.RequestedTheme == ElementTheme.Dark)
96-
{
97-
titleBar.ButtonForegroundColor = Colors.White;
98-
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 240, 240, 240);
99-
titleBar.BackgroundColor = Color.FromArgb(255, 25, 25, 25);
100-
}
101-
else if (this.RequestedTheme == ElementTheme.Light)
102-
{
103-
titleBar.ButtonForegroundColor = Colors.Black;
104-
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 240, 240, 240);
105-
titleBar.BackgroundColor = Colors.White;
106-
}
10773
accessibleContentFrame.Navigate(typeof(YourHome), new SuppressNavigationTransitionInfo());
10874
RibbonTeachingTip = RibbonTip;
10975
PopulateNavViewWithExternalDrives();

0 commit comments

Comments
 (0)