share settings, UI adjust
This commit is contained in:
		| @@ -22,6 +22,7 @@ | ||||
|       "idiom": "iphone" | ||||
|     }, | ||||
|     { | ||||
|       "filename": "pixiv.png", | ||||
|       "scale": "1x", | ||||
|       "idiom": "iphone" | ||||
|     }, | ||||
|   | ||||
| @@ -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> | ||||
|   | ||||
| @@ -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) | ||||
|         { | ||||
|   | ||||
| @@ -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); | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -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) | ||||
|                                 } | ||||
|                             } | ||||
|   | ||||
| @@ -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; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -16,6 +16,7 @@ | ||||
|     <Preview>预览</Preview> | ||||
|     <Operation>操作</Operation> | ||||
|     <SaveOriginal>保存原图</SaveOriginal> | ||||
|     <Share>分享</Share> | ||||
|     <SaveSuccess>成功保存图片到照片库。</SaveSuccess> | ||||
|     <AlreadySavedQuestion>原图已保存,是否继续?</AlreadySavedQuestion> | ||||
| </root> | ||||
| @@ -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)); | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,7 @@ namespace Pixiview.Utils | ||||
|     { | ||||
|         EnvironmentParameter GetEnvironment(); | ||||
|  | ||||
|         OSAppTheme GetApplicationTheme(); | ||||
|         //AppTheme GetApplicationTheme(); | ||||
|         void SetStatusBarStyle(StatusBarStyles style); | ||||
|         void SetStatusBarColor(Color color); | ||||
|  | ||||
|   | ||||
| @@ -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)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user