Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

将搜索页改为对话框 #120

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PixivFSUWP/Controls/TagsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override Size MeasureOverride(Size availableSize)
else
widths[rowCount - 1] = tmpWidth;
}
return new Size(widths.Max(), rowCount * ItemHeight + (rowCount - 1) * ItemVerticalMargin);
return new Size(0, rowCount * ItemHeight + (rowCount - 1) * ItemVerticalMargin);
}

protected override Size ArrangeOverride(Size finalSize)
Expand Down
18 changes: 17 additions & 1 deletion PixivFSUWP/Data/OverAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,28 @@ public static class OverAll
public static UserIllustsCollection UserList { get; private set; }
public static MainPage TheMainPage { get; set; }

public struct SearchParam
public struct SearchParam : IEquatable<SearchParam>
{
public string Word;
public string SearchTarget;
public string Sort;
public string Duration;

public override bool Equals(object obj) => obj is SearchParam param && Equals(param);
public bool Equals(SearchParam other) => Word == other.Word && SearchTarget == other.SearchTarget && Sort == other.Sort && Duration == other.Duration;

public override int GetHashCode()
{
var hashCode = -582144489;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Word);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(SearchTarget);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Sort);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Duration);
return hashCode;
}

public static bool operator ==(SearchParam left, SearchParam right) => left.Equals(right);
public static bool operator !=(SearchParam left, SearchParam right) => !(left == right);
}

public static void RefreshRecommendList()
Expand Down
2 changes: 1 addition & 1 deletion PixivFSUWP/IllustDetailPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<DataTemplate x:DataType="viewmodels:TagViewModel">
<Grid Width="Auto" VerticalAlignment="Stretch">
<Button x:Name="btnTag" Tag="{Binding Tag}" HorizontalAlignment="Stretch"
Style="{StaticResource ButtonRevealStyle}" Height="25">
Style="{StaticResource ButtonRevealStyle}" Height="25" Click="BtnTag_Click">
<Grid Background="Transparent" Margin="0 -5">
<TextBlock Text="{Binding Tag}" FontSize="12"/>
</Grid>
Expand Down
9 changes: 9 additions & 0 deletions PixivFSUWP/IllustDetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,5 +523,14 @@ private async void btnPublishComment_Click(object sender, RoutedEventArgs e)
txtComment.Text = "";
}
}

private void BtnTag_Click(object sender, RoutedEventArgs e)
=> new SearchDialog(Frame).Search(new SearchParam
{
Word = (sender as Button).Tag as string,
SearchTarget = "exact_match_for_tags",
Sort = "date_desc",
Duration = null
});
}
}
12 changes: 1 addition & 11 deletions PixivFSUWP/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,7 @@ private void BtnMe_Click(object sender, RoutedEventArgs e)
}

private async void BtnSearch_Click(object sender, RoutedEventArgs e)
{
try
{
if (ContentFrame.Content is SearchPage)
await (ContentFrame.Content as SearchPage).ShowSearch();
else
ContentFrame.Navigate(typeof(SearchPage), WaterfallPage.ListContent.SearchResult, App.FromRightTransitionInfo);
}
//吞掉异常,这个异常没有意义
catch { }
}
=> await new SearchDialog(ContentFrame).ShowAsync();

