Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UniSky.Services/Implementation/TypedSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public bool VideosInFeeds
get => settings.Read(VIDEOS_IN_FEEDS, VIDEOS_IN_FEEDS_DEFAULT);
set => settings.Save(VIDEOS_IN_FEEDS, value);
}

public bool ShowFeedContext
{
get => settings.Read(SHOW_FEED_CONTEXT, SHOW_FEED_CONTEXT_DEFAULT);
Expand Down
4 changes: 3 additions & 1 deletion UniSky.Services/Overlay/IOverlayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

namespace UniSky.Services;


public interface IOverlayController
{
UIElement Root { get; }
bool IsStandalone { get; }
ISafeAreaService SafeAreaService { get; }
Task<bool> TryHideSheetAsync();
Task ShowAsync(object parameter);
Task<bool> TryHideAsync();
}
28 changes: 28 additions & 0 deletions UniSky/Controls/Compose/ComposeSheet.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using UniSky.Controls.Overlay;
using UniSky.Controls.Sheet;
Expand All @@ -9,9 +10,12 @@
using Windows.ApplicationModel.Resources;
using Windows.Foundation;
using Windows.Foundation.Metadata;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;

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

Expand All @@ -38,6 +42,12 @@ public ComposeSheet()
this.Shown += OnShown;
this.Hiding += OnHiding;
this.Hidden += OnHidden;

if (ApiInformation.IsEventPresent(typeof(UIElement).FullName, "PreviewKeyDown"))
{
PrimaryTextBox.PreviewKeyDown += OnPreviewKeyDown;
}

this.strings = ResourceLoader.GetForCurrentView();
}

Expand Down Expand Up @@ -136,5 +146,23 @@ private void PrimaryTextBox_Paste(object sender, TextControlPasteEventArgs e)
{
e.Handled = ViewModel.HandlePaste();
}

private async void OnPreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
var coreWindow = CoreWindow.GetForCurrentThread();
if (e.Key == VirtualKey.Enter)
{
var state = coreWindow.GetAsyncKeyState(VirtualKey.Control);
if (state.HasFlag(CoreVirtualKeyStates.Down))
{
if (!ViewModel.CanPost)
return;

e.Handled = true;

await ViewModel.PostAsync();
}
}
}
}
}
9 changes: 7 additions & 2 deletions UniSky/Controls/Gallery/GalleryControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

<FlipView x:Name="FlippyView"
ItemsSource="{Binding Images}"
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}">
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
Background="Transparent">
<FlipView.ItemTemplate>
<DataTemplate>
<ScrollViewer x:Name="OutputScrollViewer"
Expand All @@ -24,7 +25,11 @@
MinZoomFactor="1.0">
<Viewbox MaxWidth="{Binding ViewportWidth, ElementName=OutputScrollViewer, Mode=OneWay}"
MaxHeight="{Binding ViewportHeight, ElementName=OutputScrollViewer, Mode=OneWay}">
<Image Source="{Binding ImageUrl}"/>
<Image x:Name="MainImage" Tag="{Binding ImageUrl}">
<Image.Source>
<BitmapImage UriSource="{Binding ImageUrl}" ImageOpened="MainImage_Loaded"/>
</Image.Source>
</Image>
</Viewbox>
</ScrollViewer>
</DataTemplate>
Expand Down
37 changes: 37 additions & 0 deletions UniSky/Controls/Gallery/GalleryControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Toolkit.Uwp.UI.Extensions;
using UniSky.Controls.Overlay;
using UniSky.Services;
using UniSky.ViewModels.Gallery;
using Windows.Foundation.Metadata;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Media.Imaging;

namespace UniSky.Controls.Gallery;

Expand All @@ -22,4 +28,35 @@ protected override void OnShowing(OverlayShowingEventArgs args)

DataContext = ActivatorUtilities.CreateInstance<GalleryViewModel>(ServiceContainer.Scoped, gallery);
}

protected override void OnShown(RoutedEventArgs args)
{
base.OnShown(args);
}

private void MainImage_Loaded(object sender, RoutedEventArgs e)
{
if (Controller.IsStandalone)
return;

var vm = (GalleryViewModel)DataContext;
var selected = vm.Images[vm.SelectedIndex];
var source = (BitmapImage)sender;

if (source.UriSource.AbsolutePath != new Uri(selected.ImageUrl).AbsolutePath)
return;

var container = FlippyView.ContainerFromIndex(vm.SelectedIndex);
var mainImage = container.FindDescendantByName("MainImage");

var animation = ConnectedAnimationService.GetForCurrentView()
.GetAnimation("GalleryView");

if (animation != null)
{
if (ApiInformation.IsTypePresent(typeof(DirectConnectedAnimationConfiguration).FullName))
animation.Configuration = new DirectConnectedAnimationConfiguration();
animation.TryStart(mainImage);
}
}
}
153 changes: 153 additions & 0 deletions UniSky/Controls/Overlay/OverlayRootControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<UserControl
x:Class="UniSky.Controls.Overlay.OverlayRootControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniSky.Controls.Overlay"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:w1709="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 5)"
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<UserControl.Resources>
<ExponentialEase x:Key="ExponentialEaseEnter"
EasingMode="EaseOut"
Exponent="7"/>
<ExponentialEase x:Key="ExponentialEaseExit"
EasingMode="EaseIn"
Exponent="5"/>

