Archived
1
0

Inbox development 2

This commit is contained in:
Michael Gordeev
2018-07-30 01:08:25 +03:00
parent 2ab98fc0d8
commit 1039acb96a
6 changed files with 121 additions and 79 deletions
+4 -1
View File
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<items>
<item time="YYYY-MM-DDThh:mm:ss-03" version="1.0.1">
<item time="2018-07-29T23:00:00-03" version="1.0.1">
<content>Announcement body (beware of special characters)</content>
</item>
</items>
<!--<item time="YYYY-MM-DDThh:mm:ss-03" version="1.0.1">
<content>Announcement body (beware of special characters)</content>
</item>-->
+5 -4
View File
@@ -8,7 +8,7 @@ namespace FoxTube.Classes
public class InboxItem
{
public InboxItemType Type { get; set; } = InboxItemType.Default;
DateTime TimeStamp { get; set; }
public DateTime TimeStamp { get; set; }
public string PatchVersion { get; set; }
public string Subject { get; set; }
@@ -19,9 +19,9 @@ namespace FoxTube.Classes
get
{
if (Type == InboxItemType.PatchNote)
return @"&#xE728;";
return "\xE728";
else
return @"&#xE119;";
return "\xE119";
}
}
public string Subtitle
@@ -52,13 +52,14 @@ namespace FoxTube.Classes
Type = InboxItemType.PatchNote;
PatchVersion = version;
Content = content;
TimeStamp = XmlConvert.ToDateTime(timeStamp, XmlDateTimeSerializationMode.Unspecified);
TimeStamp = DateTime.Parse(timeStamp);
}
public InboxItem(string title, string content, DateTime timeStamp)
{
Type = InboxItemType.Default;
Content = content;
Subject = title;
TimeStamp = timeStamp;
}
}
+17 -55
View File
@@ -16,15 +16,20 @@
</Grid.ColumnDefinitions>
<ScrollViewer>
<StackPanel VerticalAlignment="Stretch" Background="#FFF2F2F2">
<ComboBox Header="Filter" Margin="10" HorizontalAlignment="Stretch" SelectedIndex="0">
<ComboBox Header="Filter" Margin="10" HorizontalAlignment="Stretch" SelectedIndex="0" Name="filter" SelectionChanged="filter_SelectionChanged">
<ComboBoxItem Content="All"/>
<ComboBoxItem Content="Messages"/>
<ComboBoxItem Content="Patch notes"/>
</ComboBox>
<ListBox>
<ListBox Name="list" SelectionChanged="list_SelectionChanged">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="10"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem Padding="10" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
@@ -39,68 +44,25 @@
<TextBlock FontWeight="Bold" Text="{Binding Path=Title}"/>
<TextBlock Foreground="Gray" Text="{Binding Path=Subtitle}"/>
</StackPanel>
<TextBlock Foreground="Gray" FontSize="13" Text="{Binding Path=Timestamp}" Grid.Column="2"/>
<TextBlock Foreground="Gray" FontSize="13" Text="{Binding Path=TimeStamp}" Grid.Column="2"/>
</Grid>
</ListBoxItem>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBoxItem Padding="10" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<PersonPicture Height="40" Initials="&#xE728;" FontFamily="Segoe MDL2 Assets" Background="Red" Margin="0,0,10,0"/>
<StackPanel Grid.Column="1">
<TextBlock FontWeight="Bold" Text="What's new in v1.01"/>
<TextBlock Foreground="Gray" Text="Patch note"/>
</StackPanel>
<TextBlock Foreground="Gray" FontSize="13" Text="11:00 PM" Grid.Column="2"/>
</Grid>
</ListBoxItem>
<ListBoxItem Padding="10" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<PersonPicture Height="40" Initials="&#xE119;" FontFamily="Segoe MDL2 Assets" Background="Red" Margin="0,0,10,0"/>
<StackPanel Grid.Column="1">
<TextBlock FontWeight="Bold" Text="Hello, World! We went live!"/>
<TextBlock Foreground="Gray" Text="Developer's message"/>
</StackPanel>
<TextBlock Foreground="Gray" FontSize="13" Text="11:00 PM" Grid.Column="2"/>
</Grid>
</ListBoxItem>
<ListBoxItem Padding="10" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid Margin="0,0,10,0">
<Ellipse Fill="Red" Height="40" Width="40"/>
<TextBlock Foreground="White" FontFamily="Segoe MDL2 Assets" Text="&#xE119;" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Light" FontSize="17"/>
</Grid>
<StackPanel Grid.Column="1">
<TextBlock FontWeight="Bold" Text="Hello, World! We went live!"/>
<TextBlock Foreground="Gray" Text="Developer's message"/>
</StackPanel>
<TextBlock Foreground="Gray" FontSize="13" Text="11:00 PM" Grid.Column="2"/>
</Grid>
</ListBoxItem>
</ListBox>
</StackPanel>
</ScrollViewer>
<ScrollViewer Grid.Column="1">
<StackPanel Margin="10">
<TextBlock FontWeight="Bold" Text="Hello, World!" FontSize="26"/>
<controls:MarkdownTextBlock IsTextSelectionEnabled="True" Text="Content"/>
<TextBlock FontWeight="Bold" Text="Hello, World!" FontSize="26" Name="title"/>
<controls:MarkdownTextBlock IsTextSelectionEnabled="True" Text="Content" Name="content"/>
</StackPanel>
</ScrollViewer>
<Grid Grid.Column="1" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Name="block">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE7EA;" FontSize="75" Foreground="Gray" Margin="10"/>
<TextBlock Text="Select item from list" FontSize="32" VerticalAlignment="Center" Foreground="Gray"/>
</StackPanel>
</Grid>
</Grid>
</Page>
+66 -5
View File
@@ -14,6 +14,7 @@ using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using FoxTube.Classes;
using System.Xml;
using Windows.Storage;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -24,6 +25,7 @@ namespace FoxTube.Pages
/// </summary>
public sealed partial class Inbox : Page
{
List<InboxItem> backup = new List<InboxItem>();
List<InboxItem> items = new List<InboxItem>();
public Inbox()
{
@@ -31,11 +33,16 @@ namespace FoxTube.Pages
LoadItems();
}
public void LoadItems()
public async void LoadItems()
{
XmlDocument doc = new XmlDocument();
doc.Load("ms-appx:///Assets/Data/Patchnotes.xml");
string path = @"Assets\Data\Patchnotes.xml";
StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFile file = await InstallationFolder.GetFileAsync(path);
Stream Countries = await file.OpenStreamForReadAsync();
doc.Load(Countries);
foreach (XmlElement e in doc["items"].ChildNodes)
items.Add(new InboxItem(
e.GetAttribute("version"),
@@ -44,14 +51,68 @@ namespace FoxTube.Pages
));
doc.Load("http://foxgame.hol.es/ftp.xml");
foreach (XmlElement e in doc["items"].ChildNodes)
foreach (XmlElement e in doc["posts"].ChildNodes)
items.Add(new InboxItem(
e["header"].InnerText,
e["content"].InnerText,
XmlConvert.ToDateTime(e.GetAttribute("time"), XmlDateTimeSerializationMode.Unspecified)
DateTime.Parse(e.GetAttribute("time"))
));
items.Sort();
items.OrderBy(item => item.TimeStamp);
foreach (InboxItem i in items)
backup.Add(i);
list.ItemsSource = items;
}
private void filter_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
items.Clear();
switch (filter.SelectedIndex)
{
case 0:
foreach (InboxItem i in backup)
items.Add(i);
break;
case 1:
foreach (InboxItem i in backup)
if(i.Type == InboxItemType.Default)
items.Add(i);
break;
case 2:
foreach (InboxItem i in backup)
if (i.Type == InboxItemType.PatchNote)
items.Add(i);
break;
}
list.ItemsSource = items;
}
catch(NullReferenceException) { }
}
private void list_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
InboxItem item = list.SelectedItem as InboxItem;
OpenView(item.Title, item.Content);
}
void CloseView()
{
content.Text = "";
title.Text = "";
block.Visibility = Visibility.Visible;
}
void OpenView(string header, string body)
{
content.Text = body;
title.Text = header;
block.Visibility = Visibility.Collapsed;
}
}
}
+7
View File
@@ -5,6 +5,7 @@
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="using:FoxTube.Pages"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
@@ -127,6 +128,9 @@
<PivotItem Margin="0,-48,0,0">
<local:Translate/>
</PivotItem>
<PivotItem Margin="0,-48,0,0">
<pages:Inbox/>
</PivotItem>
</Pivot>
</ScrollViewer>
<Grid Grid.Row="0" Background="Red">
@@ -146,6 +150,9 @@
<HyperlinkButton Foreground="White" Margin="0,0,10,0" Name="toTranslate" Click="toTranslate_Click">
<TextBlock Text="Help us translate this app"/>
</HyperlinkButton>
<HyperlinkButton Foreground="White" Margin="0,0,10,0" Name="toInbox" Click="toInbox_Click">
<TextBlock Text="Inbox"/>
</HyperlinkButton>
</StackPanel>
</Grid>
</Grid>
+8
View File
@@ -116,6 +116,7 @@ namespace FoxTube
toFeedback.FontWeight = FontWeights.Normal;
toAbout.FontWeight = FontWeights.Normal;
toTranslate.FontWeight = FontWeights.Normal;
toInbox.FontWeight = FontWeights.Normal;
if (content.SelectedIndex == 0)
toGeneral.FontWeight = FontWeights.Bold;
@@ -127,6 +128,8 @@ namespace FoxTube
toAbout.FontWeight = FontWeights.Bold;
else if (content.SelectedIndex == 4)
toTranslate.FontWeight = FontWeights.Bold;
else if (content.SelectedIndex == 5)
toInbox.FontWeight = FontWeights.Bold;
}
private void toAccount_Click(object sender, RoutedEventArgs e)
@@ -148,5 +151,10 @@ namespace FoxTube
{
settings.Values["safeSearch"] = safeSearch.SelectedIndex;
}
private void toInbox_Click(object sender, RoutedEventArgs e)
{
content.SelectedIndex = 5;
}
}
}