* 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
This commit is contained in:
@@ -143,9 +143,13 @@ namespace Pixiview.Illust
|
||||
}
|
||||
else if (isPhone)
|
||||
{
|
||||
#if __IOS__
|
||||
newMargin = width > height ?
|
||||
StyleDefinition.TopOffset16 :
|
||||
StyleDefinition.TopOffset32;
|
||||
#elif __ANDROID__
|
||||
newMargin = default;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -545,10 +549,10 @@ namespace Pixiview.Illust
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class IllustItem : BindableObject
|
||||
{
|
||||
public static readonly BindableProperty TitleProperty = BindableProperty.Create(
|
||||
nameof(Title), typeof(string), typeof(IllustItem));
|
||||
public static readonly BindableProperty RankTitleProperty = BindableProperty.Create(
|
||||
nameof(RankTitle), typeof(string), typeof(IllustItem));
|
||||
//public static readonly BindableProperty TitleProperty = BindableProperty.Create(
|
||||
// nameof(Title), typeof(string), typeof(IllustItem));
|
||||
//public static readonly BindableProperty RankTitleProperty = BindableProperty.Create(
|
||||
// nameof(RankTitle), typeof(string), typeof(IllustItem));
|
||||
public static readonly BindableProperty ImageProperty = BindableProperty.Create(
|
||||
nameof(Image), typeof(ImageSource), typeof(IllustItem));
|
||||
public static readonly BindableProperty ProfileImageProperty = BindableProperty.Create(
|
||||
@@ -557,20 +561,20 @@ namespace Pixiview.Illust
|
||||
nameof(ImageHeight), typeof(GridLength), typeof(IllustItem), GridLength.Auto);
|
||||
public static readonly BindableProperty IsFavoriteProperty = BindableProperty.Create(
|
||||
nameof(IsFavorite), typeof(bool), typeof(IllustItem));
|
||||
public static readonly BindableProperty IsPlayingProperty = BindableProperty.Create(
|
||||
nameof(IsPlaying), typeof(bool), typeof(IllustItem));
|
||||
//public static readonly BindableProperty IsPlayingProperty = BindableProperty.Create(
|
||||
// nameof(IsPlaying), typeof(bool), typeof(IllustItem));
|
||||
|
||||
[JsonProperty]
|
||||
public string Title
|
||||
{
|
||||
get => (string)GetValue(TitleProperty);
|
||||
set => SetValue(TitleProperty, value);
|
||||
}
|
||||
public string RankTitle
|
||||
{
|
||||
get => (string)GetValue(RankTitleProperty);
|
||||
set => SetValue(RankTitleProperty, value);
|
||||
}
|
||||
public string Title { get; set; }
|
||||
//{
|
||||
// get => (string)GetValue(TitleProperty);
|
||||
// set => SetValue(TitleProperty, value);
|
||||
//}
|
||||
public string RankTitle { get; set; }
|
||||
//{
|
||||
// get => (string)GetValue(RankTitleProperty);
|
||||
// set => SetValue(RankTitleProperty, value);
|
||||
//}
|
||||
public ImageSource Image
|
||||
{
|
||||
get => (ImageSource)GetValue(ImageProperty);
|
||||
@@ -591,11 +595,11 @@ namespace Pixiview.Illust
|
||||
get => (bool)GetValue(IsFavoriteProperty);
|
||||
set => SetValue(IsFavoriteProperty, value);
|
||||
}
|
||||
public bool IsPlaying
|
||||
{
|
||||
get => (bool)GetValue(IsPlayingProperty);
|
||||
set => SetValue(IsPlayingProperty, value);
|
||||
}
|
||||
public bool IsPlaying { get; set; }
|
||||
//{
|
||||
// get => (bool)GetValue(IsPlayingProperty);
|
||||
// set => SetValue(IsPlayingProperty, value);
|
||||
//}
|
||||
public ICommand IllustTapped { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
|
@@ -15,9 +15,24 @@
|
||||
<ScrollView HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never">
|
||||
<u:FlowLayout ItemsSource="{Binding Illusts}"
|
||||
HorizontalOptions="Fill" Column="{Binding Columns}"
|
||||
Margin="16" RowSpacing="16" ColumnSpacing="16"
|
||||
ItemTemplate="{StaticResource cardView}"/>
|
||||
RowSpacing="16" ColumnSpacing="16"
|
||||
ItemTemplate="{StaticResource cardView}">
|
||||
<u:FlowLayout.Margin>
|
||||
<OnPlatform x:TypeArguments="Thickness"
|
||||
iOS="16, 66, 16, 16"
|
||||
Android="16, 56, 16, 16"/>
|
||||
</u:FlowLayout.Margin>
|
||||
</u:FlowLayout>
|
||||
</ScrollView>
|
||||
<u:BlurryPanel VerticalOptions="Start" HeightRequest="{OnPlatform Android=40, iOS=50}"
|
||||
Margin="{Binding PanelTopMargin}"/>
|
||||
<SearchBar x:Name="searchBar" Placeholder="{r:Text Search}"
|
||||
HeightRequest="{OnPlatform Android=40, iOS=50}"
|
||||
VerticalOptions="Start"
|
||||
Margin="{Binding PageTopMargin}"
|
||||
CancelButtonColor="{DynamicResource TintColor}"
|
||||
Text="{Binding Keywords, Mode=TwoWay}"
|
||||
SearchButtonPressed="SearchBar_SearchButtonPressed"/>
|
||||
<Frame HasShadow="False" Margin="0" Padding="20" CornerRadius="8"
|
||||
IsVisible="{Binding IsLoading}"
|
||||
HorizontalOptions="Center" VerticalOptions="Center"
|
||||
|
@@ -1,17 +1,36 @@
|
||||
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)
|
||||
@@ -40,5 +59,19 @@ namespace Pixiview.Illust
|
||||
}
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,20 +7,24 @@
|
||||
x:Class="Pixiview.Illust.RankingPage"
|
||||
BackgroundColor="{DynamicResource WindowColor}">
|
||||
<Shell.TitleView>
|
||||
<Grid VerticalOptions="Fill" HorizontalOptions="Fill" ColumnSpacing="6">
|
||||
<Grid VerticalOptions="Fill" ColumnSpacing="6"
|
||||
HorizontalOptions="{x:OnPlatform Android=Start, iOS=Fill}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="{OnPlatform Android=Auto}"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="1" Text="{Binding Title}"
|
||||
TextColor="{DynamicResource TextColor}"
|
||||
FontSize="{OnPlatform Android=18}"
|
||||
VerticalTextAlignment="Center" FontAttributes="Bold">
|
||||
<Label.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
|
||||
</Label.GestureRecognizers>
|
||||
</Label>
|
||||
<Label Grid.Column="2" Text="{Binding PanelState}"
|
||||
TextColor="{DynamicResource TextColor}"
|
||||
FontFamily="{DynamicResource IconSolidFontFamily}"
|
||||
FontSize="Small"
|
||||
VerticalTextAlignment="Center"/>
|
||||
@@ -38,14 +42,6 @@
|
||||
Margin="16, 16, 16, 16" RowSpacing="16" ColumnSpacing="16"
|
||||
ItemTemplate="{StaticResource cardView}"/>
|
||||
</ScrollView>
|
||||
<!--<u:BlurryPanel VerticalOptions="Start" HeightRequest="50" Margin="{Binding PanelTopMargin}"/>
|
||||
<SearchBar x:Name="searchBar" Placeholder="{r:Text Search}" HeightRequest="50"
|
||||
VerticalOptions="Start"
|
||||
Margin="{Binding PageTopMargin}"
|
||||
CancelButtonColor="{DynamicResource TintColor}"
|
||||
Text="{Binding Keywords, Mode=TwoWay}"
|
||||
SearchButtonPressed="SearchBar_SearchButtonPressed"
|
||||
Unfocused="SearchBar_Unfocused"/>-->
|
||||
<u:BlurryPanel x:Name="panelFilter" VerticalOptions="Start" Opacity="0"
|
||||
Margin="{Binding PanelTopMargin}"
|
||||
HeightRequest="{Binding Height, Source={x:Reference gridFilter}}"/>
|
||||
@@ -57,7 +53,9 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<u:SegmentedControl Margin="6, 6, 6, 3" VerticalOptions="Center"
|
||||
SelectedSegmentIndex="{Binding SegmentDate, Mode=TwoWay}">
|
||||
SelectedSegmentIndex="{Binding SegmentDate, Mode=TwoWay}"
|
||||
SelectedTextColor="{DynamicResource TextColor}"
|
||||
TintColor="{DynamicResource CardBackgroundColor}">
|
||||
<u:SegmentedControl.Children>
|
||||
<u:SegmentedControlOption Text="{r:Text Daily}"/>
|
||||
<u:SegmentedControlOption Text="{r:Text Weekly}"/>
|
||||
@@ -67,7 +65,9 @@
|
||||
</u:SegmentedControl>
|
||||
<u:SegmentedControl Grid.Row="1" HorizontalOptions="Start"
|
||||
Margin="6, 3, 6, 6" VerticalOptions="Center"
|
||||
SelectedSegmentIndex="{Binding SegmentType, Mode=TwoWay}">
|
||||
SelectedSegmentIndex="{Binding SegmentType, Mode=TwoWay}"
|
||||
SelectedTextColor="{DynamicResource TextColor}"
|
||||
TintColor="{DynamicResource CardBackgroundColor}">
|
||||
<u:SegmentedControl.Children>
|
||||
<u:SegmentedControlOption Text="{r:Text General}"/>
|
||||
<u:SegmentedControlOption Text="{r:Text R18}"/>
|
||||
@@ -76,6 +76,7 @@
|
||||
<Button Grid.Row="1" HorizontalOptions="End" VerticalOptions="Center"
|
||||
Text="{DynamicResource IconCircleCheck}"
|
||||
FontFamily="{DynamicResource IconSolidFontFamily}"
|
||||
BackgroundColor="Transparent"
|
||||
TextColor="{DynamicResource TintColor}"
|
||||
FontSize="20" Margin="0, 0, 6, 0"
|
||||
Clicked="Filter_Clicked"/>
|
||||
|
@@ -16,8 +16,6 @@ namespace Pixiview.Illust
|
||||
private static readonly string[] segmentDates = { "daily", "weekly", "monthly", "male" };
|
||||
private static readonly object sync = new object();
|
||||
|
||||
public static readonly BindableProperty KeywordsProperty = BindableProperty.Create(
|
||||
nameof(Keywords), typeof(string), typeof(RankingPage));
|
||||
public static readonly BindableProperty PanelStateProperty = BindableProperty.Create(
|
||||
nameof(PanelState), typeof(string), typeof(RankingPage), StyleDefinition.IconCaretDown);
|
||||
public static readonly BindableProperty SegmentDateProperty = BindableProperty.Create(
|
||||
@@ -56,11 +54,6 @@ namespace Pixiview.Illust
|
||||
}
|
||||
}
|
||||
|
||||
public string Keywords
|
||||
{
|
||||
get => (string)GetValue(KeywordsProperty);
|
||||
set => SetValue(KeywordsProperty, value);
|
||||
}
|
||||
public string PanelState
|
||||
{
|
||||
get => (string)GetValue(PanelStateProperty);
|
||||
@@ -93,14 +86,6 @@ namespace Pixiview.Illust
|
||||
gridFilter.TranslationY = -100;
|
||||
panelFilter.TranslationY = -100;
|
||||
|
||||
//#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
|
||||
|
||||
lastQueryKey = QueryKey;
|
||||
queryDate = null; // $"{now.Year}{now.Month:00}{now.Day:00}";
|
||||
currentPage = 1;
|
||||
@@ -223,35 +208,6 @@ namespace Pixiview.Illust
|
||||
StartLoad(true);
|
||||
}
|
||||
|
||||
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
|
||||
{
|
||||
var key = Keywords;
|
||||
if (key != null)
|
||||
{
|
||||
key = key.Trim().ToLower();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
Illusts = IllustCollection;
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = IllustCollection.Where(i =>
|
||||
(i.UserName != null && i.UserName.ToLower().Contains(key)) ||
|
||||
(i.Title != null && i.Title.ToLower().Contains(key)));
|
||||
Illusts = new IllustCollection(list);
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchBar_Unfocused(object sender, FocusEventArgs e)
|
||||
{
|
||||
if (!e.IsFocused)
|
||||
{
|
||||
SearchBar_SearchButtonPressed(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
ToggleFilterPanel(!isFilterVisible);
|
||||
|
@@ -16,11 +16,12 @@
|
||||
</ContentPage.ToolbarItems>
|
||||
<Grid Padding="{Binding PageTopMargin}">
|
||||
<CarouselView ItemsSource="{Binding Illusts}" HorizontalScrollBarVisibility="Never"
|
||||
ItemTemplate="{StaticResource carouselView}"
|
||||
PositionChanged="CarouselView_PositionChanged">
|
||||
<CarouselView.ItemsLayout>
|
||||
<LinearItemsLayout Orientation="Vertical" ItemSpacing="20"/>
|
||||
</CarouselView.ItemsLayout>
|
||||
<CarouselView.ItemTemplate>
|
||||
<!--<CarouselView.ItemTemplate>
|
||||
<DataTemplate x:DataType="mdl:IllustDetailItem">
|
||||
<Grid>
|
||||
<Image Source="{Binding Image}"
|
||||
@@ -48,7 +49,7 @@
|
||||
Color="{DynamicResource TextColor}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</CarouselView.ItemTemplate>
|
||||
</CarouselView.ItemTemplate>-->
|
||||
</CarouselView>
|
||||
|
||||
<u:RoundLabel Text="{Binding PagePositionText}"
|
||||
|
@@ -77,6 +77,8 @@ namespace Pixiview.Illust
|
||||
? fontIconLove
|
||||
: fontIconNotLove;
|
||||
|
||||
Resources.Add("carouselView", GetCarouseTemplate());
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
if (illust != null)
|
||||
@@ -113,6 +115,70 @@ namespace Pixiview.Illust
|
||||
Screen.SetHomeIndicatorAutoHidden(Shell.Current, false);
|
||||
}
|
||||
|
||||
private DataTemplate GetCarouseTemplate()
|
||||
{
|
||||
var isAnime = IllustItem.IllustType == IllustType.Anime;
|
||||
var tap = new TapGestureRecognizer();
|
||||
tap.Tapped += Image_Tapped;
|
||||
|
||||
return new DataTemplate(() =>
|
||||
{
|
||||
var image = new Image
|
||||
{
|
||||
HorizontalOptions = LayoutOptions.Fill,
|
||||
VerticalOptions = LayoutOptions.Fill,
|
||||
Aspect = Aspect.AspectFit
|
||||
}
|
||||
.Binding(Image.SourceProperty, nameof(IllustDetailItem.Image));
|
||||
if (isAnime)
|
||||
{
|
||||
image.GestureRecognizers.Add(tap);
|
||||
}
|
||||
else
|
||||
{
|
||||
image.SetBinding(LongPressEffect.CommandProperty, nameof(IllustDetailItem.LongPressed));
|
||||
image.SetBinding(LongPressEffect.CommandParameterProperty, ".");
|
||||
image.Effects.Add(new LongPressEffect());
|
||||
}
|
||||
|
||||
return new Grid
|
||||
{
|
||||
Children =
|
||||
{
|
||||
image,
|
||||
|
||||
new Frame
|
||||
{
|
||||
HasShadow = false,
|
||||
Margin = default,
|
||||
Padding = new Thickness(20),
|
||||
CornerRadius = 8,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
Content = new ActivityIndicator
|
||||
{
|
||||
IsRunning = true,
|
||||
IsVisible = true
|
||||
}
|
||||
.DynamicResource(ActivityIndicator.ColorProperty, ThemeBase.WindowColor)
|
||||
}
|
||||
.Binding(IsVisibleProperty, nameof(IllustDetailItem.Loading))
|
||||
.DynamicResource(BackgroundColorProperty, ThemeBase.MaskColor),
|
||||
|
||||
new ActivityIndicator
|
||||
{
|
||||
IsRunning = true,
|
||||
Margin = new Thickness(10),
|
||||
HorizontalOptions = LayoutOptions.Start,
|
||||
VerticalOptions = LayoutOptions.Start
|
||||
}
|
||||
.Binding(IsVisibleProperty, nameof(IllustDetailItem.Downloading))
|
||||
.DynamicResource(ActivityIndicator.ColorProperty, ThemeBase.TextColor)
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void LoadIllust(IllustItem illust)
|
||||
{
|
||||
if (illust == null)
|
||||
@@ -395,7 +461,7 @@ namespace Pixiview.Illust
|
||||
{
|
||||
MainThread.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
var result = await FileStore.SaveImageToGalleryAsync(image, item.OriginalUrl);
|
||||
var result = await FileStore.SaveImageToGalleryAsync(image);
|
||||
|
||||
string message = result ?? ResourceHelper.SaveSuccess;
|
||||
await DisplayAlert(ResourceHelper.Title, message, ResourceHelper.Ok);
|
||||
|
Reference in New Issue
Block a user