feature: long press to save original illust
This commit is contained in:
58
Pixiview.iOS/Effects/LongPressEffectImplement.cs
Normal file
58
Pixiview.iOS/Effects/LongPressEffectImplement.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Threading.Tasks;
|
||||
using Pixiview.iOS.Effects;
|
||||
using Pixiview.Utils;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
|
||||
[assembly: ResolutionGroupName("Pixiview")]
|
||||
[assembly: ExportEffect(typeof(LongPressEffectImplement), "LongPressEffect")]
|
||||
namespace Pixiview.iOS.Effects
|
||||
{
|
||||
public class LongPressEffectImplement : PlatformEffect
|
||||
{
|
||||
private bool attached;
|
||||
private readonly UILongPressGestureRecognizer longPressGesture;
|
||||
|
||||
public LongPressEffectImplement()
|
||||
{
|
||||
longPressGesture = new UILongPressGestureRecognizer(OnLongPressed);
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
if (!attached)
|
||||
{
|
||||
attached = true;
|
||||
Container.AddGestureRecognizer(longPressGesture);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDetached()
|
||||
{
|
||||
if (attached)
|
||||
{
|
||||
attached = false;
|
||||
Container.RemoveGestureRecognizer(longPressGesture);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLongPressed(UILongPressGestureRecognizer e)
|
||||
{
|
||||
if (e.State != UIGestureRecognizerState.Began)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var element = Element;
|
||||
if (element != null)
|
||||
{
|
||||
var command = LongPressEffect.GetCommand(element);
|
||||
if (command != null)
|
||||
{
|
||||
var o = LongPressEffect.GetCommandParameter(element);
|
||||
command.Execute(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -79,6 +79,7 @@
|
||||
<Compile Include="Renderers\AppShellRenderer.cs" />
|
||||
<Compile Include="Renderers\AppShellSection\AppShellSectionRootHeader.cs" />
|
||||
<Compile Include="Renderers\SegmentedControlRenderer.cs" />
|
||||
<Compile Include="Effects\LongPressEffectImplement.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
|
||||
@@ -148,6 +149,7 @@
|
||||
<Folder Include="Renderers\" />
|
||||
<Folder Include="Services\" />
|
||||
<Folder Include="Renderers\AppShellSection\" />
|
||||
<Folder Include="Effects\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Resources\fa-light-300.ttf" />
|
||||
|
@@ -29,29 +29,28 @@ namespace Pixiview.iOS.Services
|
||||
#region - Theme -
|
||||
|
||||
[SuppressMessage("Code Notifications", "XI0002:Notifies you from using newer Apple APIs when targeting an older OS version", Justification = "<Pending>")]
|
||||
public Theme GetApplicationTheme()
|
||||
public OSAppTheme GetApplicationTheme()
|
||||
{
|
||||
if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
|
||||
{
|
||||
var currentController = Platform.GetCurrentUIViewController();
|
||||
if (currentController == null)
|
||||
{
|
||||
return Theme.Light;
|
||||
return OSAppTheme.Unspecified;
|
||||
}
|
||||
|
||||
var style = currentController.TraitCollection.UserInterfaceStyle;
|
||||
if (style == UIUserInterfaceStyle.Dark)
|
||||
{
|
||||
return Theme.Dark;
|
||||
return OSAppTheme.Dark;
|
||||
}
|
||||
else
|
||||
else if (style == UIUserInterfaceStyle.Light)
|
||||
{
|
||||
return Theme.Light;
|
||||
return OSAppTheme.Light;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Theme.Light;
|
||||
}
|
||||
|
||||
return OSAppTheme.Unspecified;
|
||||
}
|
||||
|
||||
public void SetStatusBarStyle(StatusBarStyles style)
|
||||
|
Reference in New Issue
Block a user