diff --git a/Pixiview.iOS/Pixiview.iOS.csproj b/Pixiview.iOS/Pixiview.iOS.csproj
index fc85f28..a15cffe 100644
--- a/Pixiview.iOS/Pixiview.iOS.csproj
+++ b/Pixiview.iOS/Pixiview.iOS.csproj
@@ -70,13 +70,11 @@
-
-
@@ -157,7 +155,6 @@
-
diff --git a/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs b/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs
index 38ace7b..9c79508 100644
--- a/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs
+++ b/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs
@@ -1,6 +1,5 @@
using Foundation;
using Pixiview.iOS.Renderers;
-using Pixiview.iOS.Services;
using Pixiview.UI;
using Pixiview.Utils;
using UIKit;
diff --git a/Pixiview/App.cs b/Pixiview/App.cs
index 3c14f39..47fb48f 100644
--- a/Pixiview/App.cs
+++ b/Pixiview/App.cs
@@ -18,22 +18,9 @@ namespace Pixiview
// public properties
public static AppTheme CurrentTheme { get; private set; }
public static PlatformCulture CurrentCulture { get; private set; }
- public static Dictionary ExtraResources { get; private set; }
- private void InitResources(IEnvironmentService service)
+ private void InitResources()
{
- var p = service.GetEnvironment();
-
- ExtraResources = new Dictionary
- {
- { ThemeBase.IconLightFontFamily, p.IconLightFontFamily },
- { ThemeBase.IconRegularFontFamily, p.IconRegularFontFamily },
- { ThemeBase.IconSolidFontFamily, p.IconSolidFontFamily },
-
- { ThemeBase.IconLeft, p.IconLeft }
- };
-
- //var theme = service.GetApplicationTheme();
var theme = AppInfo.RequestedTheme;
SetTheme(theme, true);
}
@@ -61,10 +48,10 @@ namespace Pixiview
}
}
- private void InitLanguage(IEnvironmentService service)
+ private void InitLanguage()
{
- var ci = service.GetCurrentCultureInfo();
- service.SetCultureInfo(ci);
+ var ci = EnvironmentService.GetCurrentCultureInfo();
+ EnvironmentService.SetCultureInfo(ci);
CurrentCulture = new PlatformCulture(ci.Name.ToLower());
}
@@ -88,19 +75,20 @@ namespace Pixiview
{
themeInstance = LightTheme.Instance;
}
- //DependencyService.Get().SetStatusBarColor
+#if __ANDROID__
+ EnvironmentService.SetStatusBarColor
+#endif
var style = (StatusBarStyles)themeInstance[ThemeBase.StatusBarStyle];
- DependencyService.Get().SetStatusBarStyle(style);
+ EnvironmentService.SetStatusBarStyle(style);
Resources = themeInstance;
}
protected override void OnStart()
{
- var service = DependencyService.Get();
- InitLanguage(service);
+ InitLanguage();
MainPage = new AppShell();
- InitResources(service);
+ InitResources();
InitPreferences();
}
@@ -110,7 +98,6 @@ namespace Pixiview
protected override void OnResume()
{
- //var theme = DependencyService.Get().GetApplicationTheme();
var theme = AppInfo.RequestedTheme;
SetTheme(theme);
}
diff --git a/Pixiview/Illust/ViewIllustPage.xaml.cs b/Pixiview/Illust/ViewIllustPage.xaml.cs
index 7cba37a..8cc4095 100644
--- a/Pixiview/Illust/ViewIllustPage.xaml.cs
+++ b/Pixiview/Illust/ViewIllustPage.xaml.cs
@@ -345,8 +345,7 @@ namespace Pixiview.Illust
{
MainThread.BeginInvokeOnMainThread(async () =>
{
- var service = DependencyService.Get();
- var result = await service.SaveImageToGalleryAsync(image);
+ var result = await FileStore.SaveImageToGalleryAsync(image);
string message = result ?? ResourceHelper.SaveSuccess;
await DisplayAlert(ResourceHelper.Title, message, ResourceHelper.Ok);
diff --git a/Pixiview/Pixiview.projitems b/Pixiview/Pixiview.projitems
index 4e66d52..29c7c9b 100644
--- a/Pixiview/Pixiview.projitems
+++ b/Pixiview/Pixiview.projitems
@@ -73,8 +73,8 @@
-
-
+
+
diff --git a/Pixiview/UI/StyleDefinition.cs b/Pixiview/UI/StyleDefinition.cs
index 53d8632..989c9dd 100644
--- a/Pixiview/UI/StyleDefinition.cs
+++ b/Pixiview/UI/StyleDefinition.cs
@@ -7,13 +7,8 @@ namespace Pixiview.UI
public static class StyleDefinition
{
public const double FontSizeTitle = 18.0;
- public const double FontSizeTitleIcon = 24.0;
public static readonly Thickness ScreenBottomPadding;
- public static readonly Thickness HorizonLeft10 = new Thickness(10, 0, 0, 0);
- public static readonly Thickness HorizonRight10 = new Thickness(0, 0, 10, 0);
- public static readonly Thickness LeftBottom10 = new Thickness(10, 0, 0, 10);
- public static readonly GridLength TitleIconWidth = 40;
public static readonly Color ColorLightShadow = Color.FromRgba(0, 0, 0, 0x20);
public static readonly Color ColorDeepShadow = Color.FromRgba(0, 0, 0, 0x50);
public static readonly Color ColorRedBackground = Color.FromRgb(0xfd, 0x43, 0x63);
@@ -22,6 +17,16 @@ namespace Pixiview.UI
public static readonly double FontSizeMicro = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
public static readonly double FontSizeSmall = Device.GetNamedSize(NamedSize.Small, typeof(Label));
+#if __IOS__
+ public const string IconLightFontFamily = "FontAwesome5Pro-Light";
+ public const string IconRegularFontFamily = "FontAwesome5Pro-Regular";
+ public const string IconSolidFontFamily = "FontAwesome5Pro-Solid";
+
+ public const string IconLeft = "\uf104";
+#else
+ // TODO
+#endif
+
public const string IconUser = "\uf007";
public const string IconSparkles = "\uf890";
public const string IconOrder = "\uf88f";
@@ -29,7 +34,6 @@ namespace Pixiview.UI
public const string IconRefresh = "\uf2f1";
public const string IconLove = "\uf004";
public const string IconOption = "\uf013";
- public const string IconDownload = "\uf019";
public const string IconFavorite = "\uf02e";
public const string IconShare = "\uf35d";
diff --git a/Pixiview/UI/Theme/ThemeBase.cs b/Pixiview/UI/Theme/ThemeBase.cs
index 81721ac..4f01f1e 100644
--- a/Pixiview/UI/Theme/ThemeBase.cs
+++ b/Pixiview/UI/Theme/ThemeBase.cs
@@ -11,7 +11,6 @@ namespace Pixiview.UI.Theme
public const string FontIconLove = nameof(FontIconLove);
public const string FontIconNotLove = nameof(FontIconNotLove);
public const string FontIconOption = nameof(FontIconOption);
- public const string FontIconDownload = nameof(FontIconDownload);
public const string FontIconFavorite = nameof(FontIconFavorite);
public const string FontIconShare = nameof(FontIconShare);
@@ -29,36 +28,20 @@ namespace Pixiview.UI.Theme
public const string IconLightFontFamily = nameof(IconLightFontFamily);
public const string IconRegularFontFamily = nameof(IconRegularFontFamily);
public const string IconSolidFontFamily = nameof(IconSolidFontFamily);
- public const string IconLeft = nameof(IconLeft);
- public const string FontSizeTitle = nameof(FontSizeTitle);
- public const string FontSizeTitleIcon = nameof(FontSizeTitleIcon);
//public const string Horizon10 = nameof(Horizon10);
public const string ScreenBottomPadding = nameof(ScreenBottomPadding);
- public const string NavigationBarHeight = nameof(NavigationBarHeight);
- public const string IconRefresh = nameof(IconRefresh);
- public const string IconOption = nameof(IconOption);
- public const string IconDownload = nameof(IconDownload);
protected void InitResources()
{
- Add(FontSizeTitle, StyleDefinition.FontSizeTitle);
- Add(FontSizeTitleIcon, StyleDefinition.FontSizeTitleIcon);
//Add(Horizon10, StyleDefinition.Horizon10);
Add(ScreenBottomPadding, StyleDefinition.ScreenBottomPadding);
- Add(IconRefresh, StyleDefinition.IconRefresh);
- Add(IconOption, StyleDefinition.IconOption);
- Add(IconDownload, StyleDefinition.IconDownload);
- if (App.ExtraResources != null)
- {
- foreach (var kv in App.ExtraResources)
- {
- Add(kv.Key, kv.Value);
- }
- }
+ Add(IconLightFontFamily, StyleDefinition.IconLightFontFamily);
+ Add(IconRegularFontFamily, StyleDefinition.IconRegularFontFamily);
+ Add(IconSolidFontFamily, StyleDefinition.IconSolidFontFamily);
- var regularFontFamily = (string)this[IconRegularFontFamily];
- var solidFontFamily = (string)this[IconSolidFontFamily];
+ var regularFontFamily = StyleDefinition.IconRegularFontFamily;
+ var solidFontFamily = StyleDefinition.IconSolidFontFamily;
Add(FontIconLove, GetSolidIcon(StyleDefinition.IconLove, solidFontFamily, StyleDefinition.ColorRedBackground));
Add(FontIconUser, GetSolidIcon(StyleDefinition.IconUser, solidFontFamily));
@@ -67,7 +50,6 @@ namespace Pixiview.UI.Theme
Add(FontIconRefresh, GetSolidIcon(StyleDefinition.IconRefresh, solidFontFamily));
Add(FontIconNotLove, GetSolidIcon(StyleDefinition.IconLove, regularFontFamily));
Add(FontIconOption, GetSolidIcon(StyleDefinition.IconOption, solidFontFamily));
- Add(FontIconDownload, GetSolidIcon(StyleDefinition.IconDownload, solidFontFamily));
Add(FontIconFavorite, GetSolidIcon(StyleDefinition.IconFavorite, solidFontFamily));
Add(FontIconShare, GetSolidIcon(StyleDefinition.IconShare, solidFontFamily));
}
diff --git a/Pixiview.iOS/Services/EnvironmentService.cs b/Pixiview/Utils/EnvironmentService.cs
similarity index 85%
rename from Pixiview.iOS/Services/EnvironmentService.cs
rename to Pixiview/Utils/EnvironmentService.cs
index b8e9777..2028d10 100644
--- a/Pixiview.iOS/Services/EnvironmentService.cs
+++ b/Pixiview/Utils/EnvironmentService.cs
@@ -1,30 +1,16 @@
using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
+using System.Globalization;
using System.Threading;
-using Foundation;
-using Pixiview.iOS.Services;
using Pixiview.Resources;
-using Pixiview.Utils;
+#if __IOS__
+using Foundation;
using UIKit;
-using Xamarin.Forms;
+#endif
-[assembly: Dependency(typeof(EnvironmentService))]
-namespace Pixiview.iOS.Services
+namespace Pixiview.Utils
{
- public class EnvironmentService : IEnvironmentService
+ public class EnvironmentService
{
- public EnvironmentParameter GetEnvironment()
- {
- return new EnvironmentParameter
- {
- IconLightFontFamily = "FontAwesome5Pro-Light",
- IconRegularFontFamily = "FontAwesome5Pro-Regular",
- IconSolidFontFamily = "FontAwesome5Pro-Solid",
-
- IconLeft = "\uf104" // for android, it's "\uf060"
- };
- }
-
#region - Theme -
/*
@@ -54,18 +40,11 @@ namespace Pixiview.iOS.Services
}
//*/
- public void SetStatusBarStyle(StatusBarStyles style)
+ public static void SetStatusBarStyle(StatusBarStyles style)
{
SetStatusBarStyle(ConvertStyle(style));
}
- public void SetStatusBarColor(Color color)
- {
- // nothing need to do
- }
-
- #endregion
-
public static void SetStatusBarStyle(UIStatusBarStyle style)
{
if (UIApplication.SharedApplication.StatusBarStyle == style)
@@ -100,9 +79,19 @@ namespace Pixiview.iOS.Services
}
}
+ #endregion
+
#region - Culture Info -
- public CultureInfo GetCurrentCultureInfo()
+ public static void SetCultureInfo(CultureInfo ci)
+ {
+ Thread.CurrentThread.CurrentCulture = ci;
+ Thread.CurrentThread.CurrentUICulture = ci;
+
+ App.DebugPrint($"CurrentCulture set: {ci.Name}");
+ }
+
+ public static CultureInfo GetCurrentCultureInfo()
{
string lang;
if (NSLocale.PreferredLanguages.Length > 0)
@@ -140,7 +129,7 @@ namespace Pixiview.iOS.Services
}
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "")]
- string iOSToDotnetLanguage(string iOSLanguage)
+ private static string iOSToDotnetLanguage(string iOSLanguage)
{
string netLanguage;
@@ -165,7 +154,7 @@ namespace Pixiview.iOS.Services
return netLanguage;
}
- string ToDotnetFallbackLanguage(PlatformCulture platCulture)
+ private static string ToDotnetFallbackLanguage(PlatformCulture platCulture)
{
string netLanguage;
@@ -189,14 +178,6 @@ namespace Pixiview.iOS.Services
return netLanguage;
}
- public void SetCultureInfo(CultureInfo ci)
- {
- Thread.CurrentThread.CurrentCulture = ci;
- Thread.CurrentThread.CurrentUICulture = ci;
-
- App.DebugPrint($"CurrentCulture set: {ci.Name}");
- }
-
#endregion
}
}
diff --git a/Pixiview.iOS/Services/FileStore.cs b/Pixiview/Utils/FileStore.cs
similarity index 80%
rename from Pixiview.iOS/Services/FileStore.cs
rename to Pixiview/Utils/FileStore.cs
index 3e29a7c..bf82036 100644
--- a/Pixiview.iOS/Services/FileStore.cs
+++ b/Pixiview/Utils/FileStore.cs
@@ -1,17 +1,18 @@
-using System.Threading.Tasks;
-using Pixiview.iOS.Services;
-using Pixiview.Utils;
+using System.Threading.Tasks;
using Xamarin.Forms;
+#if __IOS__
using Xamarin.Forms.Platform.iOS;
+#else
+using Xamarin.Forms.Platform.Android;
+#endif
-[assembly: Dependency(typeof(FileStore))]
-namespace Pixiview.iOS.Services
+namespace Pixiview.Utils
{
- public class FileStore : IFileStore
+ public class FileStore
{
-
- public Task SaveImageToGalleryAsync(ImageSource image)
+ public static Task SaveImageToGalleryAsync(ImageSource image)
{
+#if __IOS__
IImageSourceHandler renderer;
if (image is UriImageSource)
{
@@ -40,6 +41,9 @@ namespace Pixiview.iOS.Services
});
}
return task.Task;
+#else
+ // TODO
+#endif
}
}
}
diff --git a/Pixiview/Utils/IEnvironmentService.cs b/Pixiview/Utils/IEnvironmentService.cs
deleted file mode 100644
index 63be4ee..0000000
--- a/Pixiview/Utils/IEnvironmentService.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System.Globalization;
-using Xamarin.Forms;
-
-namespace Pixiview.Utils
-{
- public interface IEnvironmentService
- {
- EnvironmentParameter GetEnvironment();
-
- //AppTheme GetApplicationTheme();
- void SetStatusBarStyle(StatusBarStyles style);
- void SetStatusBarColor(Color color);
-
- CultureInfo GetCurrentCultureInfo();
- void SetCultureInfo(CultureInfo ci);
- }
-
- public class EnvironmentParameter
- {
- public string IconLightFontFamily { get; set; }
- public string IconRegularFontFamily { get; set; }
- public string IconSolidFontFamily { get; set; }
- public string IconLeft { get; set; }
- }
-}
diff --git a/Pixiview/Utils/IFileStore.cs b/Pixiview/Utils/IFileStore.cs
deleted file mode 100644
index bfba038..0000000
--- a/Pixiview/Utils/IFileStore.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Threading.Tasks;
-using Xamarin.Forms;
-
-namespace Pixiview.Utils
-{
- public interface IFileStore
- {
- Task SaveImageToGalleryAsync(ImageSource image);
- }
-}