Open Source Project - Crypto News App (UPDATE #5: Search Functionality)

in #utopian-io6 years ago (edited)

The aim of the application is to fetch news feed from preferred blogs and display on the application. It is structured in such a way that you can scroll through them like you would do on your social media timeline. It also leverages you the ability to read any of these news, right there on the app without having to open another browser application.

Screenshot_2018-01-31-04-37-02.png

Previous Updates

Updates

Search and Filter: In this new update, I added search functionality. Being able to filter specific information from a list/collection is one feature every application that handles data should have. I have now added that functionality to CryptoNews app. Users can now search within posts and filter out specific information based on their search.

First, I added a search bar to the content page.

<SearchBar TextChanged="SearchBar_TextChanged"></SearchBar>

Then I set an EventListener in the code behind to handle changes to the text in the searchBar entry.

public void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
        {
            var viewModel = BindingContext as BlogPostsViewModel;
            var list = viewModel.BlogPosts;

            if (string.IsNullOrEmpty(e.NewTextValue))
            {
                BlogPostsListView.ItemsSource = list;
            }

            else
            {
               var newList = list.Where(x => x.Title.ToLower().Contains(e.NewTextValue.ToLower())).ToList();
                BlogPostsListView.ItemsSource = newList;
            }
        }

What this block of code does exactly is to handle any change in the text of the search bar entry. If nothing is typed in, the resulting list is the original list from the database. However, with changes to the search text, the list updates itself to match only results containing the searched string in their title.
https://github.com/Johnesan/CryptoNews/blob/master/CryptoNews/CryptoNews/Views/BlogPosts.xaml.cs

https://github.com/Johnesan/CryptoNews/blob/master/CryptoNews/CryptoNews/Views/FavouriteBlogPosts.xaml.cs

Screenshot_2018-03-05-19-12-10_1.jpg

  • I created a custom renderer to handle having the search bar in the toolbar because xamarin.forms does not support it right out of the box. However, because of the fact that it is a hacked attempt, few compatibility issues still exist which may cause the app to close unexpectedly sometimes, when implemented.

More details of what I did are reflected in the commits

Roadmap

  • Due to the various issues associated with using a crossplatform framework such as large application file size, this application would be ported to native development environment to ensure seamless exprience, smooth feel, and leveraging usage of native API functionalities. @princessdharmy and @mathemandy have offered to help in that regard. This would leverage me time to focus more on the iOS implementation.

  • The scope of this application will eventually broaden to emcompass news from every sector (and not just crytpo).

Github Commits



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @johnesan I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.35
TRX 0.12
JST 0.039
BTC 69796.92
ETH 3521.66
USDT 1.00
SBD 4.70