Skip to content

Instantly share code, notes, and snippets.

View QiMata's full-sized avatar

Jared Rhodes QiMata

View GitHub Profile
@QiMata
QiMata / ContentViewRoundedCorners.cs
Created February 1, 2016 21:28
The shared control for creating the rounded corners
public class ContentViewRoundedCorners : ContentView
{
public static readonly BindableProperty CornerRaidusProperty =
BindableProperty.Create<ContentViewRoundedCorners, float>(x => x.CornerRadius, 0);
public float CornerRadius
{
get { return (float) GetValue(CornerRaidusProperty); }
set { SetValue(CornerRaidusProperty, value); }
}
@QiMata
QiMata / ContentViewRoundedCornersRenderer.cs
Created February 1, 2016 21:31
Only works for Android 4.2 or higher. The android renderer for the ContentViewRoundedCorners control.
class ContentViewRoundedCornersRenderer : VisualElementRenderer<ContentView>
{
private float _cornerRadius;
private RectF _bounds;
private Path _path;
protected override void OnElementChanged(ElementChangedEventArgs<ContentView> e)
{
base.OnElementChanged(e);
@QiMata
QiMata / ContentViewRoundedCornersRenderer.cs
Created February 1, 2016 21:33
The iOS renderer for ContentViewRoundedCorners control.
class ContentViewRoundedCornersRenderer : VisualElementRenderer<ContentView>
{
protected override void OnElementChanged(ElementChangedEventArgs<ContentView> e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
return;
}
@QiMata
QiMata / ContentViewRoundedCornersExample.xaml
Created February 1, 2016 21:36
An example usage using XAML
<yournamespace:ContentViewRoundedCorners
CornerRadius="10">
<ContentView.Content>
<Label TextColor="Blue"
Text="Cool Demo Jared"
VerticalTextAlignment="Center" HorizontalTextAlignment="Center"></Label>
</ContentView.Content>
</yournamespace:ContentViewRoundedCorners>
[assembly:ExportRenderer(typeof(BaseNavigationPage),typeof(BaseNavigationPageRenderer))]
namespace yournamespace
{
class CustomNavigationPageRenderer : NavigationPageGradientHeaderRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
@QiMata
QiMata / curl_client.cpp
Last active February 15, 2016 12:32
An http client (like .NET's) using folly and proxygen
#include "curl_client.hpp"
#include <folly/FileUtil.h>
#include <folly/String.h>
#include <proxygen/lib/http/HTTPCommonHeaders.h>
#include <proxygen/lib/http/HTTPMessage.h>
#include <proxygen/lib/http/session/HTTPUpstreamSession.h>
#include <proxygen/lib/ssl/SSLContextConfig.h>
using namespace folly;
@QiMata
QiMata / ValueConverterGroup.cs
Last active February 25, 2018 02:34
Reuse converters by chaining them together with a custom converter.
public class ValueConverterGroup : List<IValueConverter>, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return this.Aggregate(value, (current, converter) => converter.Convert(current, targetType, parameter, culture));
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
@QiMata
QiMata / BooleanToObjectConverter.cs
Created May 16, 2016 15:26
A list of useful converters for Xamarin Forms
public class BooleanToObjectConverter : BindableObject, IValueConverter
{
public static readonly BindableProperty TrueObjectProperty = BindableProperty.Create<BooleanToObjectConverter, Object>(x => x.TrueObject, null);
public static readonly BindableProperty FalseObjectProperty = BindableProperty.Create<BooleanToObjectConverter, Object>(x => x.FalseObject, null);
public object FalseObject
{
get { return GetValue(FalseObjectProperty); }
set { SetValue(FalseObjectProperty, value); }
}
[assembly:ExportRenderer(typeof(CustomNavigationPage),typeof(CustomNavigationPageRenderer))]
namespace Common.Controls.iOS
{
public class CustomNavigationPageRenderer : NavigationRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
@QiMata
QiMata / BaseContentPage.xaml
Last active July 20, 2019 12:25
A common base page for using IsBusy property to show a busy indicator.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="LoadingPage"
x:Name="ContentPage">
<ContentPage.Content>
<AbsoluteLayout>
<ContentView Content="{Binding Source={x:Reference ContentPage},Path=MainContent}"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">