Skip to content

Commit

Permalink
Merge pull request #5 from DotNetRu/develop
Browse files Browse the repository at this point in the history
Update develop
  • Loading branch information
unchase authored Mar 22, 2020
2 parents 9827d16 + 100dd60 commit 286a353
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 85 deletions.
2 changes: 1 addition & 1 deletion DotNetRu.Clients.UI/BasePages/ViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public LocalizedResources Resources
?? (this.launchBrowserCommand = new Command<Uri>(
async (t) => await this.ExecuteLaunchBrowserAsync(t)));

protected INavigation Navigation { get; }
protected internal INavigation Navigation { get; }

protected ILogger Logger { get; } = DependencyService.Get<ILogger>();

Expand Down
54 changes: 54 additions & 0 deletions DotNetRu.Clients.UI/Handlers/NewsSearchHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DotNetRu.Clients.Portable.Model;
using Xamarin.Essentials;
using Xamarin.Forms;

namespace DotNetRu.Clients.UI.Handlers
{
public class NewsSearchHandler : SearchHandler
{
private IEnumerable<Tweet> _tweets;

private bool _isFirstSearch = true;

protected override void OnQueryChanged(string oldValue, string newValue)
{
base.OnQueryChanged(oldValue, newValue);

if (ItemsSource is IEnumerable<Tweet> tweets)
{
if (_isFirstSearch)
{
this._tweets = tweets;
this._isFirstSearch = false;
}

if (string.IsNullOrWhiteSpace(newValue))
{
ItemsSource = this._tweets;
}
else
{
ItemsSource = this._tweets.Where(x =>
x.Text.Contains(newValue, StringComparison.InvariantCultureIgnoreCase) ||
x.Name.Contains(newValue, StringComparison.InvariantCultureIgnoreCase))
.OrderBy(x => x.CreatedDate)
.ToList();
}
}
}

protected override async void OnItemSelected(object item)
{
base.OnItemSelected(item);
if (item is Tweet tweet && !string.IsNullOrWhiteSpace(tweet.Url))
{
App.Logger.TrackPage(AppPage.Tweet.ToString(), tweet.Url);

await Launcher.OpenAsync(new Uri(tweet.Url));
}
}
}
}
57 changes: 57 additions & 0 deletions DotNetRu.Clients.UI/Handlers/SpeakersSearchHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DotNetRu.Clients.Portable.Model;
using DotNetRu.Clients.Portable.ViewModel;
using DotNetRu.Clients.UI.Speakers;
using DotNetRu.DataStore.Audit.Models;
using MvvmHelpers;
using Xamarin.Forms;

namespace DotNetRu.Clients.UI.Handlers
{
public class SpeakersSearchHandler : SearchHandler
{
private IEnumerable<Grouping<char, SpeakerModel>> _speakerGroups;

private bool _isFirstSearch = true;

protected override void OnQueryChanged(string oldValue, string newValue)
{
base.OnQueryChanged(oldValue, newValue);

if (ItemsSource is IEnumerable<Grouping<char, SpeakerModel>> speakerGroups)
{
if (_isFirstSearch)
{
this._speakerGroups = speakerGroups;
this._isFirstSearch = false;
}

if (string.IsNullOrWhiteSpace(newValue))
{
ItemsSource = this._speakerGroups;
}
else
{
ItemsSource = this._speakerGroups.SelectMany(speaker => speaker.Items).Where(x =>
x.FullName.Contains(newValue, StringComparison.InvariantCultureIgnoreCase)).ToList();
}
}
}

protected override async void OnItemSelected(object item)
{
base.OnItemSelected(item);
if (item is SpeakerModel speaker)
{
App.Logger.TrackPage(AppPage.Speaker.ToString(), speaker.FullName);

if (BindingContext is ViewModelBase viewModel)
{
await viewModel.Navigation.PushAsync(new SpeakerDetailsPage { SpeakerModel = speaker });
}
}
}
}
}
31 changes: 29 additions & 2 deletions DotNetRu.Clients.UI/Localization/AppResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions DotNetRu.Clients.UI/Localization/AppResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ Sergey Polezhaev</value>
<data name="EkbDotNet" xml:space="preserve">
<value>Ekaterinburg</value>
</data>
<data name="Enter search term" xml:space="preserve">
<value>Enter search term</value>
</data>
<data name="Enter speaker fullname" xml:space="preserve">
<value>Enter speaker fullname</value>
</data>
<data name="ErrorOccured" xml:space="preserve">
<value>Error occured</value>
</data>
Expand Down
60 changes: 33 additions & 27 deletions DotNetRu.Clients.UI/Localization/AppResources.ru.resx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -337,4 +337,10 @@
<data name="EkbDotNet" xml:space="preserve">
<value>Екатеринбург</value>
</data>
<data name="Enter search term" xml:space="preserve">
<value>Введите поисковый запрос</value>
</data>
<data name="Enter speaker fullname" xml:space="preserve">
<value>Введите имя спикера</value>
</data>
</root>
Loading

0 comments on commit 286a353

Please sign in to comment.