diff --git a/Pixiview.iOS/Pixiview.iOS.csproj b/Pixiview.iOS/Pixiview.iOS.csproj
index a188d5a..e7a89a4 100644
--- a/Pixiview.iOS/Pixiview.iOS.csproj
+++ b/Pixiview.iOS/Pixiview.iOS.csproj
@@ -72,6 +72,8 @@
+
+
diff --git a/Pixiview.iOS/Renderers/CardViewRenderer.cs b/Pixiview.iOS/Renderers/CardViewRenderer.cs
new file mode 100644
index 0000000..6f2e7d9
--- /dev/null
+++ b/Pixiview.iOS/Renderers/CardViewRenderer.cs
@@ -0,0 +1,53 @@
+using CoreGraphics;
+using Pixiview.iOS.Renderers;
+using Pixiview.UI;
+using UIKit;
+using Xamarin.Forms;
+using Xamarin.Forms.Platform.iOS;
+
+[assembly: ExportRenderer(typeof(CardView), typeof(CardViewRenderer))]
+namespace Pixiview.iOS.Renderers
+{
+ public class CardViewRenderer : VisualElementRenderer
+ {
+ protected override void OnElementChanged(ElementChangedEventArgs e)
+ {
+ base.OnElementChanged(e);
+
+ var layer = Layer;
+ var element = e.NewElement;
+ if (layer != null && element != null)
+ {
+ var cornerRadius = element.CornerRadius;
+ if (cornerRadius > 0)
+ {
+ layer.CornerRadius = cornerRadius;
+ }
+
+ //if (element.BackgroundColor != default)
+ //{
+ // layer.BackgroundColor = element.BackgroundColor.ToCGColor();
+ //}
+
+ var shadowColor = element.ShadowColor;
+ if (shadowColor != default)
+ {
+ layer.ShadowColor = shadowColor.ToCGColor();
+ layer.ShadowOpacity = 1f;
+
+ var radius = element.ShadowRadius;
+ if (radius > 0)
+ {
+ layer.ShadowRadius = radius;
+ }
+
+ layer.ShadowOffset = element.ShadowOffset.ToSizeF();
+ }
+ else
+ {
+ layer.ShadowOpacity = 0f;
+ }
+ }
+ }
+ }
+}
diff --git a/Pixiview.iOS/Renderers/CircleImageRenderer.cs b/Pixiview.iOS/Renderers/CircleImageRenderer.cs
index 85f77a2..69c40a4 100644
--- a/Pixiview.iOS/Renderers/CircleImageRenderer.cs
+++ b/Pixiview.iOS/Renderers/CircleImageRenderer.cs
@@ -12,9 +12,10 @@ namespace Pixiview.iOS.Renderers
{
base.OnElementChanged(e);
- if (Control != null)
+ var layer = Layer;
+ if (layer != null)
{
- Control.Layer.MasksToBounds = true;
+ layer.MasksToBounds = true;
}
}
@@ -22,9 +23,10 @@ namespace Pixiview.iOS.Renderers
{
base.LayoutSubviews();
- if (Control != null)
+ var control = Control;
+ if (control != null)
{
- Control.Layer.CornerRadius = Control.Frame.Size.Width / 2;
+ control.Layer.CornerRadius = control.Frame.Size.Width / 2;
}
}
}
diff --git a/Pixiview.iOS/Renderers/RoundImageRenderer.cs b/Pixiview.iOS/Renderers/RoundImageRenderer.cs
new file mode 100644
index 0000000..94af638
--- /dev/null
+++ b/Pixiview.iOS/Renderers/RoundImageRenderer.cs
@@ -0,0 +1,56 @@
+using CoreAnimation;
+using Pixiview.iOS.Renderers;
+using Pixiview.UI;
+using Xamarin.Forms;
+using Xamarin.Forms.Platform.iOS;
+
+[assembly: ExportRenderer(typeof(RoundImage), typeof(RoundImageRenderer))]
+namespace Pixiview.iOS.Renderers
+{
+ public class RoundImageRenderer : ImageRenderer
+ {
+ protected override void OnElementChanged(ElementChangedEventArgs e)
+ {
+ base.OnElementChanged(e);
+
+ var layer = Layer;
+ if (layer != null && e.NewElement is RoundImage image)
+ {
+ bool flag = false;
+ if (image.CornerRadius > 0)
+ {
+ layer.CornerRadius = image.CornerRadius;
+ flag = true;
+ }
+ var mask = image.CornerMasks;
+ if (mask != CornerMask.None)
+ {
+ var m = default(CACornerMask);
+ if ((mask & CornerMask.LeftTop) == CornerMask.LeftTop)
+ {
+ m |= CACornerMask.MinXMinYCorner;
+ }
+ if ((mask & CornerMask.RightTop) == CornerMask.RightTop)
+ {
+ m |= CACornerMask.MaxXMinYCorner;
+ }
+ if ((mask & CornerMask.LeftBottom) == CornerMask.LeftBottom)
+ {
+ m |= CACornerMask.MinXMaxYCorner;
+ }
+ if ((mask & CornerMask.RightBottom) == CornerMask.RightBottom)
+ {
+ m |= CACornerMask.MaxXMaxYCorner;
+ }
+
+ layer.MaskedCorners = m;
+ flag = true;
+ }
+ if (flag)
+ {
+ layer.MasksToBounds = true;
+ }
+ }
+ }
+ }
+}
diff --git a/Pixiview.iOS/Renderers/RoundLabelRenderer.cs b/Pixiview.iOS/Renderers/RoundLabelRenderer.cs
index 27f5fae..d9931ae 100644
--- a/Pixiview.iOS/Renderers/RoundLabelRenderer.cs
+++ b/Pixiview.iOS/Renderers/RoundLabelRenderer.cs
@@ -13,14 +13,22 @@ namespace Pixiview.iOS.Renderers
{
base.OnElementChanged(e);
- if (Control != null && Element is RoundLabel label)
+ var layer = Layer;
+ if (layer != null && e.NewElement is RoundLabel label)
{
- int radius = label.CornerRadius;
+ var radius = label.CornerRadius;
if (radius > 0)
{
- Control.Layer.CornerRadius = radius;
- Control.BackgroundColor = label.BackgroundColor.ToUIColor();
- Control.Layer.MasksToBounds = true;
+ layer.CornerRadius = radius;
+ //layer.MasksToBounds = true;
+ }
+ else
+ {
+ layer.CornerRadius = 0;
+ }
+ if (layer.BackgroundColor != default)
+ {
+ layer.BackgroundColor = label.BackgroundColor.ToCGColor();
}
}
}
@@ -31,14 +39,15 @@ namespace Pixiview.iOS.Renderers
if (e.PropertyName == RoundLabel.CornerRadiusProperty.PropertyName)
{
- if (Control != null && Element is RoundLabel label)
+ var layer = Layer;
+ if (layer != null && Element is RoundLabel label)
{
- int radius = label.CornerRadius;
+ var radius = label.CornerRadius;
if (radius > 0)
{
- Control.Layer.CornerRadius = radius;
- Control.BackgroundColor = label.BackgroundColor.ToUIColor();
- Control.Layer.MasksToBounds = true;
+ layer.CornerRadius = radius;
+ layer.BackgroundColor = label.BackgroundColor.ToCGColor();
+ //layer.MasksToBounds = true;
}
}
}
diff --git a/Pixiview.iOS/Services/EnvironmentService.cs b/Pixiview.iOS/Services/EnvironmentService.cs
index 6f70d75..dca6429 100644
--- a/Pixiview.iOS/Services/EnvironmentService.cs
+++ b/Pixiview.iOS/Services/EnvironmentService.cs
@@ -1,5 +1,8 @@
-using Pixiview.iOS.Services;
+using System.Diagnostics.CodeAnalysis;
+using Pixiview.iOS.Services;
using Pixiview.Utils;
+using UIKit;
+using Xamarin.Essentials;
using Xamarin.Forms;
[assembly: Dependency(typeof(EnvironmentService))]
@@ -7,6 +10,32 @@ namespace Pixiview.iOS.Services
{
public class EnvironmentService : IEnvironmentService
{
+ [SuppressMessage("Code Notifications", "XI0002:Notifies you from using newer Apple APIs when targeting an older OS version", Justification = "")]
+ public Theme GetApplicationTheme()
+ {
+ if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
+ {
+ var currentController = Platform.GetCurrentUIViewController();
+ if (currentController == null)
+ {
+ return Theme.Light;
+ }
+ var style = currentController.TraitCollection.UserInterfaceStyle;
+ if (style == UIUserInterfaceStyle.Dark)
+ {
+ return Theme.Dark;
+ }
+ else
+ {
+ return Theme.Light;
+ }
+ }
+ else
+ {
+ return Theme.Light;
+ }
+ }
+
public EnvironmentParameter GetEnvironment()
{
return new EnvironmentParameter
@@ -18,5 +47,10 @@ namespace Pixiview.iOS.Services
IconLeft = "\uf104" // for android, it's "\uf060"
};
}
+
+ public void SetStatusBarColor(Color color)
+ {
+ // nothing need to do
+ }
}
}
diff --git a/Pixiview/App.cs b/Pixiview/App.cs
new file mode 100644
index 0000000..77180ec
--- /dev/null
+++ b/Pixiview/App.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using Pixiview.UI.Theme;
+using Pixiview.Utils;
+using Xamarin.Forms;
+
+namespace Pixiview
+{
+ public class App : Application
+ {
+ // public properties
+ public static Theme CurrentTheme { get; private set; }
+ public static Dictionary ExtraResources { get; private set; }
+
+ public App()
+ {
+ InitResources();
+ }
+
+ private void InitResources()
+ {
+ var service = DependencyService.Get();
+ 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();
+ SetTheme(theme, true);
+ }
+
+ private void SetTheme(Theme theme, bool force = false)
+ {
+ if (force || theme != CurrentTheme)
+ {
+ CurrentTheme = theme;
+ }
+ else
+ {
+ return;
+ }
+ DebugPrint($"application theme: {theme}");
+ ThemeBase themeInstance;
+ if (theme == Theme.Dark)
+ {
+ themeInstance = DarkTheme.Instance;
+ }
+ else
+ {
+ themeInstance = LightTheme.Instance;
+ }
+ //DependencyService.Get().SetStatusBarColor
+ Resources = themeInstance;
+ }
+
+ protected override void OnStart()
+ {
+ MainPage = UIFactory.CreateNavigationPage(new MainPage());
+ }
+
+ protected override void OnSleep()
+ {
+ }
+
+ protected override void OnResume()
+ {
+ var theme = DependencyService.Get().GetApplicationTheme();
+ SetTheme(theme);
+ }
+
+ public static void DebugPrint(string message)
+ {
+ Debug.WriteLine("[{0:HH:mm:ss.ffff}] - {1}", DateTime.Now, message);
+ }
+
+ public static void DebugError(string category, string message)
+ {
+ Debug.Fail(string.Format("[{0:HH:mm:ss.ffff}] - {1} - {2}", DateTime.Now, category, message));
+ }
+ }
+}
diff --git a/Pixiview/MainPage.xaml b/Pixiview/MainPage.xaml
index 16edc0a..58582d7 100644
--- a/Pixiview/MainPage.xaml
+++ b/Pixiview/MainPage.xaml
@@ -14,54 +14,64 @@
LeftButtonClicked="NavigationTitle_LeftButtonClicked"
RightButtonClicked="NavigationTitle_RightButtonClicked"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ FontSize="Small"/>
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Pixiview/MainPage.xaml.cs b/Pixiview/MainPage.xaml.cs
index 604a07e..1730c01 100644
--- a/Pixiview/MainPage.xaml.cs
+++ b/Pixiview/MainPage.xaml.cs
@@ -20,6 +20,20 @@ namespace Pixiview
nameof(Illusts), typeof(IllustCollection), typeof(MainPage));
public static readonly BindableProperty ColumnsProperty = BindableProperty.Create(
nameof(Columns), typeof(int), typeof(MainPage), 2);
+ public static readonly BindableProperty LoadingProperty = BindableProperty.Create(
+ nameof(Loading), typeof(bool), typeof(MainPage), propertyChanged: OnLoadingPropertyChanged);
+
+ private static void OnLoadingPropertyChanged(BindableObject obj, object oldValue, object newValue)
+ {
+ var page = (MainPage)obj;
+ var before = (bool)oldValue;
+ var now = (bool)newValue;
+ if (!page.loaded && now && Stores.NetworkAvailable)
+ {
+ page.loaded = true;
+ Task.Run(page.DoLoadIllusts);
+ }
+ }
public IllustCollection Illusts
{
@@ -31,6 +45,11 @@ namespace Pixiview
get => (int)GetValue(ColumnsProperty);
set => SetValue(ColumnsProperty, value);
}
+ public bool Loading
+ {
+ get => (bool)GetValue(LoadingProperty);
+ set => SetValue(LoadingProperty, value);
+ }
private readonly ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Configs.MaxThreads };
@@ -54,11 +73,7 @@ namespace Pixiview
base.OnAppearing();
Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;
- if (!loaded && Stores.NetworkAvailable)
- {
- loaded = true;
- Task.Run(DoLoadIllusts);
- }
+ Loading = true;
}
protected override void OnDisappearing()
@@ -70,10 +85,9 @@ namespace Pixiview
private void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
{
- if (!loaded && (e.NetworkAccess == NetworkAccess.Internet || e.NetworkAccess == NetworkAccess.ConstrainedInternet))
+ if (e.NetworkAccess == NetworkAccess.Internet || e.NetworkAccess == NetworkAccess.ConstrainedInternet)
{
- loaded = true;
- Task.Run(DoLoadIllusts);
+ Loading = true;
}
}
@@ -108,6 +122,7 @@ namespace Pixiview
var collection = new IllustCollection(data);
Illusts = collection;
+ Loading = false;
DoLoadImages(collection);
}
diff --git a/Pixiview/Pixiview.csproj b/Pixiview/Pixiview.csproj
index d5405d3..7ae65c0 100644
--- a/Pixiview/Pixiview.csproj
+++ b/Pixiview/Pixiview.csproj
@@ -18,5 +18,6 @@
+
\ No newline at end of file
diff --git a/Pixiview/UI/CardView.cs b/Pixiview/UI/CardView.cs
new file mode 100644
index 0000000..9c253fc
--- /dev/null
+++ b/Pixiview/UI/CardView.cs
@@ -0,0 +1,38 @@
+using Xamarin.Forms;
+
+namespace Pixiview.UI
+{
+ public class CardView : ContentView
+ {
+ public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(
+ nameof(CornerRadius), typeof(float), typeof(CardView));
+ public static readonly BindableProperty ShadowColorProperty = BindableProperty.Create(
+ nameof(ShadowColor), typeof(Color), typeof(CardView));
+ public static readonly BindableProperty ShadowRadiusProperty = BindableProperty.Create(
+ nameof(ShadowRadius), typeof(float), typeof(CardView), 5f);
+ public static readonly BindableProperty ShadowOffsetProperty = BindableProperty.Create(
+ nameof(ShadowOffset), typeof(Size), typeof(CardView));
+
+ public float CornerRadius
+ {
+ get => (float)GetValue(CornerRadiusProperty);
+ set => SetValue(CornerRadiusProperty, value);
+ }
+ public Color ShadowColor
+ {
+ get => (Color)GetValue(ShadowColorProperty);
+ set => SetValue(ShadowColorProperty, value);
+ }
+ public float ShadowRadius
+ {
+ get => (float)GetValue(ShadowRadiusProperty);
+ set => SetValue(ShadowRadiusProperty, value);
+ }
+ public Size ShadowOffset
+ {
+ get => (Size)GetValue(ShadowOffsetProperty);
+ set => SetValue(ShadowOffsetProperty, value);
+ }
+ }
+}
+
diff --git a/Pixiview/UI/CircleUIs.cs b/Pixiview/UI/CircleUIs.cs
index 1906dfc..0e56531 100644
--- a/Pixiview/UI/CircleUIs.cs
+++ b/Pixiview/UI/CircleUIs.cs
@@ -4,16 +4,59 @@ namespace Pixiview.UI
{
public class CircleImage : Image { }
+ public class RoundImage : Image
+ {
+ public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(
+ nameof(CornerRadius), typeof(float), typeof(RoundImage));
+ public static readonly BindableProperty CornerMasksProperty = BindableProperty.Create(
+ nameof(CornerMasks), typeof(CornerMask), typeof(RoundImage));
+
+ public float CornerRadius
+ {
+ get => (float)GetValue(CornerRadiusProperty);
+ set => SetValue(CornerRadiusProperty, value);
+ }
+ public CornerMask CornerMasks
+ {
+ get => (CornerMask)GetValue(CornerMasksProperty);
+ set => SetValue(CornerMasksProperty, value);
+ }
+ }
+
+ public enum CornerMask
+ {
+ None = 0,
+
+ LeftTop = 1,
+ RightTop = 2,
+ LeftBottom = 4,
+ RightBottom = 8,
+
+ Top = LeftTop | RightTop, // 3
+ Left = LeftTop | LeftBottom, // 5
+ Slash = RightTop | LeftBottom, // 6
+ BackSlash = LeftTop | RightBottom, // 9
+ Right = RightTop | RightBottom, // 10
+ Bottom = LeftBottom | RightBottom, // 12
+
+ ExceptRightBottom = LeftTop | RightTop | LeftBottom, // 7
+ ExceptLeftBottom = LeftTop | RightTop | RightBottom, // 11
+ ExceptRightTop = LeftTop | LeftBottom | RightBottom, // 13
+ ExceptLeftTop = RightTop | LeftBottom | RightBottom, // 14
+
+ All = LeftTop | RightTop | LeftBottom | RightBottom // 15
+ }
+
public class RoundLabel : Label
{
public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(
- nameof(CornerRadius), typeof(int), typeof(RoundLabel));
+ nameof(CornerRadius), typeof(float), typeof(RoundLabel));
public static new readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(
nameof(BackgroundColor), typeof(Color), typeof(RoundLabel), Color.Transparent);
- public int CornerRadius
+ public float CornerRadius
{
- get => (int)GetValue(CornerRadiusProperty);
+ get => (float)GetValue(CornerRadiusProperty);
set => SetValue(CornerRadiusProperty, value);
}
public new Color BackgroundColor
diff --git a/Pixiview/UI/NavigationTitle.cs b/Pixiview/UI/NavigationTitle.cs
index 6db773c..faced7e 100644
--- a/Pixiview/UI/NavigationTitle.cs
+++ b/Pixiview/UI/NavigationTitle.cs
@@ -1,4 +1,5 @@
using System;
+using Pixiview.UI.Theme;
using Xamarin.Forms;
namespace Pixiview.UI
@@ -44,12 +45,12 @@ namespace Pixiview.UI
var left = GetLinkButton(nameof(IsLeftButtonVisible),
padding: StyleDefinition.HorizonRight10);
- left.SetDynamicResource(Button.FontFamilyProperty, App.IconRegularFontFamily);
- left.SetDynamicResource(Button.TextProperty, App.IconLeft);
+ left.SetDynamicResource(Button.FontFamilyProperty, ThemeBase.IconRegularFontFamily);
+ left.SetDynamicResource(Button.TextProperty, ThemeBase.IconLeft);
left.Clicked += Left_Clicked;
var title = new Label();
- title.SetDynamicResource(StyleProperty, App.TitleLabel);
+ title.SetDynamicResource(StyleProperty, ThemeBase.TitleLabel);
title.SetBinding(Label.TextProperty, nameof(Title));
Grid.SetColumnSpan(title, 3);
@@ -96,7 +97,7 @@ namespace Pixiview.UI
{
button.SetBinding(Button.TextProperty, text);
}
- button.SetDynamicResource(StyleProperty, App.TitleButton);
+ button.SetDynamicResource(StyleProperty, ThemeBase.TitleButton);
return button;
}
}
diff --git a/Pixiview/UI/Theme/DarkTheme.cs b/Pixiview/UI/Theme/DarkTheme.cs
new file mode 100644
index 0000000..e490126
--- /dev/null
+++ b/Pixiview/UI/Theme/DarkTheme.cs
@@ -0,0 +1,37 @@
+using Xamarin.Forms;
+
+namespace Pixiview.UI.Theme
+{
+ public partial class DarkTheme : ThemeBase
+ {
+ private static DarkTheme _instance;
+
+ public static DarkTheme Instance
+ {
+ get
+ {
+ if (_instance == null)
+ {
+ _instance = new DarkTheme();
+ }
+ return _instance;
+ }
+ }
+
+ public DarkTheme()
+ {
+ InitColors();
+ InitResources();
+ }
+
+ private void InitColors()
+ {
+ Add(WindowColor, Color.Black);
+ Add(TextColor, Color.White);
+ Add(SubTextColor, Color.LightGray);
+ Add(MainColor, Color.FromRgb(0x33, 0x33, 0x33));
+ Add(MainTextColor, Color.White);
+ Add(SubColor, Color.FromRgb(0x33, 0x33, 0x33));
+ }
+ }
+}
diff --git a/Pixiview/UI/Theme/LightTheme.cs b/Pixiview/UI/Theme/LightTheme.cs
new file mode 100644
index 0000000..5bdd1d5
--- /dev/null
+++ b/Pixiview/UI/Theme/LightTheme.cs
@@ -0,0 +1,37 @@
+using Xamarin.Forms;
+
+namespace Pixiview.UI.Theme
+{
+ public partial class LightTheme : ThemeBase
+ {
+ private static LightTheme _instance;
+
+ public static LightTheme Instance
+ {
+ get
+ {
+ if (_instance == null)
+ {
+ _instance = new LightTheme();
+ }
+ return _instance;
+ }
+ }
+
+ public LightTheme()
+ {
+ InitColors();
+ InitResources();
+ }
+
+ private void InitColors()
+ {
+ Add(WindowColor, Color.White);
+ Add(TextColor, Color.Black);
+ Add(SubTextColor, Color.DimGray);
+ Add(MainColor, Color.FromRgb(0x7f, 0x99, 0xc6));
+ Add(MainTextColor, Color.White);
+ Add(SubColor, Color.FromRgb(0xfa, 0xfa, 0xf0));
+ }
+ }
+}
diff --git a/Pixiview/UI/Theme/ThemeBase.cs b/Pixiview/UI/Theme/ThemeBase.cs
new file mode 100644
index 0000000..2395836
--- /dev/null
+++ b/Pixiview/UI/Theme/ThemeBase.cs
@@ -0,0 +1,63 @@
+using Xamarin.Forms;
+
+namespace Pixiview.UI.Theme
+{
+ public class ThemeBase : ResourceDictionary
+ {
+ public const string TitleButton = nameof(TitleButton);
+ public const string TitleLabel = nameof(TitleLabel);
+
+ public const string WindowColor = nameof(WindowColor);
+ public const string TextColor = nameof(TextColor);
+ public const string SubTextColor = nameof(SubTextColor);
+ public const string MainColor = nameof(MainColor);
+ public const string MainTextColor = nameof(MainTextColor);
+ public const string SubColor = nameof(SubColor);
+
+ 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);
+
+ protected void InitResources()
+ {
+ Add(FontSizeTitle, StyleDefinition.FontSizeTitle);
+ Add(FontSizeTitleIcon, StyleDefinition.FontSizeTitleIcon);
+ //Add(Horizon10, StyleDefinition.Horizon10);
+
+ if (App.ExtraResources != null)
+ {
+ foreach (var kv in App.ExtraResources)
+ {
+ Add(kv.Key, kv.Value);
+ }
+ }
+
+ Add(TitleLabel, new Style(typeof(Label))
+ {
+ Setters =
+ {
+ new Setter { Property = View.VerticalOptionsProperty, Value = LayoutOptions.Center },
+ new Setter { Property = View.HorizontalOptionsProperty, Value = LayoutOptions.Fill },
+ new Setter { Property = Label.HorizontalTextAlignmentProperty, Value = TextAlignment.Center },
+ new Setter { Property = Label.FontSizeProperty, Value = StyleDefinition.FontSizeTitle },
+ new Setter { Property = Label.TextColorProperty, Value = this[MainTextColor] }
+ }
+ });
+ Add(TitleButton, new Style(typeof(Button))
+ {
+ Setters =
+ {
+ new Setter { Property = Button.BorderWidthProperty, Value = 0.0 },
+ new Setter { Property = VisualElement.BackgroundColorProperty, Value = Color.Transparent },
+ new Setter { Property = Button.FontFamilyProperty, Value = this[IconSolidFontFamily] },
+ new Setter { Property = Button.FontSizeProperty, Value = StyleDefinition.FontSizeTitleIcon },
+ new Setter { Property = Button.TextColorProperty, Value = this[MainTextColor] }
+ }
+ });
+ }
+ }
+}
diff --git a/Pixiview/Utils/IEnvironmentService.cs b/Pixiview/Utils/IEnvironmentService.cs
index 0103cb9..fc37ea5 100644
--- a/Pixiview/Utils/IEnvironmentService.cs
+++ b/Pixiview/Utils/IEnvironmentService.cs
@@ -1,9 +1,12 @@
-
+using Xamarin.Forms;
+
namespace Pixiview.Utils
{
public interface IEnvironmentService
{
EnvironmentParameter GetEnvironment();
+ Theme GetApplicationTheme();
+ void SetStatusBarColor(Color color);
}
public class EnvironmentParameter
@@ -13,4 +16,10 @@ namespace Pixiview.Utils
public string IconSolidFontFamily { get; set; }
public string IconLeft { get; set; }
}
+
+ public enum Theme
+ {
+ Light,
+ Dark
+ }
}
diff --git a/Pixiview/Utils/UIFactory.cs b/Pixiview/Utils/UIFactory.cs
index b84882b..d90e306 100644
--- a/Pixiview/Utils/UIFactory.cs
+++ b/Pixiview/Utils/UIFactory.cs
@@ -1,4 +1,5 @@
-using Xamarin.Forms;
+using Pixiview.UI.Theme;
+using Xamarin.Forms;
namespace Pixiview.Utils
{
@@ -7,9 +8,9 @@ namespace Pixiview.Utils
public static NavigationPage CreateNavigationPage(Page root)
{
var navigation = new NavigationPage(root);
- navigation.SetDynamicResource(NavigationPage.BarBackgroundColorProperty, App.MainColor);
- navigation.SetDynamicResource(NavigationPage.BarTextColorProperty, App.MainTextColor);
- navigation.SetDynamicResource(VisualElement.BackgroundColorProperty, App.WindowColor);
+ navigation.SetDynamicResource(NavigationPage.BarBackgroundColorProperty, ThemeBase.MainColor);
+ navigation.SetDynamicResource(NavigationPage.BarTextColorProperty, ThemeBase.MainTextColor);
+ navigation.SetDynamicResource(VisualElement.BackgroundColorProperty, ThemeBase.WindowColor);
return navigation;
}
}