Skip to content

Commit fa826eb

Browse files
committed
refactor: issues for feedback
1 parent af2efbf commit fa826eb

11 files changed

Lines changed: 300 additions & 76 deletions

Lavcode.Common/RepositoryConstant.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ public static class RepositoryConstant
44
{
55
public static string GitAccount { get; } = "hal-wang";
66
public static string Repos { get; } = "Lavcode";
7-
public static int FeedbackIssueNumber { get; } = 1;
7+
public static string FeedbackIssueTag { get; } = "Client Feedback";
88
public static int NoticeIssueNumber { get; } = 2;
99
public static string GitHubUrl { get; } = "https://github.com";
1010
public static string GitHubRepositoryUrl { get; } = $"{GitHubUrl}/{GitAccount}/{Repos}";
11-
public static string GiteeUrl { get; } = "https://gitee.com";
12-
public static string GiteeRepositoryUrl { get; } = $"{GiteeUrl}/{GitAccount}/{Repos}";
1311

1412
public static string GitStorageRepos { get; } = "LavcodeStorage";
1513
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<!--
2+
Issue 列表
3+
-->
4+
5+
<UserControl
6+
x:Class="Lavcode.Uwp.Controls.Issue.IssueList"
7+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
8+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
9+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
10+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11+
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
12+
xmlns:octokit="using:Octokit"
13+
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
14+
mc:Ignorable="d"
15+
d:DesignHeight="300"
16+
d:DesignWidth="400"
17+
DataContext="{x:Bind}">
18+
19+
<ListView ItemsSource="{x:Bind Issues,Mode=OneWay}"
20+
x:Name="lv"
21+
IsItemClickEnabled="True"
22+
ItemClick="ListView_ItemClick"
23+
SelectionMode="None"
24+
BorderThickness="0 1 0 0">
25+
<ListView.BorderBrush>
26+
<SolidColorBrush Color="{ThemeResource SystemBaseHighColor}" Opacity="0.2"/>
27+
</ListView.BorderBrush>
28+
29+
<ListView.ItemContainerStyle>
30+
<Style TargetType="ListViewItem">
31+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
32+
<Setter Property="VerticalContentAlignment" Value="Stretch" />
33+
<Setter Property="BorderThickness" Value="0 0 0 1" />
34+
<Setter Property="BorderBrush">
35+
<Setter.Value>
36+
<SolidColorBrush Color="{ThemeResource SystemBaseHighColor}" Opacity="0.2"/>
37+
</Setter.Value>
38+
</Setter>
39+
<Setter Property="Background" Value="Transparent" />
40+
<Setter Property="Padding" Value="20 12" />
41+
<Setter Property="ui:FrameworkElementExtensions.Cursor" Value="Hand" />
42+
</Style>
43+
</ListView.ItemContainerStyle>
44+
45+
<ListView.ItemTemplate>
46+
<DataTemplate x:DataType="octokit:Issue">
47+
<StackPanel>
48+
<Grid>
49+
<Grid.ColumnDefinitions>
50+
<ColumnDefinition Width="auto"/>
51+
<ColumnDefinition Width="auto"/>
52+
<ColumnDefinition Width="auto"/>
53+
<ColumnDefinition Width="*"/>
54+
<ColumnDefinition Width="auto"/>
55+
</Grid.ColumnDefinitions>
56+
57+
<Button Style="{StaticResource LightButtonStyle}" Padding="0" HorizontalAlignment="Left" Click="AuthorButton_Click">
58+
<StackPanel Orientation="Horizontal">
59+
<Border VerticalAlignment="Center"
60+
Width="24"
61+
Height="24"
62+
CornerRadius="12"
63+
Margin="0 0 10 0">
64+
<Image Source="{x:Bind User.AvatarUrl}"/>
65+
</Border>
66+
<TextBlock Text="{x:Bind User.Login}"
67+
VerticalAlignment="Center"/>
68+
</StackPanel>
69+
</Button>
70+
71+
<TextBlock Grid.Column="1" Text="回复:" VerticalAlignment="Center" Margin="20 0 0 0" Opacity="0.7"/>
72+
<TextBlock Grid.Column="2" Text="{x:Bind Comments}" VerticalAlignment="Center" Opacity="0.7"/>
73+
<TextBlock Grid.Column="3" Text="{x:Bind Title}" FontSize="15" FontWeight="Bold" Margin="20 0 0 0" VerticalAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>
74+
75+
<TextBlock Grid.Column="4" HorizontalAlignment="Right" Opacity="0.7" VerticalAlignment="Center"
76+
Text="{x:Bind UpdatedAt,Converter={StaticResource DateFormatConverter},ConverterParameter=yyyy-MM-dd HH:mm:ssL}"/>
77+
</Grid>
78+
<controls:MarkdownTextBlock x:Name="MarkdownText"
79+
Margin="0 10 0 0"
80+
Text="{x:Bind Body}"
81+
Background="Transparent"
82+
Visibility="{x:Bind Body,Converter={StaticResource IsStrEmptyConverter},ConverterParameter=T}"
83+
LinkClicked="MarkdownText_LinkClicked"/>
84+
</StackPanel>
85+
</DataTemplate>
86+
</ListView.ItemTemplate>
87+
</ListView>
88+
</UserControl>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using Lavcode.Common;
2+
using System;
3+
using System.Collections.Generic;
4+
using Windows.System;
5+
using Windows.UI.Xaml;
6+
using Windows.UI.Xaml.Controls;
7+
8+
namespace Lavcode.Uwp.Controls.Issue
9+
{
10+
public sealed partial class IssueList : UserControl
11+
{
12+
public IssueList()
13+
{
14+
this.InitializeComponent();
15+
}
16+
17+
public IEnumerable<Octokit.Issue> Issues
18+
{
19+
get { return (IEnumerable<Octokit.Issue>)GetValue(IssuesProperty); }
20+
set { SetValue(IssuesProperty, value); }
21+
}
22+
23+
// Using a DependencyProperty as the backing store for Issues. This enables animation, styling, binding, etc...
24+
public static readonly DependencyProperty IssuesProperty =
25+
DependencyProperty.Register("Issues", typeof(IEnumerable<Octokit.Issue>), typeof(IssueList), new PropertyMetadata(null));
26+
27+
private async void MarkdownText_LinkClicked(object sender, Microsoft.Toolkit.Uwp.UI.Controls.LinkClickedEventArgs e)
28+
{
29+
await Launcher.LaunchUriAsync(new Uri(e.Link));
30+
}
31+
32+
private async void AuthorButton_Click(object sender, RoutedEventArgs e)
33+
{
34+
var issue = (sender as FrameworkElement).DataContext as Octokit.Issue;
35+
await Launcher.LaunchUriAsync(new Uri($"{RepositoryConstant.GitHubUrl}/{issue.User.Login}"));
36+
}
37+
38+
private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
39+
{
40+
if (e.ClickedItem is not Octokit.Issue issue)
41+
{
42+
return;
43+
}
44+
45+
await Launcher.LaunchUriAsync(new Uri(issue.HtmlUrl));
46+
}
47+
}
48+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using HTools.Uwp.Helpers;
2+
using Lavcode.Common;
3+
using Lavcode.Uwp.Helpers;
4+
using Microsoft.Toolkit.Collections;
5+
using Octokit;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using System.Threading;
10+
using System.Threading.Tasks;
11+
12+
namespace Lavcode.Uwp.Modules.Feedback
13+
{
14+
public class IssueSource : IIncrementalSource<Issue>
15+
{
16+
private readonly string[] _labels;
17+
public IssueSource(string[] labels)
18+
{
19+
_labels = labels;
20+
}
21+
22+
private readonly GitHubClient _client = GitHubHelper.GetBaseClient(RepositoryConstant.Repos);
23+
public async Task<IEnumerable<Issue>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default)
24+
{
25+
try
26+
{
27+
var issueRequest = new RepositoryIssueRequest()
28+
{
29+
SortDirection = SortDirection.Descending,
30+
SortProperty = IssueSort.Updated,
31+
State = ItemStateFilter.Open,
32+
};
33+
if (_labels != null)
34+
{
35+
foreach (var label in _labels)
36+
{
37+
issueRequest.Labels.Add(label);
38+
}
39+
}
40+
41+
return await _client.Issue.GetAllForRepository(
42+
RepositoryConstant.GitAccount,
43+
RepositoryConstant.Repos,
44+
issueRequest,
45+
new ApiOptions()
46+
{
47+
PageCount = 1,
48+
PageSize = pageSize,
49+
StartPage = pageIndex + 1,
50+
});
51+
}
52+
catch (Exception ex)
53+
{
54+
MessageHelper.ShowError(ex, 0);
55+
return new List<Issue>();
56+
}
57+
}
58+
}
59+
}

Lavcode.Uwp/Lavcode.Uwp.csproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,17 @@
144144
<Compile Include="Controls\Header.xaml.cs">
145145
<DependentUpon>Header.xaml</DependentUpon>
146146
</Compile>
147+
<Compile Include="Controls\Issue\IssueList.xaml.cs">
148+
<DependentUpon>IssueList.xaml</DependentUpon>
149+
</Compile>
147150
<Compile Include="Global.cs" />
148151
<Compile Include="Helpers\CommandLauncher.cs" />
149152
<Compile Include="Helpers\NetLoadingHelper.cs" />
150153
<Compile Include="Helpers\UpdateHelper.cs" />
151154
<Compile Include="Modules\Auth\ApiLoginDialog.xaml.cs">
152155
<DependentUpon>ApiLoginDialog.xaml</DependentUpon>
153156
</Compile>
157+
<Compile Include="Controls\Issue\IssueSource.cs" />
154158
<Compile Include="Modules\Guide\GuideHandler.cs" />
155159
<Compile Include="Modules\Guide\GuideItem.cs" />
156160
<Compile Include="Modules\Guide\GuideSettingMapItem.cs" />
@@ -394,6 +398,10 @@
394398
<Generator>MSBuild:Compile</Generator>
395399
<SubType>Designer</SubType>
396400
</Page>
401+
<Page Include="Controls\Issue\IssueList.xaml">
402+
<Generator>MSBuild:Compile</Generator>
403+
<SubType>Designer</SubType>
404+
</Page>
397405
<Page Include="Modules\Auth\ApiLoginDialog.xaml">
398406
<Generator>MSBuild:Compile</Generator>
399407
<SubType>Designer</SubType>
@@ -560,13 +568,13 @@
560568
<Version>0.10.4</Version>
561569
</PackageReference>
562570
<PackageReference Include="HTools">
563-
<Version>1.6.12</Version>
571+
<Version>1.6.16</Version>
564572
</PackageReference>
565573
<PackageReference Include="Microsoft.Extensions.DependencyInjection">
566574
<Version>6.0.0</Version>
567575
</PackageReference>
568576
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
569-
<Version>6.2.13</Version>
577+
<Version>6.2.14</Version>
570578
</PackageReference>
571579
<PackageReference Include="Microsoft.Services.Store.Engagement">
572580
<Version>10.1901.28001</Version>
@@ -584,10 +592,10 @@
584592
<Version>2.0.1</Version>
585593
</PackageReference>
586594
<PackageReference Include="Octokit">
587-
<Version>0.50.0</Version>
595+
<Version>3.0.0</Version>
588596
</PackageReference>
589597
<PackageReference Include="System.Interactive.Async">
590-
<Version>5.1.0</Version>
598+
<Version>6.0.1</Version>
591599
</PackageReference>
592600
</ItemGroup>
593601
<ItemGroup>

Lavcode.Uwp/Modules/Feedback/FeedbackDialog.xaml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,30 @@
1919
<lucv:DialogTitle Title="反馈" Closable="True" Dialog="{x:Bind}"/>
2020
</ContentDialog.Title>
2121

22-
<Grid Width="340">
23-
<TextBox PlaceholderText="填写反馈内容(支持 Markdown)"
24-
AcceptsReturn="True"
25-
MinHeight="100"
26-
MaxHeight="200"
27-
VerticalAlignment="Center"
28-
Text="{x:Bind VM.Content,Mode=TwoWay}"/>
29-
<Button Style="{ThemeResource LightButtonStyle}"
30-
ToolTipService.ToolTip="预览"
31-
HorizontalAlignment="Right"
32-
VerticalAlignment="Bottom"
33-
Click="Preview_Click">
34-
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE7B3;"/>
35-
</Button>
36-
</Grid>
22+
<StackPanel Width="340">
23+
<TextBox PlaceholderText="标题" Text="{x:Bind VM.Title,Mode=TwoWay}"/>
24+
25+
<Grid Margin="0 10 0 0">
26+
<TextBox PlaceholderText="填写反馈内容(可选,支持 Markdown)"
27+
TextWrapping="Wrap"
28+
AcceptsReturn="True"
29+
MinHeight="100"
30+
MaxHeight="200"
31+
VerticalAlignment="Center"
32+
Text="{x:Bind VM.Content,Mode=TwoWay}"/>
33+
<Button Style="{ThemeResource LightButtonStyle}"
34+
ToolTipService.ToolTip="预览"
35+
HorizontalAlignment="Right"
36+
VerticalAlignment="Bottom"
37+
Click="Preview_Click">
38+
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE7B3;"/>
39+
</Button>
40+
</Grid>
41+
42+
<StackPanel Margin="0 4 0 0" Opacity="0.6">
43+
<TextBlock Text="反馈完成后,等待短暂时间刷新才展现" FontSize="12" TextWrapping="Wrap"/>
44+
<TextBlock Text="内容公开显示,如果包含隐私信息请选择发邮件" FontSize="12" TextWrapping="Wrap"/>
45+
<TextBlock Text="修改请访问 GitHub 操作相关 Issues" FontSize="12" TextWrapping="Wrap"/>
46+
</StackPanel>
47+
</StackPanel>
3748
</ContentDialog>

Lavcode.Uwp/Modules/Feedback/FeedbackDialog.xaml.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Lavcode.Uwp.Modules.Feedback
1111
{
12-
public sealed partial class FeedbackDialog : ContentDialog, IResultDialog<bool>
12+
public sealed partial class FeedbackDialog : ContentDialog, IResultDialog<Issue>
1313
{
1414
public FeedbackDialog()
1515
{
@@ -37,7 +37,7 @@ private async void LayoutDialog_PrimaryButtonClick(ContentDialog sender, Content
3737
IsLoading = true;
3838
if (await VM.Feedback())
3939
{
40-
this.Hide(true);
40+
this.Hide(VM.IssueResult);
4141
}
4242
IsLoading = false;
4343
}
@@ -52,8 +52,6 @@ private async void Signup_Click(object sender, RoutedEventArgs e)
5252
await Launcher.LaunchUriAsync(new Uri(RepositoryConstant.GitHubUrl, UriKind.Absolute));
5353
}
5454

55-
public IssueComment CommentResult => VM.CommentResult;
56-
57-
public bool Result { get; set; } = false;
55+
public Issue Result { get; set; } = null;
5856
}
5957
}

0 commit comments

Comments
 (0)