diff --git a/Pixiview.iOS/Pixiview.iOS.csproj b/Pixiview.iOS/Pixiview.iOS.csproj index 93ee590..fc5ab43 100644 --- a/Pixiview.iOS/Pixiview.iOS.csproj +++ b/Pixiview.iOS/Pixiview.iOS.csproj @@ -76,6 +76,7 @@ + @@ -149,5 +150,6 @@ + \ No newline at end of file diff --git a/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs b/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs index df6b31c..546d3ce 100644 --- a/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs +++ b/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs @@ -39,8 +39,6 @@ namespace Pixiview.iOS.Renderers base.Dispose(disposing); } - public override bool PrefersHomeIndicatorAutoHidden => Screen.GetHomeIndicatorAutoHidden(Element); - public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); diff --git a/Pixiview.iOS/Renderers/AppShellRenderer.cs b/Pixiview.iOS/Renderers/AppShellRenderer.cs new file mode 100644 index 0000000..c53bda9 --- /dev/null +++ b/Pixiview.iOS/Renderers/AppShellRenderer.cs @@ -0,0 +1,26 @@ +using Pixiview.iOS.Renderers; +using Pixiview.Utils; +using UIKit; +using Xamarin.Forms; +using Xamarin.Forms.Platform.iOS; + +[assembly: ExportRenderer(typeof(Shell), typeof(AppShellRenderer))] +namespace Pixiview.iOS.Renderers +{ + public class AppShellRenderer : ShellRenderer + { + public override bool PrefersHomeIndicatorAutoHidden => Screen.GetHomeIndicatorAutoHidden(Element); + + protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection shellSection) + { + var renderer = base.CreateShellSectionRenderer(shellSection); + if (renderer is ShellSectionRenderer sr && Element is AppShell shell) + { + shell.SetNavigationBarHeight( + sr.NavigationBar.Frame.Height, + UIApplication.SharedApplication.StatusBarFrame.Height); + } + return renderer; + } + } +} diff --git a/Pixiview.iOS/Resources/userprofile.jpg b/Pixiview.iOS/Resources/userprofile.jpg new file mode 100644 index 0000000..91428d8 Binary files /dev/null and b/Pixiview.iOS/Resources/userprofile.jpg differ diff --git a/Pixiview/AppShell.xaml b/Pixiview/AppShell.xaml index d83328a..fb90033 100644 --- a/Pixiview/AppShell.xaml +++ b/Pixiview/AppShell.xaml @@ -2,22 +2,42 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/Pixiview/AppShell.xaml.cs b/Pixiview/AppShell.xaml.cs index e1fc87c..ec476b0 100644 --- a/Pixiview/AppShell.xaml.cs +++ b/Pixiview/AppShell.xaml.cs @@ -1,12 +1,38 @@ -using Xamarin.Forms; +using System; +using Xamarin.Forms; namespace Pixiview { public partial class AppShell : Shell { + public static new AppShell Current => Shell.Current as AppShell; + + public static Thickness NavigationBarOffset { get; private set; } + public static Thickness TotalBarOffset { get; private set; } + + public event EventHandler NavigationBarHeightChanged; + public AppShell() { InitializeComponent(); } + + public void SetNavigationBarHeight(double height, double statusHeight) + { + NavigationBarOffset = new Thickness(0, height, 0, 0); + TotalBarOffset = new Thickness(0, height + statusHeight, 0, 0); + + NavigationBarHeightChanged?.Invoke(this, new BarHeightEventArgs + { + NavigationBarHeight = height, + StatusBarHeight = statusHeight + }); + } + } + + public class BarHeightEventArgs : EventArgs + { + public double NavigationBarHeight { get; set; } + public double StatusBarHeight { get; set; } } } diff --git a/Pixiview/MainPage.xaml b/Pixiview/Illust/MainPage.xaml similarity index 89% rename from Pixiview/MainPage.xaml rename to Pixiview/Illust/MainPage.xaml index 6c52cce..5449465 100644 --- a/Pixiview/MainPage.xaml +++ b/Pixiview/Illust/MainPage.xaml @@ -3,12 +3,12 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:p="clr-namespace:Pixiview" + xmlns:mdl="clr-namespace:Pixiview.Illust" xmlns:u="clr-namespace:Pixiview.UI" xmlns:util="clr-namespace:Pixiview.Utils" xmlns:r="clr-namespace:Pixiview.Resources" mc:Ignorable="d" - x:Class="Pixiview.MainPage" + x:Class="Pixiview.Illust.MainPage" util:Screen.StatusBarStyle="{DynamicResource StatusBarStyle}" Shell.NavBarHasShadow="True" BackgroundColor="{DynamicResource WindowColor}" @@ -19,12 +19,12 @@ IconImageSource="{DynamicResource FontIconRefresh}"/> - + - + - + + + \ No newline at end of file diff --git a/Pixiview/MainPage.xaml.cs b/Pixiview/Illust/MainPage.xaml.cs similarity index 99% rename from Pixiview/MainPage.xaml.cs rename to Pixiview/Illust/MainPage.xaml.cs index 316badc..4c16705 100644 --- a/Pixiview/MainPage.xaml.cs +++ b/Pixiview/Illust/MainPage.xaml.cs @@ -10,7 +10,7 @@ using Pixiview.Utils; using Xamarin.Essentials; using Xamarin.Forms; -namespace Pixiview +namespace Pixiview.Illust { // Learn more about making custom code visible in the Xamarin.Forms previewer // by visiting https://aka.ms/xamarinforms-previewer diff --git a/Pixiview/NewsPage.xaml b/Pixiview/Illust/NewsPage.xaml similarity index 93% rename from Pixiview/NewsPage.xaml rename to Pixiview/Illust/NewsPage.xaml index 118c615..85bd6c1 100644 --- a/Pixiview/NewsPage.xaml +++ b/Pixiview/Illust/NewsPage.xaml @@ -1,5 +1,5 @@  - + diff --git a/Pixiview/NewsPage.xaml.cs b/Pixiview/Illust/NewsPage.xaml.cs similarity index 89% rename from Pixiview/NewsPage.xaml.cs rename to Pixiview/Illust/NewsPage.xaml.cs index 795b7f2..279895f 100644 --- a/Pixiview/NewsPage.xaml.cs +++ b/Pixiview/Illust/NewsPage.xaml.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Xamarin.Forms; -namespace Pixiview +namespace Pixiview.Illust { public partial class NewsPage : ContentPage { diff --git a/Pixiview/RankingPage.xaml b/Pixiview/Illust/RankingPage.xaml similarity index 92% rename from Pixiview/RankingPage.xaml rename to Pixiview/Illust/RankingPage.xaml index 0067e83..e09bc73 100644 --- a/Pixiview/RankingPage.xaml +++ b/Pixiview/Illust/RankingPage.xaml @@ -1,5 +1,5 @@  - + diff --git a/Pixiview/RankingPage.xaml.cs b/Pixiview/Illust/RankingPage.xaml.cs similarity index 89% rename from Pixiview/RankingPage.xaml.cs rename to Pixiview/Illust/RankingPage.xaml.cs index caf3382..b47b5ff 100644 --- a/Pixiview/RankingPage.xaml.cs +++ b/Pixiview/Illust/RankingPage.xaml.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Xamarin.Forms; -namespace Pixiview +namespace Pixiview.Illust { public partial class RankingPage : ContentPage { diff --git a/Pixiview/ViewIllustPage.xaml b/Pixiview/Illust/ViewIllustPage.xaml similarity index 75% rename from Pixiview/ViewIllustPage.xaml rename to Pixiview/Illust/ViewIllustPage.xaml index fbdd4a5..fc48957 100644 --- a/Pixiview/ViewIllustPage.xaml +++ b/Pixiview/Illust/ViewIllustPage.xaml @@ -1,26 +1,29 @@  - + - + - + BackgroundColor="{DynamicResource MaskColor}"> + - diff --git a/Pixiview/ViewIllustPage.xaml.cs b/Pixiview/Illust/ViewIllustPage.xaml.cs similarity index 82% rename from Pixiview/ViewIllustPage.xaml.cs rename to Pixiview/Illust/ViewIllustPage.xaml.cs index 07c146b..45908a6 100644 --- a/Pixiview/ViewIllustPage.xaml.cs +++ b/Pixiview/Illust/ViewIllustPage.xaml.cs @@ -6,7 +6,7 @@ using Pixiview.Utils; using Xamarin.Essentials; using Xamarin.Forms; -namespace Pixiview +namespace Pixiview.Illust { public partial class ViewIllustPage : AdaptedPage { @@ -18,6 +18,8 @@ namespace Pixiview nameof(IsPageVisible), typeof(bool), typeof(ViewIllustPage)); public static readonly BindableProperty IllustItemProperty = BindableProperty.Create( nameof(IllustItem), typeof(IllustItem), typeof(ViewIllustPage)); + public static readonly BindableProperty PageTopMarginProperty = BindableProperty.Create( + nameof(PageTopMargin), typeof(Thickness), typeof(ViewIllustPage)); public IllustDetailItem[] Illusts { @@ -39,6 +41,11 @@ namespace Pixiview get => (IllustItem)GetValue(IllustItemProperty); private set => SetValue(IllustItemProperty, value); } + public Thickness PageTopMargin + { + get => (Thickness)GetValue(PageTopMarginProperty); + private set => SetValue(PageTopMarginProperty, value); + } public int CurrentPage { get; private set; } @@ -79,9 +86,48 @@ namespace Pixiview } Illusts = items; + OnOrientationChanged(CurrentOrientation); Task.Run(DoLoadImages); } + public override void OnOrientationChanged(Orientation orientation) + { + switch (orientation) + { + case Orientation.Portrait: + PageTopMargin = AppShell.TotalBarOffset; + break; + case Orientation.PortraitUpsideDown: + if (DeviceInfo.Idiom == DeviceIdiom.Phone) + { + PageTopMargin = AppShell.NavigationBarOffset; + } + else + { + PageTopMargin = AppShell.TotalBarOffset; + } + break; + case Orientation.Unknown: + case Orientation.LandscapeLeft: + case Orientation.LandscapeRight: + default: + PageTopMargin = AppShell.NavigationBarOffset; + break; + } + } + + protected override void OnAppearing() + { + base.OnAppearing(); + Screen.SetHomeIndicatorAutoHidden(Shell.Current, true); + } + + protected override void OnDisappearing() + { + base.OnDisappearing(); + Screen.SetHomeIndicatorAutoHidden(Shell.Current, false); + } + private void CarouselView_PositionChanged(object sender, PositionChangedEventArgs e) { var index = e.CurrentPosition; diff --git a/Pixiview/OptionPage.xaml b/Pixiview/OptionPage.xaml new file mode 100644 index 0000000..85a87e0 --- /dev/null +++ b/Pixiview/OptionPage.xaml @@ -0,0 +1,6 @@ + + + + + diff --git a/Pixiview/OptionPage.xaml.cs b/Pixiview/OptionPage.xaml.cs new file mode 100644 index 0000000..6a493b5 --- /dev/null +++ b/Pixiview/OptionPage.xaml.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +namespace Pixiview +{ + public partial class OptionPage : ContentPage + { + public OptionPage() + { + InitializeComponent(); + } + } +} diff --git a/Pixiview/Pixiview.csproj b/Pixiview/Pixiview.csproj index 87eb65b..bc395f3 100644 --- a/Pixiview/Pixiview.csproj +++ b/Pixiview/Pixiview.csproj @@ -21,6 +21,7 @@ + diff --git a/Pixiview/UI/AdaptedPage.cs b/Pixiview/UI/AdaptedPage.cs index 4638b06..b52bd34 100644 --- a/Pixiview/UI/AdaptedPage.cs +++ b/Pixiview/UI/AdaptedPage.cs @@ -5,18 +5,6 @@ namespace Pixiview.UI { public class AdaptedPage : ContentPage { - static readonly Thickness LandscapeLeftPadding = new Thickness(34, 0, 0, 0); - static readonly Thickness LandscapeRightPadding = new Thickness(0, 0, 34, 0); - - public static readonly BindableProperty StatusBarPaddingProperty = BindableProperty.Create( - nameof(StatusBarPadding), typeof(Thickness), typeof(AdaptedPage), default(Thickness)); - - public Thickness StatusBarPadding - { - get => (Thickness)GetValue(StatusBarPaddingProperty); - set => SetValue(StatusBarPaddingProperty, value); - } - public Orientation CurrentOrientation { get; private set; } public event EventHandler Load; @@ -35,19 +23,6 @@ namespace Pixiview.UI public virtual void OnOrientationChanged(Orientation orientation) { - if (orientation == Orientation.LandscapeLeft || orientation == Orientation.PortraitUpsideDown) - { - StatusBarPadding = StyleDefinition.IsFullscreenDevice ? LandscapeLeftPadding : default; - } - else if (orientation == Orientation.LandscapeRight) - { - StatusBarPadding = StyleDefinition.IsFullscreenDevice ? LandscapeRightPadding : default; - } - else - { - StatusBarPadding = default; - } - OrientationChanged?.Invoke(this, new OrientationEventArgs { CurrentOrientation = orientation }); } diff --git a/Pixiview/UI/CardView.cs b/Pixiview/UI/CardView.cs index ac3aaa8..224cfc5 100644 --- a/Pixiview/UI/CardView.cs +++ b/Pixiview/UI/CardView.cs @@ -1,4 +1,5 @@ -using Xamarin.Forms; +using Pixiview.Illust; +using Xamarin.Forms; namespace Pixiview.UI { diff --git a/Pixiview/UI/Theme/DarkTheme.cs b/Pixiview/UI/Theme/DarkTheme.cs index b35e791..d33aacb 100644 --- a/Pixiview/UI/Theme/DarkTheme.cs +++ b/Pixiview/UI/Theme/DarkTheme.cs @@ -35,6 +35,8 @@ namespace Pixiview.UI.Theme Add(MainTextColor, Color.White); Add(SubColor, Color.FromRgb(0x33, 0x33, 0x33)); Add(MaskColor, Color.FromRgba(0xff, 0xff, 0xff, 0x50)); + Add(NavColor, Color.Black); + Add(SubNavColor, Color.FromRgb(0x22, 0x22, 0x22)); } } } diff --git a/Pixiview/UI/Theme/LightTheme.cs b/Pixiview/UI/Theme/LightTheme.cs index 1595721..447e334 100644 --- a/Pixiview/UI/Theme/LightTheme.cs +++ b/Pixiview/UI/Theme/LightTheme.cs @@ -35,6 +35,8 @@ namespace Pixiview.UI.Theme Add(MainTextColor, Color.Black); Add(SubColor, Color.FromRgb(0xf0, 0xf0, 0xf0)); // Color.FromRgb(0xfa, 0xfa, 0xf0) Add(MaskColor, Color.FromRgba(0, 0, 0, 0x50)); + Add(NavColor, Color.FromRgb(0xee, 0xee, 0xee)); + Add(SubNavColor, Color.White); } } } diff --git a/Pixiview/UI/Theme/ThemeBase.cs b/Pixiview/UI/Theme/ThemeBase.cs index fe12633..df44823 100644 --- a/Pixiview/UI/Theme/ThemeBase.cs +++ b/Pixiview/UI/Theme/ThemeBase.cs @@ -21,6 +21,8 @@ namespace Pixiview.UI.Theme public const string MainTextColor = nameof(MainTextColor); public const string SubColor = nameof(SubColor); public const string MaskColor = nameof(MaskColor); + public const string NavColor = nameof(NavColor); + public const string SubNavColor = nameof(SubNavColor); public const string IconLightFontFamily = nameof(IconLightFontFamily); public const string IconRegularFontFamily = nameof(IconRegularFontFamily); diff --git a/Pixiview/Utils/Extensions.cs b/Pixiview/Utils/Extensions.cs index f97844a..d69a6f2 100644 --- a/Pixiview/Utils/Extensions.cs +++ b/Pixiview/Utils/Extensions.cs @@ -12,16 +12,14 @@ namespace Pixiview.Utils typeof(StatusBarStyles), typeof(Page), StatusBarStyles.WhiteText); + public static StatusBarStyles GetStatusBarStyle(VisualElement page) => (StatusBarStyles)page.GetValue(StatusBarStyleProperty); + public static void SetStatusBarStyle(VisualElement page, StatusBarStyles value) => page.SetValue(StatusBarStyleProperty, value); public static readonly BindableProperty HomeIndicatorAutoHiddenProperty = BindableProperty.CreateAttached( HomeIndicatorAutoHidden, typeof(bool), - typeof(Page), + typeof(Shell), false); - - public static StatusBarStyles GetStatusBarStyle(VisualElement page) => (StatusBarStyles)page.GetValue(StatusBarStyleProperty); - public static void SetStatusBarStyle(VisualElement page, StatusBarStyles value) => page.SetValue(StatusBarStyleProperty, value); - public static bool GetHomeIndicatorAutoHidden(VisualElement page) => (bool)page.GetValue(HomeIndicatorAutoHiddenProperty); public static void SetHomeIndicatorAutoHidden(VisualElement page, bool value) => page.SetValue(HomeIndicatorAutoHiddenProperty, value); }