features:

- launcher logo
 - tab bar tint color
 - favorites logic udpated
This commit is contained in:
Tsanie Lily 2020-05-08 17:02:54 +08:00
parent ca074e12b1
commit ca46fd35fe
20 changed files with 680 additions and 129 deletions

View File

@ -0,0 +1,530 @@
{
"images": [
{
"idiom": "universal"
},
{
"filename": "pixiv.png",
"scale": "1x",
"idiom": "universal"
},
{
"filename": "pixiv@2x.png",
"scale": "2x",
"idiom": "universal"
},
{
"filename": "pixiv@3x.png",
"scale": "3x",
"idiom": "universal"
},
{
"idiom": "iphone"
},
{
"scale": "1x",
"idiom": "iphone"
},
{
"scale": "2x",
"idiom": "iphone"
},
{
"subtype": "retina4",
"scale": "2x",
"idiom": "iphone"
},
{
"scale": "3x",
"idiom": "iphone"
},
{
"idiom": "ipad"
},
{
"scale": "1x",
"idiom": "ipad"
},
{
"scale": "2x",
"idiom": "ipad"
},
{
"idiom": "watch"
},
{
"scale": "2x",
"idiom": "watch"
},
{
"screenWidth": "{130,145}",
"scale": "2x",
"idiom": "watch"
},
{
"screenWidth": "{146,165}",
"scale": "2x",
"idiom": "watch"
},
{
"idiom": "mac"
},
{
"scale": "1x",
"idiom": "mac"
},
{
"scale": "2x",
"idiom": "mac"
},
{
"idiom": "car"
},
{
"scale": "2x",
"idiom": "car"
},
{
"scale": "3x",
"idiom": "car"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"idiom": "universal"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "1x",
"idiom": "universal"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "2x",
"idiom": "universal"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "3x",
"idiom": "universal"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"idiom": "iphone"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "1x",
"idiom": "iphone"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "2x",
"idiom": "iphone"
},
{
"subtype": "retina4",
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "2x",
"idiom": "iphone"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "3x",
"idiom": "iphone"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"idiom": "ipad"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "1x",
"idiom": "ipad"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "2x",
"idiom": "ipad"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"idiom": "watch"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "2x",
"idiom": "watch"
},
{
"screenWidth": "{130,145}",
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "2x",
"idiom": "watch"
},
{
"screenWidth": "{146,165}",
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "2x",
"idiom": "watch"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"idiom": "mac"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "1x",
"idiom": "mac"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "2x",
"idiom": "mac"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"idiom": "car"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "2x",
"idiom": "car"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
],
"scale": "3x",
"idiom": "car"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"idiom": "universal"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "1x",
"idiom": "universal"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "2x",
"idiom": "universal"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "3x",
"idiom": "universal"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"idiom": "iphone"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "1x",
"idiom": "iphone"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "2x",
"idiom": "iphone"
},
{
"subtype": "retina4",
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "2x",
"idiom": "iphone"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "3x",
"idiom": "iphone"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"idiom": "ipad"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "1x",
"idiom": "ipad"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "2x",
"idiom": "ipad"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"idiom": "watch"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "2x",
"idiom": "watch"
},
{
"screenWidth": "{130,145}",
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "2x",
"idiom": "watch"
},
{
"screenWidth": "{146,165}",
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "2x",
"idiom": "watch"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"idiom": "mac"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "1x",
"idiom": "mac"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "2x",
"idiom": "mac"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"idiom": "car"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "2x",
"idiom": "car"
},
{
"appearances": [
{
"appearance": "luminosity",
"value": "light"
}
],
"scale": "3x",
"idiom": "car"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -125,6 +125,10 @@
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon20.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\LauncherLogo.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\LauncherLogo.imageset\pixiv.png" />
<ImageAsset Include="Assets.xcassets\LauncherLogo.imageset\pixiv%402x.png" />
<ImageAsset Include="Assets.xcassets\LauncherLogo.imageset\pixiv%403x.png" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
@ -150,6 +154,7 @@
<Folder Include="Services\" />
<Folder Include="Renderers\AppShellSection\" />
<Folder Include="Effects\" />
<Folder Include="Assets.xcassets\LauncherLogo.imageset\" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\fa-light-300.ttf" />

View File

@ -92,12 +92,13 @@ namespace Pixiview.iOS.Renderers
tabBar.UnselectedItemTintColor = _defaultUnselectedTint;
}
[SuppressMessage("Code Notifications", "XI0002:Notifies you from using newer Apple APIs when targeting an older OS version", Justification = "<Pending>")]
public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
{
IShellAppearanceElement appearanceElement = appearance;
//var backgroundColor = appearanceElement.EffectiveTabBarBackgroundColor;
var unselectedColor = appearanceElement.EffectiveTabBarUnselectedColor;
var titleColor = appearanceElement.EffectiveTabBarTitleColor;
var tintColor = appearanceElement.EffectiveTabBarForegroundColor; // appearanceElement.EffectiveTabBarTitleColor;
var tabBar = controller.TabBar;
//bool operatingSystemSupportsUnselectedTint = Forms.IsiOS10OrNewer;
@ -115,12 +116,16 @@ namespace Pixiview.iOS.Renderers
//if (!backgroundColor.IsDefault)
// tabBar.BarTintColor = backgroundColor.ToUIColor();
if (!UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
if (!titleColor.IsDefault)
tabBar.TintColor = titleColor.ToUIColor();
//if (operatingSystemSupportsUnselectedTint)
if (!tintColor.IsDefault)
tabBar.TintColor = tintColor.ToUIColor();
//if (operatingSystemSupportsUnselectedTint)
{
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
//tabBar.UnselectedItemTintColor = UIColor.TertiaryLabelColor;
}
else
{
if (!unselectedColor.IsDefault)
tabBar.UnselectedItemTintColor = unselectedColor.ToUIColor();

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using CoreGraphics;
using Foundation;
using UIKit;

View File

@ -16,6 +16,22 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="197" image="LauncherLogo" translatesAutoresizingMaskIntoConstraints="NO">
<rect key="frame" x="59" y="356" width="256" height="100"/>
<accessibility key="accessibilityConfiguration">
<accessibilityTraits key="traits" image="YES" notEnabled="YES"/>
</accessibility>
<constraints>
<constraint id="399" firstAttribute="height" constant="100"/>
<constraint id="400" firstAttribute="width" constant="256"/>
</constraints>
</imageView>
</subviews>
<constraints>
<constraint id="397" firstItem="197" firstAttribute="centerY" secondItem="yd7-JS-zBw" secondAttribute="centerY"/>
<constraint id="398" firstItem="197" firstAttribute="centerX" secondItem="yd7-JS-zBw" secondAttribute="centerX"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="XAI-xm-WK6" userLabel="First Responder" sceneMemberID="firstResponder"/>
@ -23,4 +39,7 @@
<point key="canvasLocation" x="349" y="339"/>
</scene>
</scenes>
<resources>
<image name="LauncherLogo" width="256" height="100"/>
</resources>
</document>

View File

@ -8,8 +8,8 @@
xmlns:util="clr-namespace:Pixiview.Utils"
x:Class="Pixiview.AppShell"
BackgroundColor="{DynamicResource NavColor}"
ForegroundColor="{DynamicResource MainTextColor}"
TitleColor="{DynamicResource MainTextColor}"
ForegroundColor="{DynamicResource TintColor}"
TitleColor="{DynamicResource TextColor}"
UnselectedColor="{DynamicResource SubTextColor}">
<Shell.FlyoutHeaderTemplate>
<DataTemplate>

View File

@ -17,9 +17,9 @@ namespace Pixiview.Illust
protected override void OnAppearing()
{
base.OnAppearing();
StartLoad(true);
//base.OnAppearing();
loaded = false;
StartLoad();
}
protected override IEnumerable<IllustItem> DoGetIllustList(IllustItem[] data, ICommand command)
@ -33,12 +33,12 @@ namespace Pixiview.Illust
protected override IllustItem[] DoLoadIllustData(bool force)
{
var favorites = Stores.LoadFavoritesIllusts();
var favorites = Stores.FavoriteObject;
if (favorites == null)
{
return null;
}
return favorites.Illusts;
return favorites.Illusts.ToArray();
}
}
}

View File

@ -15,7 +15,6 @@ namespace Pixiview.Illust
{
public interface IIllustCollectionPage
{
List<IllustItem> Favorites { get; }
IllustCollection IllustCollection { get; set; }
}
@ -60,13 +59,13 @@ namespace Pixiview.Illust
set => SetValue(LoadingProperty, value);
}
public List<IllustItem> Favorites { get; } = new List<IllustItem>();
#endregion
protected static bool IsUpdated { get; private set; } = true;
public IllustCollection IllustCollection { get; set; }
protected virtual bool IsFavoriteVisible => true;
#endregion
protected Thickness totalBarOffset;
protected Thickness navigationBarOffset;
protected bool loaded;
@ -79,12 +78,6 @@ namespace Pixiview.Illust
{
BindingContext = this;
commandIllustImageTapped = new Command<IllustItem>(IllustImageTapped);
var favorites = Stores.LoadFavoritesIllusts();
if (favorites != null)
{
Favorites.AddRange(favorites.Illusts);
}
}
private void IllustImageTapped(IllustItem illust)
@ -97,22 +90,38 @@ namespace Pixiview.Illust
protected override void OnAppearing()
{
base.OnAppearing();
Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;
if (IsUpdated || !loaded)
{
IsUpdated = false;
loaded = false;
StartLoad();
}
else if (IsFavoriteVisible)
{
var favorites = Stores.Favorites;
foreach (var item in IllustCollection)
{
item.IsFavorite = favorites.Any(i => i.Id == item.Id);
}
}
}
protected override void OnDisappearing()
{
base.OnDisappearing();
Connectivity.ConnectivityChanged -= Connectivity_ConnectivityChanged;
base.OnDisappearing();
}
private void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
{
if (e.NetworkAccess == NetworkAccess.Internet || e.NetworkAccess == NetworkAccess.ConstrainedInternet)
{
StartLoad();
if (!loaded)
{
StartLoad(true);
}
}
}
@ -293,7 +302,7 @@ namespace Pixiview.Illust
}
}
}
.DynamicResource(BackgroundColorProperty, ThemeBase.SubColor);
.DynamicResource(BackgroundColorProperty, ThemeBase.CardBackgroundColor);
});
}
@ -308,15 +317,20 @@ namespace Pixiview.Illust
Loading = false;
return;
}
if (force)
{
IsUpdated = true;
}
var data = DoGetIllustList(illustData, commandIllustImageTapped).Where(i => i != null);
var collection = new IllustCollection(data);
if (IsFavoriteVisible)
{
var favorites = Stores.Favorites;
foreach (var item in collection)
{
item.IsFavorite = Favorites.Any(i => i.Id == item.Id);
item.IsFavorite = favorites.Any(i => i.Id == item.Id);
}
}
IllustCollection = collection;
@ -404,7 +418,7 @@ namespace Pixiview.Illust
public class IllustFavorite
{
public DateTime LastFavoriteUtc { get; set; }
public IllustItem[] Illusts { get; set; }
public List<IllustItem> Illusts { get; set; }
}
[JsonObject(MemberSerialization.OptIn)]

