-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from DotNetRu/develop
Update develop
- Loading branch information
Showing
11 changed files
with
318 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.