<ui:AttachedDropShadow x:Key="CommonShadow"
x:Name="CommonShadow"
BlurRadius="16"
Color="{ThemeResource SheetRootShadowColor}"
CastTo="{Binding ElementName=CompositionBackdropContainer}"/>
</UserControl.Resources>

<Grid>
<Border x:Name="CompositionBackdropContainer"
IsHitTestVisible="False"
Visibility="Collapsed"
Background="{ThemeResource SheetContentRootBackdropBackgroundBrush}">
</Border>

<Grid x:Name="HostControl"
RenderTransformOrigin="0.5,0.5"
Opacity="0"
TabFocusNavigation="Cycle">
<Grid.RenderTransform>
<ScaleTransform x:Name="OverlayScale" ScaleX="1" ScaleY="1"/>
</Grid.RenderTransform>
<Border x:Name="SheetBorder"
BorderBrush="{ThemeResource SheetContentBorderBrush}"
ui:Effects.Shadow="{StaticResource CommonShadow}">
<Border x:Name="SheetRoot"/>
</Border>


<Button x:Name="PrimaryTitleBarButton"
TabIndex="0"
Grid.Column="2"
Width="40"
Height="40"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="16"
Click="PrimaryTitleBarButton_Click"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="16"
Content="&#xE8BB;">
<w1709:Button.KeyboardAccelerators>
<w1709:KeyboardAccelerator Key="Escape"/>
</w1709:Button.KeyboardAccelerators>
</Button>

</Grid>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="OverlayStates">
<VisualState x:Name="Open">
<VisualState.Storyboard>
<Storyboard x:Name="ShowOverlayStoryboard"
Completed="ShowOverlayStoryboard_Completed">
<DoubleAnimation From="0" To="1"
Storyboard.TargetName="HostControl"
Storyboard.TargetProperty="Opacity"
Duration="0:0:0.30"
EasingFunction="{StaticResource ExponentialEaseEnter}"/>
<DoubleAnimation From="0" To="1"
Storyboard.TargetName="CompositionBackdropContainer"
Storyboard.TargetProperty="Opacity"
Duration="0:0:0.30"
EasingFunction="{StaticResource ExponentialEaseEnter}"/>

<!--<DoubleAnimation From="0.85" To="1"
Storyboard.TargetName="OverlayScale"
Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
Duration="0:0:0.30"
EasingFunction="{StaticResource ExponentialEaseEnter}"/>
<DoubleAnimation From="0.85" To="1"
Storyboard.TargetName="OverlayScale"
Storyboard.TargetProperty="(ScaleTransform.ScaleY)"
Duration="0:0:0.30"
EasingFunction="{StaticResource ExponentialEaseEnter}"/>-->

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostControl"
Storyboard.TargetProperty="Visibility"
BeginTime="0:0:0.0">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="CompositionBackdropContainer"
Storyboard.TargetProperty="Visibility"
BeginTime="0:0:0.0">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState.Storyboard>
</VisualState>
<VisualState x:Name="Closed">
<VisualState.Storyboard>
<Storyboard x:Name="HideOverlayStoryboard"
Completed="HideOverlayStoryboard_Completed">
<DoubleAnimation From="1" To="0"
Storyboard.TargetName="HostControl"
Storyboard.TargetProperty="Opacity"
Duration="0:0:0.15"
EasingFunction="{StaticResource ExponentialEaseExit}"/>
<DoubleAnimation From="1" To="0"
Storyboard.TargetName="CompositionBackdropContainer"
Storyboard.TargetProperty="Opacity"
Duration="0:0:0.15"
EasingFunction="{StaticResource ExponentialEaseExit}"/>


<DoubleAnimation From="1" To="0.85"
Storyboard.TargetName="OverlayScale"
Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
Duration="0:0:0.15"
EasingFunction="{StaticResource ExponentialEaseExit}"/>
<DoubleAnimation From="1" To="0.85"
Storyboard.TargetName="OverlayScale"
Storyboard.TargetProperty="(ScaleTransform.ScaleY)"
Duration="0:0:0.15"
EasingFunction="{StaticResource ExponentialEaseExit}"/>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostControl"
Storyboard.TargetProperty="Visibility"
BeginTime="0:0:0.15">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="CompositionBackdropContainer"
Storyboard.TargetProperty="Visibility"
BeginTime="0:0:0.15">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState.Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</UserControl>
Loading