public void UpdateNavButtonState()
{
Expand Down
6 changes: 3 additions & 3 deletions PixivFSUWP/PixivFSUWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@
<Compile Include="ReportIssuePage.xaml.cs">
<DependentUpon>ReportIssuePage.xaml</DependentUpon>
</Compile>
<Compile Include="SearchPage.xaml.cs">
<DependentUpon>SearchPage.xaml</DependentUpon>
<Compile Include="SearchDialog.xaml.cs">
<DependentUpon>SearchDialog.xaml</DependentUpon>
</Compile>
<Compile Include="SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
Expand Down Expand Up @@ -276,7 +276,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SearchPage.xaml">
<Page Include="SearchDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
143 changes: 143 additions & 0 deletions PixivFSUWP/SearchDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<ContentDialog
x:Class="PixivFSUWP.SearchDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PixivFSUWP"
xmlns:viewmodels="using:PixivFSUWP.ViewModels"
xmlns:controls="using:PixivFSUWP.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<ContentDialog.Background>
<AcrylicBrush x:Name="detailBackground" BackgroundSource="Backdrop" TintOpacity="0.2" TintColor="{ThemeResource SystemAltHighColor}" FallbackColor="{ThemeResource SystemAltHighColor}"/>
</ContentDialog.Background>
<FrameworkElement.Resources>
<Style x:Key="DigitOnlyAutoSuggestBox" TargetType="AutoSuggestBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="AutoSuggestBox">
<Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="Orientation">
<VisualState x:Name="Landscape"/>
<VisualState x:Name="Portrait"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TextBox x:Name="TextBox" ScrollViewer.BringIntoViewOnFocusChange="False" Description="{TemplateBinding Description}"
DesiredCandidateWindowAlignment="BottomEdge" Header="{TemplateBinding Header}" Margin="0"
PlaceholderText="{TemplateBinding PlaceholderText}" Style="{TemplateBinding TextBoxStyle}" InputScope="Digits"
UseSystemFocusVisuals="{TemplateBinding UseSystemFocusVisuals}" Width="{TemplateBinding Width}" Canvas.ZIndex="0"
TextChanging="style_TextBox_TextChanging" BeforeTextChanging="style_TextBox_BeforeTextChanging"/>
<Popup x:Name="SuggestionsPopup">
<Border x:Name="SuggestionsContainer">
<ListView x:Name="SuggestionsList" Background="{ThemeResource AutoSuggestBoxSuggestionsListBackground}"
BorderThickness="{ThemeResource AutoSuggestListBorderThemeThickness}"
BorderBrush="{ThemeResource AutoSuggestBoxSuggestionsListBorderBrush}"
DisplayMemberPath="{TemplateBinding DisplayMemberPath}" ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
ItemTemplate="{TemplateBinding ItemTemplate}" IsItemClickEnabled="True"
ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}" MaxHeight="{ThemeResource AutoSuggestListMaxHeight}"
Margin="{ThemeResource AutoSuggestListMargin}" Padding="{ThemeResource AutoSuggestListPadding}"/>
</Border>
</Popup>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</FrameworkElement.Resources>
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" FontSize="14" FontWeight="Bold" x:Uid="Keyword"/>
<AutoSuggestBox Margin="0 5 0 0" x:Name="txtWord" x:Uid="Search" QuerySubmitted="TxtWord_QuerySubmitted"
HorizontalAlignment="Stretch" QueryIcon="Find"/>
<TextBlock Margin="0 10 0 0" HorizontalAlignment="Left" FontSize="14" FontWeight="Bold" x:Uid="SearchOptions"/>
<Grid Margin="0 5 0 0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="5"/>
<ColumnDefinition/>
<ColumnDefinition Width="5"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ComboBox x:Name="cbSearchTarget" IsEditable="False" BorderThickness="1"
HorizontalAlignment="Stretch" SelectedIndex="0">
<ComboBox.Items>
<ComboBoxItem x:Uid="PartiallyMatchTag"/>
<ComboBoxItem x:Uid="FullyMatchTag"/>
<ComboBoxItem x:Uid="PartiallyMatchTitleAndCap"/>
</ComboBox.Items>
</ComboBox>
<ComboBox x:Name="cbSort" Grid.Column="2" IsEditable="False" BorderThickness="1"
HorizontalAlignment="Stretch" SelectedIndex="0">
<ComboBox.Items>
<ComboBoxItem x:Uid="DateDesc"/>
<ComboBoxItem x:Uid="DateAsc"/>
</ComboBox.Items>
</ComboBox>
<ComboBox x:Name="cbDuration" Grid.Column="4" IsEditable="False" BorderThickness="1"
HorizontalAlignment="Stretch" SelectedIndex="0">
<ComboBox.Items>
<ComboBoxItem x:Uid="AllTime"/>
<ComboBoxItem x:Uid="LastDay"/>
<ComboBoxItem x:Uid="LastWeek"/>
<ComboBoxItem x:Uid="LastMonth"/>
</ComboBox.Items>
</ComboBox>
</Grid>
<TextBlock Margin="0,10,0,0" HorizontalAlignment="Left" FontSize="14" FontWeight="Bold" x:Uid="SearchMore"/>
<Grid Grid.Row="1" Margin="0,10,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" HorizontalAlignment="Stretch">
<TextBlock x:Uid="GoToPixivID"/>
<AutoSuggestBox Style="{StaticResource DigitOnlyAutoSuggestBox}" x:Name="asbGTPID" Margin="0 5 0 0" x:Uid="GoPixivID" QuerySubmitted="GoPixivID_QuerySubmitted"
HorizontalAlignment="Stretch" QueryIcon="Forward"/>
</StackPanel>
<Button Grid.Row="1" Margin="0,5,0,0" x:Name="btnSauceNAO" x:Uid="BtnSauceNAO" HorizontalAlignment="Stretch" Click="btnSauceNAO_Click" Visibility="Collapsed"/>
</Grid>
<StackPanel Margin="0 10 0 0" HorizontalAlignment="Left" Orientation="Horizontal">
<TextBlock FontSize="14" FontWeight="Bold" x:Uid="TrendingTags"/>
<TextBlock Margin="5 0 0 0" FontSize="12" Foreground="{ThemeResource SystemBaseMediumColor}" VerticalAlignment="Bottom" x:Uid="TagWarning"/>
</StackPanel>
<ProgressBar IsIndeterminate="True" x:Name="progressRing"/>
<ItemsControl x:Name="panelTags" Margin="0 5 0 0">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="viewmodels:TagViewModel">
<Grid Width="Auto" VerticalAlignment="Stretch">
<Button x:Name="btnTag" Tag="{Binding Tag}" HorizontalAlignment="Stretch"
Style="{StaticResource ButtonRevealStyle}" Height="25"
Click="BtnTag_Click">
<Grid Background="Transparent" Margin="0 -5">
<TextBlock Text="{Binding Tag}" FontSize="12"/>
</Grid>
</Button>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<controls:TagsPanel ItemHorizontalMargin="5" ItemHeight="25" ItemVerticalMargin="5">
<controls:TagsPanel.ChildrenTransitions>
<TransitionCollection>
<PopupThemeTransition FromVerticalOffset="150"/>
</TransitionCollection>
</controls:TagsPanel.ChildrenTransitions>
</controls:TagsPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<StackPanel.ChildrenTransitions>
<TransitionCollection>
<AddDeleteThemeTransition/>
<PaneThemeTransition/>
</TransitionCollection>
</StackPanel.ChildrenTransitions>
</StackPanel>
</ContentDialog>
Loading