Skip to content

Commit 17f5008

Browse files
committed
hide study via swipe view
1 parent ef7c907 commit 17f5008

File tree

2 files changed

+44
-106
lines changed

2 files changed

+44
-106
lines changed

ClinicalTrials.Apps/Query.xaml

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Shell.TitleView>
1010
<Grid ColumnDefinitions="*,*,*" x:Name="titleView">
1111
<Button Text="&lt;" TextColor="{AppThemeBinding Dark=White,Light=Black}" Clicked="Back_Clicked" Background="Transparent" HorizontalOptions="Start"/>
12-
<Label Text="{Binding Name}" TextColor="{AppThemeBinding Dark=White, Light=Black}" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="Center" VerticalOptions="Center" Grid.Column="1" x:Name="profileLabel"/>
12+
<Label Text="{Binding Name}" MaxLines="2" LineBreakMode="TailTruncation" TextColor="{AppThemeBinding Dark=White, Light=Black}" FontAttributes="Bold" FontSize="Small" HorizontalOptions="Center" VerticalOptions="Center" Grid.Column="1" x:Name="profileLabel"/>
1313
<HorizontalStackLayout Grid.Column="2" HorizontalOptions="End">
1414
<Button Text="Save" Clicked="Save_Clicked" />
1515
</HorizontalStackLayout>
@@ -22,34 +22,38 @@
2222
<CollectionView x:Name="trialsView" ItemsSource="{Binding Studies}" Grid.Row="1" Grid.ColumnSpan="3">
2323
<CollectionView.ItemTemplate>
2424
<DataTemplate x:DataType="m:Study">
25-
<Grid ColumnDefinitions="*,100,100" RowDefinitions="Auto,Auto,Auto,Auto,25" >
26-
<Label FontSize="18">
27-
<Label.FormattedText>
28-
<FormattedString>
29-
<Span Text="{Binding ProtocolSection.IdentificationModule.Organization.Class}" />
30-
<Span Text=" / " />
31-
<Span Text="{Binding ProtocolSection.IdentificationModule.Organization.FullName}" />
32-
</FormattedString>
33-
</Label.FormattedText>
34-
</Label>
35-
<Label Text="{Binding ProtocolSection.StatusModule.OverallStatus}" Grid.Column="1" />
36-
<Label Text="{Binding ProtocolSection.StatusModule.LastUpdateSubmitDate.Date}" Grid.Column="2" />
37-
<Label Grid.Row="1" Margin="15,0">
38-
<Label.FormattedText>
39-
<FormattedString>
40-
<Span Text="{Binding ProtocolSection.IdentificationModule.NctId}" />
41-
</FormattedString>
42-
</Label.FormattedText>
43-
</Label>
44-
<Label Grid.Row="2" Margin="15,0" Grid.ColumnSpan="3">
45-
<Label.FormattedText>
46-
<FormattedString>
47-
<Span Text="{Binding ProtocolSection.IdentificationModule.BriefTitle}" />
48-
</FormattedString>
49-
</Label.FormattedText>
50-
</Label>
51-
52-
</Grid>
25+
<SwipeView>
26+
<SwipeView.RightItems>
27+
<SwipeItem Text="Hide" BackgroundColor="LightPink" Invoked="HideInvoked" />
28+
</SwipeView.RightItems>
29+
<Grid ColumnDefinitions="*,100,100" RowDefinitions="Auto,Auto,Auto,Auto,25" >
30+
<Label FontSize="18" Grid.ColumnSpan="2">
31+
<Label.FormattedText>
32+
<FormattedString>
33+
<Span Text="{Binding ProtocolSection.IdentificationModule.Organization.Class}" />
34+
<Span Text=" / " />
35+
<Span Text="{Binding ProtocolSection.IdentificationModule.Organization.FullName}" />
36+
</FormattedString>
37+
</Label.FormattedText>
38+
</Label>
39+
<Label Text="{Binding ProtocolSection.StatusModule.OverallStatus}" Grid.Column="2" Grid.Row="1"/>
40+
<Label Text="{Binding ProtocolSection.StatusModule.LastUpdateSubmitDate.Date}" Grid.Column="2" />
41+
<Label Grid.Row="1" Margin="15,0">
42+
<Label.FormattedText>
43+
<FormattedString>
44+
<Span Text="{Binding ProtocolSection.IdentificationModule.NctId}" />
45+
</FormattedString>
46+
</Label.FormattedText>
47+
</Label>
48+
<Label Grid.Row="2" Margin="15,0" Grid.ColumnSpan="3">
49+
<Label.FormattedText>
50+
<FormattedString>
51+
<Span Text="{Binding ProtocolSection.IdentificationModule.BriefTitle}" />
52+
</FormattedString>
53+
</Label.FormattedText>
54+
</Label>
55+
</Grid>
56+
</SwipeView>
5357
</DataTemplate>
5458
</CollectionView.ItemTemplate>
5559
</CollectionView>