View File

@ -14,11 +14,6 @@ namespace Pixiview.Illust
InitializeComponent();
}
public override void OnLoad()
{
StartLoad();
}
public override void OnUnload()
{
Illusts = IllustCollection.Empty;

View File

@ -20,7 +20,7 @@
<SearchBar Placeholder="{r:Text Search}" VerticalOptions="Start"
Margin="0, -46, 0, 0" HeightRequest="50"
BackgroundColor="{DynamicResource WindowColor}"
CancelButtonColor="{DynamicResource SubTextColor}"
CancelButtonColor="{DynamicResource TintColor}"
Text="{Binding Keywords, Mode=TwoWay}"
SearchButtonPressed="SearchBar_SearchButtonPressed"
Unfocused="SearchBar_Unfocused"/>

View File

@ -28,11 +28,6 @@ namespace Pixiview.Illust
InitializeComponent();
}
public override void OnLoad()
{
StartLoad();
}
public override void OnUnload()
{
Illusts = IllustCollection.Empty;

View File

@ -36,11 +36,6 @@ namespace Pixiview.Illust
InitializeComponent();
}
public override void OnLoad()
{
StartLoad();
}
public override void OnUnload()
{
Illusts = IllustCollection.Empty;

View File

@ -68,9 +68,10 @@ namespace Pixiview.Illust
fontIconLove = (ImageSource)Application.Current.Resources[ThemeBase.FontIconLove];
fontIconNotLove = (ImageSource)Application.Current.Resources[ThemeBase.FontIconNotLove];
if (page.Favorites != null)
var favorites = Stores.Favorites;
if (favorites != null)
{
FavoriteIcon = page.Favorites.Any(i => i.Id == illust.Id)
FavoriteIcon = favorites.Any(i => i.Id == illust.Id)
? fontIconLove
: fontIconNotLove;
}
@ -100,12 +101,7 @@ namespace Pixiview.Illust
if (collectionPage is IllustDataCollectionPage)
{
var favorite = new IllustFavorite
{
LastFavoriteUtc = DateTime.UtcNow,
Illusts = collectionPage.Favorites.ToArray()
};
Stores.SaveFavoritesIllusts(favorite);
Stores.SaveFavoritesIllusts();
}
Screen.SetHomeIndicatorAutoHidden(Shell.Current, false);
}
@ -236,21 +232,23 @@ namespace Pixiview.Illust
private void Favorite_Clicked(object sender, EventArgs e)
{
if (collectionPage.Favorites == null)
var favorites = Stores.Favorites;
if (favorites == null)
{
return;
}
var index = collectionPage.Favorites.FindIndex(i => i.Id == IllustItem.Id);
var illust = IllustItem;
var index = favorites.FindIndex(i => i.Id == illust.Id);
if (index < 0)
{
collectionPage.Favorites.Insert(0, IllustItem);
IllustItem.IsFavorite = true;
illust.IsFavorite = true;
favorites.Insert(0, illust);
FavoriteIcon = fontIconLove;
}
else
{
collectionPage.Favorites.RemoveAt(index);
IllustItem.IsFavorite = false;
illust.IsFavorite = false;
favorites.RemoveAt(index);
FavoriteIcon = fontIconNotLove;
}
}

