Skip to content

Commit

Permalink
new window button should not be visible on xbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Tung Huynh committed Apr 13, 2022
1 parent d296a67 commit a44365e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 42 deletions.
8 changes: 3 additions & 5 deletions Indirect/Controls/ThreadDetailsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@
Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}"
BorderBrush="{StaticResource FlyoutBorderThemeBrush}"
BorderThickness="0,0,0,1"
Canvas.ZIndex="1"
Visibility="{x:Bind ThreadHeaderVisibility, Mode=OneWay}" />
Canvas.ZIndex="1" />

<CommandBar
Grid.Row="0"
Expand All @@ -106,7 +105,6 @@
DefaultLabelPosition="Right"
IsDynamicOverflowEnabled="False"
OverflowButtonVisibility="Collapsed"
Visibility="{x:Bind ThreadHeaderVisibility, Mode=OneWay}"
XYFocusKeyboardNavigation="Enabled">

<FlyoutBase.AttachedFlyout>
Expand Down Expand Up @@ -149,12 +147,12 @@
Label="View profile" />

<AppBarButton
x:Name="NewWindowButton"
Width="48"
Click="OpenInNewWindow_OnClick"
Label="Open thread in a new window"
LabelPosition="Collapsed"
ToolTipService.ToolTip="Open thread in a new window"
Visibility="{x:Bind IsNewWindow, Converter={StaticResource InvertBooleanVisibilityConverter}, Mode=OneWay}">
ToolTipService.ToolTip="Open thread in a new window">
<AppBarButton.Icon>
<FontIcon
VerticalAlignment="Center"
Expand Down
57 changes: 21 additions & 36 deletions Indirect/Controls/ThreadDetailsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Windows.UI.Composition;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Hosting;
using Indirect.Utilities;

// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

Expand All @@ -39,54 +40,19 @@ sealed partial class ThreadDetailsView : UserControl
typeof(ThreadDetailsView),
new PropertyMetadata(null, OnThreadChanged));

public static readonly DependencyProperty IsNewWindowProperty = DependencyProperty.Register(
nameof(IsNewWindow),
typeof(bool),
typeof(ThreadDetailsView),
new PropertyMetadata(false, OnIsNewWindowChanged));

public static readonly DependencyProperty ThreadHeaderVisibilityProperty = DependencyProperty.Register(
nameof(ThreadHeaderVisibility),
typeof(Visibility),
typeof(ThreadDetailsView),
new PropertyMetadata(Visibility.Visible));

public DirectThreadWrapper Thread
{
get => (DirectThreadWrapper)GetValue(ThreadProperty);
set => SetValue(ThreadProperty, value);
}

public bool IsNewWindow
{
get => (bool)GetValue(IsNewWindowProperty);
set => SetValue(IsNewWindowProperty, value);
}

public Visibility ThreadHeaderVisibility
{
get => (Visibility)GetValue(ThreadHeaderVisibilityProperty);
set => SetValue(ThreadHeaderVisibilityProperty, value);
}
public bool IsNewWindow { get; set; }


private bool _needUpdateCaret; // For moving the caret to the end of text on thread change. This is a bad idea. ¯\_(ツ)_/¯
private readonly DispatcherQueue _dispatcherQueue;
private SizeChangedEventHandler _sizeChangedHandler;

private static void OnIsNewWindowChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if ((bool)e.NewValue)
{
var view = (ThreadDetailsView)d;
view.RootGrid.RowDefinitions[0].Height = new GridLength(0);
view.ContentGrid.RowDefinitions[0].Height = new GridLength(82);
view.ContentGrid.CornerRadius = new CornerRadius(0);
view.ContentGrid.BorderThickness = new Thickness(0);
view.BorderThicknessSetter.Value = new Thickness(0);
}
}

private static void OnThreadChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var view = (ThreadDetailsView)d;
Expand All @@ -107,9 +73,28 @@ public ThreadDetailsView()
this.InitializeComponent();
_dispatcherQueue = DispatcherQueue.GetForCurrentThread();
_sizeChangedHandler = new SizeChangedEventHandler(ItemContainer_SizeChanged);
if (!DeviceFamilyHelpers.MultipleViewsSupport)
{
NewWindowButton.Visibility = Visibility.Collapsed;
}

ViewModel.PropertyChanged += OnUserPresenceChanged;
GifPicker.ImageSelected += (sender, media) => GifPickerFlyout.Hide();
TypingIndicator.RegisterPropertyChangedCallback(VisibilityProperty, TypingIndicator_OnVisibilityChanged);
Loading += OnLoading;
}

private void OnLoading(FrameworkElement sender, object args)
{
if (IsNewWindow)
{
RootGrid.RowDefinitions[0].Height = new GridLength(0);
ContentGrid.RowDefinitions[0].Height = new GridLength(82);
ContentGrid.CornerRadius = new CornerRadius(0);
ContentGrid.BorderThickness = new Thickness(0);
BorderThicknessSetter.Value = new Thickness(0);
NewWindowButton.Visibility = Visibility.Collapsed;
}
}

private void TypingIndicator_OnVisibilityChanged(DependencyObject sender, DependencyProperty dp)
Expand Down
2 changes: 1 addition & 1 deletion Indirect/Pages/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ private async void ReelsFeed_OnItemClicked(object sender, ItemClickEventArgs e)
var reelsWrapper = (ReelWrapper)e.ClickedItem;
if (reelsWrapper != null)
{
if (DeviceFamilyHelpers.IsDesktop)
if (DeviceFamilyHelpers.MultipleViewsSupport)
{
await OpenReelInNewWindow(reelsWrapper);
}
Expand Down
2 changes: 2 additions & 0 deletions Indirect/Utilities/DeviceFamilyHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ internal static class DeviceFamilyHelpers
public static bool IsIoT => DeviceFamily == "Windows.IoT";
public static bool IsTeam => DeviceFamily == "Windows.Team";
public static bool IsHolographic => DeviceFamily == "Windows.Holographic";

public static bool MultipleViewsSupport => IsDesktop || IsHolographic;
}
}

0 comments on commit a44365e

Please sign in to comment.