Pixiview/Pixiview/Illust/MainPage.xaml.cs
Tsanie Lily d32c5eb69a * Pixiview/UI/OptionCell.cs:
* Pixiview/UI/AdaptedPage.cs:
* Pixiview/Utils/FileStore.cs:
* Pixiview/Utils/IllustData.cs:
* Pixiview/Illust/MainPage.xaml:
* Pixiview/UI/Theme/LightTheme.cs:
* Pixiview/Illust/MainPage.xaml.cs:
* Pixiview.iOS/GlobalSuppressions.cs:
* Pixiview/Illust/ViewIllustPage.xaml:
* Pixiview.Android/GlobalSuppressions.cs:
* Pixiview/Illust/ViewIllustPage.xaml.cs:
* Pixiview/Illust/IllustCollectionPage.cs:
* Pixiview.iOS/Renderers/SegmentedControlRenderer.cs:

* Pixiview/Illust/RankingPage.xaml:
* Pixiview/Illust/RankingPage.xaml.cs:
* Pixiview.Android/Pixiview.Android.csproj:
* Pixiview.Android/Resources/values/colors.xml:
* Pixiview.Android/Resources/Resource.designer.cs:
* Pixiview.Android/Resources/layout/RadioGroup.xml:
* Pixiview.Android/Renderers/BlurryPanelRenderer.cs:
* Pixiview.Android/Resources/layout/RadioButton.xml:
* Pixiview.Android/Renderers/SegmentedControlRenderer.cs:
* Pixiview.Android/Resources/color/segmented_control_text.xml:
* Pixiview.Android/Resources/drawable/segmented_control_background.xml:
* Pixiview.Android/Resources/drawable/segmented_control_last_background.xml:
* Pixiview.Android/Resources/drawable/segmented_control_first_background.xml:
  segmented control for Android
2020-05-13 18:09:16 +08:00

78 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Pixiview.Utils;
using Xamarin.Forms;
namespace Pixiview.Illust
{
public partial class MainPage : IllustDataCollectionPage
{
public static readonly BindableProperty KeywordsProperty = BindableProperty.Create(
nameof(Keywords), typeof(string), typeof(MainPage));
public string Keywords
{
get => (string)GetValue(KeywordsProperty);
set => SetValue(KeywordsProperty, value);
}
public MainPage()
{
Resources.Add("cardView", GetCardViewTemplate());
InitializeComponent();
#if __IOS__
searchBar.BackgroundColor = Color.Transparent;
#elif __ANDROID__
searchBar.SetDynamicResource(SearchBar.TextColorProperty, UI.Theme.ThemeBase.TextColor);
searchBar.SetDynamicResource(SearchBar.PlaceholderColorProperty, UI.Theme.ThemeBase.SubTextColor);
searchBar.SetDynamicResource(BackgroundColorProperty, UI.Theme.ThemeBase.WindowColor);
#endif
}
protected override IEnumerable<IllustItem> DoGetIllustList(IllustData data, ICommand command)
{
return data.body.page.follow.Select(i =>
{
var item = data.body.thumbnails.illust.FirstOrDefault(l => l.illustId == i.ToString())?.ConvertToItem();
if (item != null)
{
item.IllustTapped = command;
}
return item;
});
}
protected override IllustData DoLoadIllustData(bool force)
{
return Stores.LoadIllustData(force);
}
private void Refresh_Clicked(object sender, EventArgs e)
{
if (IsLoading)
{
return;
}
StartLoad(true);
}
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
{
var key = Keywords;
if (key != null)
{
key = key.Trim().ToLower();
}
if (!string.IsNullOrEmpty(key))
{
Task.Run(() => App.OpenUrl(new Uri("pixiview://example.com/artworks/" + key)));
}
}
}
}