Skip to content

Instantly share code, notes, and snippets.

View tugcearar's full-sized avatar
🍋

Tuğçe Arar tugcearar

🍋
View GitHub Profile
@tugcearar
tugcearar / gist:a0bf9eaa92925e77da2141f2209cc15c
Created February 5, 2017 21:58 — forked from brianmed/gist:4e458d9116889b798a8c
Xamarin Forms custom webView renderer with activity load
***
In Shared code:
public class WebViewPage : ContentPage
{
}
...
await Navigation.PushAsync (new WebViewPage());
<StackLayout VerticalOptions="Center">
<Label x:Name="lblText" Text="0" HorizontalOptions="Start" FontSize="Micro" HorizontalTextAlignment="Center" VerticalOptions="EndAndExpand" >
<Label.Margin>
<OnPlatform x:TypeArguments="Thickness">
<On Platform="iOS" Value="15,0" />
<On Platform="Android" Value="10,0" />
</OnPlatform>
</Label.Margin>
</Label>
<Slider x:Name="mySlider" Maximum="10000" Minimum="100" HorizontalOptions="FillAndExpand" ValueChanged="Handle_ValueChanged" >
@tugcearar
tugcearar / EmptyCollectionContractResolver.cs
Created February 26, 2018 13:25 — forked from ejsmith/EmptyCollectionContractResolver.cs
EmptyCollectionContractResolver
class EmptyCollectionContractResolver : DefaultContractResolver {
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
JsonProperty property = base.CreateProperty(member, memberSerialization);
Predicate<object> shouldSerialize = property.ShouldSerialize;
property.ShouldSerialize = obj => (shouldSerialize == null || shouldSerialize(obj)) && !IsEmptyCollection(property, obj);
return property;
}
private bool IsEmptyCollection(JsonProperty property, object target) {
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.LayoutPage">
<ContentPage.Content>
<StackLayout>
<Image Source="icon.png" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
void Slider_ValueChanged(object sender, Xamarin.Forms.ValueChangedEventArgs e)
{
var newStep = Math.Round(e.NewValue / 100);
mySlider.Value = newStep * 100;
lblText.Text = mySlider.Value.ToString();
lblText.TranslateTo(mySlider.Value * ((mySlider.Width - 40) / mySlider.Maximum) , 0, 100);
}
public class ListViewPageViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName]string propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
private IList<Birds> birdsList;
bool isRefreshing;
private bool isEmpty;
public bool IsEmpty
public class Birds
{
public string Title { get; set; }
public string Description { get; set; }
}
public class Converter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return !(bool)value;
}
<ContentView.Content>
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<Image Source="empty.png"/>
<Label Text="There is nothing in here." FontSize="Medium" TextColor="{DynamicResource TextColorLight}"/>
</StackLayout>
</ContentView.Content>
<?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:control="clr-namespace:XFEmptyViewSample.Controls"
xmlns:helper="clr-namespace:XFEmptyViewSample.Helpers"
xmlns:viewmodel="clr-namespace:XFEmptyViewSample.ViewModels"
x:Class="XFEmptyViewSample.Views.ListViewPage" Title="Birds">
<ContentPage.BindingContext>
<viewmodel:ListViewPageViewModel/>
</ContentPage.BindingContext>