Skip to content

Instantly share code, notes, and snippets.

View lubiepomaranczki's full-sized avatar

lubiepomaranczki

View GitHub Profile
@lubiepomaranczki
lubiepomaranczki / INavigationService
Last active February 3, 2018 17:15
INavigationService
public interface INavigationService
{
void RegisterPage(string pageKey, Type pageType);
void NavigateTo(string key, bool animated = true);
void NavigateTo(string pageKey, bool animated = true, params (string propertyName, object parameter)[] args);
void GoBack();
}
@lubiepomaranczki
lubiepomaranczki / NavigationService
Created February 3, 2018 17:16
NavigationService
public class NavigationService : INavigationService
{
#region Fields
private INavigation navigation => (Application.Current.MainPage as Main.Views.MainPage)?.Detail.Navigation;
private readonly IDictionary<string, Type> pageLookup = new Dictionary<string, Type>();
#endregion
@lubiepomaranczki
lubiepomaranczki / NavigationService - usage
Last active February 3, 2018 17:53
NavigationService - usage
//In App.xaml.cs
private void ConfigurePages()
{
navigationService.RegisterPage(nameof(Main.Views.WebPage), typeof(Main.Views.WebPage));
navigationService.RegisterPage("Whatever-key-you-want", typeof(Main.Views.WebPage));
}
//In your ViewModel, where you've injected INavigationService as Navigation
//Navigating without params
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.8.1">
<id>XamForms.Enhanced</id>
<version>1.0.4</version>
<title>Custom controls and extensions for Xamarin.Forms</title>
<authors>Lukasz Lawicki</authors>
<owners>Lukasz Lawicki</owners>
<licenseUrl>https://github.com/lubiepomaranczki/XamForms.Enhanced/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/lubiepomaranczki/XamForms.Enhanced</projectUrl>
@lubiepomaranczki
lubiepomaranczki / NormalProperty
Last active June 18, 2018 10:25
Medium ObservablePropery
private string searchText;
public string SearchText
{
get { return searchText; }
set { SetProperty(ref searchText, value); }
}
public ObservableProperty<string> SearchText = new ObservableProperty<string>();
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:XamForms.Enhanced.Views;assembly=XamForms.Enhanced"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="Medium.Sample.Views.SearchText"
Title="{Binding Title}">
<ContentPage.Content>
<SearchBar Text="{Binding SearchText.Value}"
public RegisterPageViewModel()
{
Observe();
Title = "SearchText";
}
public void Observe()
{
Observable.FromEventPattern(ev => SearchText.DataChanged += ev, ev => SearchText.DataChanged -= ev)
@lubiepomaranczki
lubiepomaranczki / CustomLoader
Last active October 3, 2018 07:32
Taken from sample repository: https://github.com/lubiepomaranczki/CustomLoader associated with my article:
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace CustomLoader
{
public class CustomLoader : Image
{
#region Fields
#!/bin/bash
PATH_TO_PROJECT="$1"
SONAR_TOKEN="{YOUR-TOKEN}"
PROJECT_NAME="$( echo "$1" | sed 's@.*/@@' )"
if [[ -z "$PROJECT_NAME" ]]; then
echo "Project name can't be null. Either project does not exist or you have / at the end of path"
exit;
fi