ClinicalTrials.Apps/Query.xaml.cs

Lines changed: 11 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ private async void Save_Clicked(object sender, EventArgs e)
5454
}
5555
}
5656

57+
private void HideInvoked(object sender, EventArgs e)
58+
{
59+
var item = (sender as BindableObject).BindingContext as Study;
60+
QueryInfo.TrialsToHide.Add(item.ProtocolSection.IdentificationModule.NctId);
61+
QueryInfo.Studies.Remove(item);
62+
}
63+
5764
private async void Back_Clicked(object sender, EventArgs e)
5865
{
5966
await Shell.Current.GoToAsync(state: "///queries");
@@ -75,7 +82,10 @@ private async void Go_Clicked(object sender, EventArgs e)
7582
countTotal: true, pageSize: 100, pageToken: null, cancellationToken: token);
7683
foreach (var study in pagedStudies.Studies.OrderByDescending(s => s.ProtocolSection.StatusModule.LastUpdatePostDateStruct.Date))
7784
{
78-
QueryInfo.Studies.Add(study);
85+
if (!QueryInfo.TrialsToHide.Contains(study.ProtocolSection.IdentificationModule.NctId))
86+
{
87+
QueryInfo.Studies.Add(study);
88+
}
7989
}
8090
}
8191

@@ -184,44 +194,6 @@ private string link(string urlPrefix, string? linkUrl, string? label, bool newTa
184194
return "<a " + (newTab ? "target=_blank " : "") + "href=" + urlPrefix + Uri.EscapeDataString(linkUrl ?? "") + ">" + label + "</a>";
185195
}
186196

187-
private string links(string urlPrefix, List<string>? linkStrings, List<string>? labelStrings, string divider, bool newTab = true)
188-
{
189-
string? retString = "";
190-
if (linkStrings != null && labelStrings != null)
191-
{
192-
for (int i = 0; i < linkStrings.Count; i++)
193-
{
194-
if (retString != "")
195-
{
196-
retString += divider;
197-
}
198-
199-
retString += link(urlPrefix, linkStrings[i], labelStrings[i], newTab: newTab);
200-
}
201-
}
202-
203-
return retString;
204-
}
205-
206-
private string links(List<string>? linkStrings, List<string>? labelStrings, string divider, bool newTab = true)
207-
{
208-
string? retString = "";
209-
if (linkStrings != null && labelStrings != null)
210-
{
211-
for (int i = 0; i < linkStrings.Count; i++)
212-
{
213-
if (retString != "")
214-
{
215-
retString += divider;
216-
}
217-
218-
retString += link(linkStrings[i], "", labelStrings[i], newTab: newTab);
219-
}
220-
}
221-
222-
return retString;
223-
}
224-
225197
private string first(List<string>? strings)
226198
{
227199
if (strings != null && strings.Count > 0)
@@ -245,42 +217,4 @@ private string last(List<string>? strings)
245217
return "";
246218
}
247219
}
248-
249-
private string three(List<string> strings, string divider = " ")
250-
{
251-
return all(strings, 3, divider);
252-
}
253-
254-
private string all(List<string>? strings, string divider = " ")
255-
{
256-
return all(strings, -1, divider);
257-
}
258-
259-
private string all(List<string>? strings, int limit, string divider)
260-
{
261-
int count = 0;
262-
string? retString = "";
263-
if (strings != null)
264-
{
265-
foreach (var str in strings)
266-
{
267-
if (count++ == limit)
268-
{
269-
retString += divider + "...";
270-
break;
271-
}
272-
273-
if (retString != "")
274-
{
275-
retString += divider;
276-
}
277-
278-
retString += str;
279-
}
280-
}
281-
282-
return retString;
283-
}
284-
285-
286220
}

0 commit comments

Comments
 (0)