diff --git a/Pixiview.iOS/Assets.xcassets/LauncherLogo.imageset/Contents.json b/Pixiview.iOS/Assets.xcassets/LauncherLogo.imageset/Contents.json index dcce229..84b7f34 100644 --- a/Pixiview.iOS/Assets.xcassets/LauncherLogo.imageset/Contents.json +++ b/Pixiview.iOS/Assets.xcassets/LauncherLogo.imageset/Contents.json @@ -22,6 +22,7 @@ "idiom": "iphone" }, { + "filename": "pixiv.png", "scale": "1x", "idiom": "iphone" }, diff --git a/Pixiview.iOS/Info.plist b/Pixiview.iOS/Info.plist index c6a9565..1d65878 100644 --- a/Pixiview.iOS/Info.plist +++ b/Pixiview.iOS/Info.plist @@ -21,7 +21,7 @@ <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>MinimumOSVersion</key> - <string>11.0</string> + <string>13.0</string> <key>CFBundleDisplayName</key> <string>Pixiview</string> <key>CFBundleIdentifier</key> @@ -46,5 +46,9 @@ <string>UIStatusBarStyleDefault</string> <key>NSPhotoLibraryUsageDescription</key> <string>需要访问您的图片库</string> + <key>LSSupportsOpeningDocumentsInPlace</key> + <true/> + <key>UIFileSharingEnabled</key> + <true/> </dict> </plist> diff --git a/Pixiview.iOS/Services/EnvironmentService.cs b/Pixiview.iOS/Services/EnvironmentService.cs index 307546e..b8e9777 100644 --- a/Pixiview.iOS/Services/EnvironmentService.cs +++ b/Pixiview.iOS/Services/EnvironmentService.cs @@ -6,7 +6,6 @@ using Pixiview.iOS.Services; using Pixiview.Resources; using Pixiview.Utils; using UIKit; -using Xamarin.Essentials; using Xamarin.Forms; [assembly: Dependency(typeof(EnvironmentService))] @@ -28,30 +27,32 @@ 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 OSAppTheme GetApplicationTheme() + public AppTheme GetApplicationTheme() { if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0)) { var currentController = Platform.GetCurrentUIViewController(); if (currentController == null) { - return OSAppTheme.Unspecified; + return AppTheme.Unspecified; } var style = currentController.TraitCollection.UserInterfaceStyle; if (style == UIUserInterfaceStyle.Dark) { - return OSAppTheme.Dark; + return AppTheme.Dark; } else if (style == UIUserInterfaceStyle.Light) { - return OSAppTheme.Light; + return AppTheme.Light; } } - return OSAppTheme.Unspecified; + return AppTheme.Unspecified; } + //*/ public void SetStatusBarStyle(StatusBarStyles style) { diff --git a/Pixiview/App.cs b/Pixiview/App.cs index 31ab7ed..e3fea30 100644 --- a/Pixiview/App.cs +++ b/Pixiview/App.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using Pixiview.Resources; using Pixiview.UI.Theme; using Pixiview.Utils; +using Xamarin.Essentials; using Xamarin.Forms; namespace Pixiview @@ -11,7 +12,7 @@ namespace Pixiview public class App : Application { // public properties - public static OSAppTheme CurrentTheme { get; private set; } + public static AppTheme CurrentTheme { get; private set; } public static PlatformCulture CurrentCulture { get; private set; } public static Dictionary<string, object> ExtraResources { get; private set; } @@ -28,7 +29,8 @@ namespace Pixiview { ThemeBase.IconLeft, p.IconLeft } }; - var theme = service.GetApplicationTheme(); + //var theme = service.GetApplicationTheme(); + var theme = AppInfo.RequestedTheme; SetTheme(theme, true); } @@ -39,7 +41,7 @@ namespace Pixiview CurrentCulture = new PlatformCulture(ci.Name.ToLower()); } - private void SetTheme(OSAppTheme theme, bool force = false) + private void SetTheme(AppTheme theme, bool force = false) { if (force || theme != CurrentTheme) { @@ -51,7 +53,7 @@ namespace Pixiview } DebugPrint($"application theme: {theme}"); ThemeBase themeInstance; - if (theme == OSAppTheme.Dark) + if (theme == AppTheme.Dark) { themeInstance = DarkTheme.Instance; } @@ -80,7 +82,8 @@ namespace Pixiview protected override void OnResume() { - var theme = DependencyService.Get<IEnvironmentService>().GetApplicationTheme(); + //var theme = DependencyService.Get<IEnvironmentService>().GetApplicationTheme(); + var theme = AppInfo.RequestedTheme; SetTheme(theme); } diff --git a/Pixiview/Illust/IllustCollectionPage.cs b/Pixiview/Illust/IllustCollectionPage.cs index fb6581f..17fab27 100644 --- a/Pixiview/Illust/IllustCollectionPage.cs +++ b/Pixiview/Illust/IllustCollectionPage.cs @@ -294,7 +294,7 @@ namespace Pixiview.Illust TextColor = StyleDefinition.ColorRedBackground, Text = StyleDefinition.IconLove } - .Binding(IsVisibleProperty, nameof(IllustItem.IsFavorite)) + .Binding(IsVisibleProperty, IsFavoriteVisible ? nameof(IllustItem.IsFavorite) : null) .DynamicResource(Label.FontFamilyProperty, ThemeBase.IconSolidFontFamily) } } diff --git a/Pixiview/Illust/RecommendsPage.xaml.cs b/Pixiview/Illust/RecommendsPage.xaml.cs index 5d7c55f..ab6d47f 100644 --- a/Pixiview/Illust/RecommendsPage.xaml.cs +++ b/Pixiview/Illust/RecommendsPage.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using System.Windows.Input; using Pixiview.UI; using Pixiview.Utils; @@ -16,7 +17,7 @@ namespace Pixiview.Illust private static void OnSegmentIndexPropertyChanged(BindableObject obj, object oldValue, object newValue) { var page = (RecommendsPage)obj; - page.DoLoadIllusts(); + Task.Run(() => page.DoLoadIllusts()); } public int SegmentIndex @@ -25,8 +26,6 @@ namespace Pixiview.Illust set => SetValue(SegmentIndexProperty, value); } - private IllustData illustData; - public RecommendsPage() { totalBarOffset = new Thickness(0, AppShell.TotalBarOffset.Top + 40, 0, 0); @@ -103,11 +102,7 @@ namespace Pixiview.Illust protected override IllustData DoLoadIllustData(bool force) { - if (illustData != null && !force) - { - return illustData; - } - illustData = Stores.LoadIllustData(force); + var illustData = Stores.LoadIllustData(force); return illustData; } diff --git a/Pixiview/Illust/ViewIllustPage.xaml.cs b/Pixiview/Illust/ViewIllustPage.xaml.cs index 1b866fd..ae2e794 100644 --- a/Pixiview/Illust/ViewIllustPage.xaml.cs +++ b/Pixiview/Illust/ViewIllustPage.xaml.cs @@ -255,43 +255,68 @@ namespace Pixiview.Illust private async void Illust_LongPressed(IllustDetailItem item) { + var share = ResourceHelper.Share; + string[] extras; + var preview = Stores.GetPreviewImagePath(item.PreviewUrl); + if (string.IsNullOrEmpty(preview)) + { + extras = new string[0]; + } + else + { + extras = new[] { share }; + } var saveOriginal = ResourceHelper.SaveOriginal; var result = await DisplayActionSheet( IllustItem.Title, ResourceHelper.Cancel, - saveOriginal); + saveOriginal, + extras); if (result == saveOriginal) { - if (Stores.CheckIllustImage(item.OriginalUrl)) + SaveOriginalImage(item); + } + else if (result == share) + { + await Share.RequestAsync(new ShareFileRequest { - var flag = await DisplayAlert(ResourceHelper.Operation, - ResourceHelper.AlreadySavedQuestion, - ResourceHelper.Yes, - ResourceHelper.No); - if (!flag) - { - return; - } - } + Title = IllustItem.Title, + File = new ShareFile(preview) + }); + } + } - var status = await Permissions.CheckStatusAsync<Permissions.Photos>(); - if (status != PermissionStatus.Granted) - { - status = await Permissions.RequestAsync<Permissions.Photos>(); - if (status != PermissionStatus.Granted) - { - App.DebugPrint("access denied to gallery."); - return; - } - } - - if (item == null || item.Downloading) + private async void SaveOriginalImage(IllustDetailItem item) + { + if (Stores.CheckIllustImage(item.OriginalUrl)) + { + var flag = await DisplayAlert(ResourceHelper.Operation, + ResourceHelper.AlreadySavedQuestion, + ResourceHelper.Yes, + ResourceHelper.No); + if (!flag) { return; } - item.Downloading = true; - _ = Task.Run(() => DoLoadOriginalImage(item)); } + + var status = await Permissions.CheckStatusAsync<Permissions.Photos>(); + if (status != PermissionStatus.Granted) + { + status = await Permissions.RequestAsync<Permissions.Photos>(); + if (status != PermissionStatus.Granted) + { + App.DebugPrint("access denied to gallery."); + return; + } + } + + if (item == null || item.Downloading) + { + return; + } + item.Downloading = true; + _ = Task.Run(() => DoLoadOriginalImage(item)); } private void DoLoadOriginalImage(IllustDetailItem item) diff --git a/Pixiview/Resources/Languages/zh-CN.xml b/Pixiview/Resources/Languages/zh-CN.xml index 5cad518..5b2bb75 100644 --- a/Pixiview/Resources/Languages/zh-CN.xml +++ b/Pixiview/Resources/Languages/zh-CN.xml @@ -16,6 +16,7 @@ <Preview>预览</Preview> <Operation>操作</Operation> <SaveOriginal>保存原图</SaveOriginal> + <Share>分享</Share> <SaveSuccess>成功保存图片到照片库。</SaveSuccess> <AlreadySavedQuestion>原图已保存,是否继续?</AlreadySavedQuestion> </root> \ No newline at end of file diff --git a/Pixiview/Resources/ResourceHelper.cs b/Pixiview/Resources/ResourceHelper.cs index f0722d7..f51db73 100644 --- a/Pixiview/Resources/ResourceHelper.cs +++ b/Pixiview/Resources/ResourceHelper.cs @@ -18,6 +18,7 @@ namespace Pixiview.Resources public static string R18 => GetResource(nameof(R18)); public static string Operation => GetResource(nameof(Operation)); public static string SaveOriginal => GetResource(nameof(SaveOriginal)); + public static string Share => GetResource(nameof(Share)); public static string SaveSuccess => GetResource(nameof(SaveSuccess)); public static string AlreadySavedQuestion => GetResource(nameof(AlreadySavedQuestion)); diff --git a/Pixiview/Utils/Extensions.cs b/Pixiview/Utils/Extensions.cs index f2c5d06..b43e021 100644 --- a/Pixiview/Utils/Extensions.cs +++ b/Pixiview/Utils/Extensions.cs @@ -6,7 +6,14 @@ namespace Pixiview.Utils { public static T Binding<T>(this T view, BindableProperty property, string name) where T : BindableObject { - view.SetBinding(property, name); + if (name == null) + { + view.SetValue(property, default(T)); + } + else + { + view.SetBinding(property, name); + } return view; } diff --git a/Pixiview/Utils/IEnvironmentService.cs b/Pixiview/Utils/IEnvironmentService.cs index ea7c9da..63be4ee 100644 --- a/Pixiview/Utils/IEnvironmentService.cs +++ b/Pixiview/Utils/IEnvironmentService.cs @@ -7,7 +7,7 @@ namespace Pixiview.Utils { EnvironmentParameter GetEnvironment(); - OSAppTheme GetApplicationTheme(); + //AppTheme GetApplicationTheme(); void SetStatusBarStyle(StatusBarStyles style); void SetStatusBarColor(Color color); diff --git a/Pixiview/Utils/Stores.cs b/Pixiview/Utils/Stores.cs index d826ffa..30e7ec6 100644 --- a/Pixiview/Utils/Stores.cs +++ b/Pixiview/Utils/Stores.cs @@ -248,6 +248,16 @@ namespace Pixiview.Utils return File.Exists(file); } + public static string GetPreviewImagePath(string url) + { + var file = Path.Combine(PersonalFolder, previewFolder, Path.GetFileName(url)); + if (File.Exists(file)) + { + return file; + } + return null; + } + private static ImageSource LoadImage(string url, string working, string folder) { var file = Path.Combine(working, folder, Path.GetFileName(url));