View File

@ -3,7 +3,7 @@ using Xamarin.Forms;
namespace Pixiview.UI.Theme
{
public partial class DarkTheme : ThemeBase
public class DarkTheme : ThemeBase
{
private static DarkTheme _instance;
@ -29,11 +29,10 @@ namespace Pixiview.UI.Theme
{
Add(StatusBarStyle, StatusBarStyles.WhiteText);
Add(WindowColor, Color.Black);
Add(TintColor, Color.FromRgb(0x00, 0x96, 0xfa));
Add(TextColor, Color.White);
Add(SubTextColor, Color.LightGray);
Add(MainColor, Color.FromRgb(0x11, 0x11, 0x11));
Add(MainTextColor, Color.White);
Add(SubColor, Color.FromRgb(0x33, 0x33, 0x33));
Add(CardBackgroundColor, Color.FromRgb(0x33, 0x33, 0x33));
Add(MaskColor, Color.FromRgba(0xff, 0xff, 0xff, 0x50));
Add(NavColor, Color.Black);
Add(NavSelectedColor, Color.FromRgb(0x22, 0x22, 0x22));

View File

@ -3,7 +3,7 @@ using Xamarin.Forms;
namespace Pixiview.UI.Theme
{
public partial class LightTheme : ThemeBase
public class LightTheme : ThemeBase
{
private static LightTheme _instance;
@ -29,13 +29,12 @@ namespace Pixiview.UI.Theme
{
Add(StatusBarStyle, StatusBarStyles.DarkText);
Add(WindowColor, Color.White);
Add(TintColor, Color.FromRgb(0x00, 0x96, 0xfa)); // 0x7f, 0x99, 0xc6
Add(TextColor, Color.Black);
Add(SubTextColor, Color.DimGray);
Add(MainColor, Color.FromRgb(0xf0, 0xf0, 0xf0)); // Color.FromRgb(0x7f, 0x99, 0xc6)
Add(MainTextColor, Color.Black);
Add(SubColor, Color.FromRgb(0xf0, 0xf0, 0xf0)); // Color.FromRgb(0xfa, 0xfa, 0xf0)
Add(CardBackgroundColor, Color.FromRgb(0xfa, 0xfa, 0xf0));
Add(MaskColor, Color.FromRgba(0, 0, 0, 0x50));
Add(NavColor, Color.FromRgb(0xee, 0xee, 0xee));
Add(NavColor, Color.FromRgb(0xf0, 0xf0, 0xf0));
Add(NavSelectedColor, Color.LightGray);
}
}

View File

@ -4,8 +4,6 @@ namespace Pixiview.UI.Theme
{
public class ThemeBase : ResourceDictionary
{
public const string TitleButton = nameof(TitleButton);
public const string TitleLabel = nameof(TitleLabel);
public const string FontIconUser = nameof(FontIconUser);
public const string FontIconSparkles = nameof(FontIconSparkles);
public const string FontIconOrder = nameof(FontIconOrder);
@ -18,11 +16,10 @@ namespace Pixiview.UI.Theme
public const string StatusBarStyle = nameof(StatusBarStyle);
public const string WindowColor = nameof(WindowColor);
public const string TintColor = nameof(TintColor);
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 CardBackgroundColor = nameof(CardBackgroundColor);
public const string MaskColor = nameof(MaskColor);
public const string NavColor = nameof(NavColor);
public const string NavSelectedColor = nameof(NavSelectedColor);
@ -58,43 +55,19 @@ namespace Pixiview.UI.Theme
}
}
var mainColor = (Color)this[MainTextColor];
var tintColor = (Color)this[TextColor];
var regularFontFamily = (string)this[IconRegularFontFamily];
var solidFontFamily = (string)this[IconSolidFontFamily];
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 = mainColor }
}
});
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 = solidFontFamily },
new Setter { Property = Button.FontSizeProperty, Value = StyleDefinition.FontSizeTitleIcon },
new Setter { Property = Button.TextColorProperty, Value = mainColor }
}
});
Add(FontIconUser, GetSolidIcon(StyleDefinition.IconUser, solidFontFamily, mainColor));
Add(FontIconSparkles, GetSolidIcon(StyleDefinition.IconSparkles, solidFontFamily, mainColor));
Add(FontIconOrder, GetSolidIcon(StyleDefinition.IconOrder, solidFontFamily, mainColor));
Add(FontIconRefresh, GetSolidIcon(StyleDefinition.IconRefresh, solidFontFamily, mainColor));
Add(FontIconUser, GetSolidIcon(StyleDefinition.IconUser, solidFontFamily, tintColor));
Add(FontIconSparkles, GetSolidIcon(StyleDefinition.IconSparkles, solidFontFamily, tintColor));
Add(FontIconOrder, GetSolidIcon(StyleDefinition.IconOrder, solidFontFamily, tintColor));
Add(FontIconRefresh, GetSolidIcon(StyleDefinition.IconRefresh, solidFontFamily, tintColor));
Add(FontIconLove, GetSolidIcon(StyleDefinition.IconLove, solidFontFamily, StyleDefinition.ColorRedBackground));
Add(FontIconNotLove, GetSolidIcon(StyleDefinition.IconLove, (string)this[IconRegularFontFamily], mainColor));
Add(FontIconOption, GetSolidIcon(StyleDefinition.IconOption, solidFontFamily, mainColor));
Add(FontIconDownload, GetSolidIcon(StyleDefinition.IconDownload, solidFontFamily, mainColor));
Add(FontIconFavorite, GetSolidIcon(StyleDefinition.IconFavorite, solidFontFamily, mainColor));
Add(FontIconNotLove, GetSolidIcon(StyleDefinition.IconLove, regularFontFamily, tintColor));
Add(FontIconOption, GetSolidIcon(StyleDefinition.IconOption, solidFontFamily, tintColor));
Add(FontIconDownload, GetSolidIcon(StyleDefinition.IconDownload, solidFontFamily, tintColor));
Add(FontIconFavorite, GetSolidIcon(StyleDefinition.IconFavorite, solidFontFamily, tintColor));
}
private FontImageSource GetSolidIcon(string icon, string family, Color color)

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
@ -11,7 +12,7 @@ using Xamarin.Forms;
namespace Pixiview.Utils
{
public class Stores
public static class Stores
{
public static readonly string PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
public static readonly string CacheFolder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
@ -43,6 +44,48 @@ namespace Pixiview.Utils
}
}
private static IllustFavorite favoriteObject;
public static IllustFavorite FavoriteObject
{
get
{
lock (sync)
{
if (favoriteObject == null)
{
var favorites = LoadFavoritesIllusts();
if (favorites != null)
{
favoriteObject = favorites;
}
}
return favoriteObject;
}
}
}
public static List<IllustItem> Favorites => FavoriteObject.Illusts;
private static IllustFavorite LoadFavoritesIllusts()
{
var file = Path.Combine(PersonalFolder, favoriteFile);
lock (sync)
{
return ReadObject<IllustFavorite>(file);
}
}
public static void SaveFavoritesIllusts()
{
var file = Path.Combine(PersonalFolder, favoriteFile);
lock (sync)
{
var data = FavoriteObject;
data.LastFavoriteUtc = DateTime.UtcNow;
WriteObject(file, data);
}
}
private static T LoadObject<T>(string file, string url, string referer = null, bool force = false)
{
string content = null;
@ -179,24 +222,6 @@ namespace Pixiview.Utils
return result;
}
public static IllustFavorite LoadFavoritesIllusts()
{
var file = Path.Combine(PersonalFolder, favoriteFile);
lock (sync)
{
return ReadObject<IllustFavorite>(file);
}
}
public static void SaveFavoritesIllusts(IllustFavorite data)
{
var file = Path.Combine(PersonalFolder, favoriteFile);
lock (sync)
{
WriteObject(file, data);
}
}
public static ImageSource LoadIllustImage(string url)
{
return LoadImage(url, PersonalFolder, imageFolder);