Skip to content

Instantly share code, notes, and snippets.

View hamid-shaikh's full-sized avatar
😅
I may be slow to respond.

Hamid Shaikh hamid-shaikh

😅
I may be slow to respond.
  • Cognizant Technology Solutions
  • Mumbai, India
View GitHub Profile
@hamid-shaikh
hamid-shaikh / AppLabel.cs
Created January 17, 2019 08:34
Xamarin.Forms Android Label Text Alignment Issue when Arabic Language is displayed
public class AppLabel : Label
{
}
@hamid-shaikh
hamid-shaikh / AppLabelRenderer.cs
Last active January 17, 2019 08:39
Label Text Alignment when Arabic text is displayed - Android
[assembly: ExportRenderer(typeof(AppLabel), typeof(AppLabelRenderer))]
namespace MyProject.Droid.Renderers
{
public class AppLabelRenderer : LabelRenderer
{
readonly Context GetContext;
public AppLabelRenderer(Context context) : base(context)
{
GetContext = context;
}
@hamid-shaikh
hamid-shaikh / AppAttachProperties.cs
Last active July 2, 2019 06:07
Xamarin.Forms Attach Properties (TapCommand, TapCommandParameter, AnimateView, AnimateOnTap) - Easily attach any of these properties to Xamarin.Forms controls
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
//TapCommandProperty
public static class AppAttachProperties
{
public static readonly BindableProperty TapCommandProperty =
BindableProperty.CreateAttached(
"TapCommand",
@hamid-shaikh
hamid-shaikh / TestPage.xaml
Created June 18, 2019 06:25
AppAttachProperties usage example
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:appHelpers="clr-namespace:ProjectName.Mobile.Helpers"
x:Class="ProjectName.Mobile.Views.TestPage">
<!--ContentPage Content-->
<Grid
BackgroundColor="{StaticResource whiteColor}"
RowSpacing="0"
ColumnSpacing="0">
@hamid-shaikh
hamid-shaikh / TapToCommandBehavior.cs
Last active June 24, 2019 11:03
Xamarin.Forms Attach TapToCommandBehavior to any control and make it Tappable with Animation
using System;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
public class TapToCommandBehavior : Behavior
{
private readonly TapGestureRecognizer tapGestureRecognizer;
private View AttachedToView;
@hamid-shaikh
hamid-shaikh / TapToCommandBehaviorTestPage.xaml
Last active June 24, 2019 11:03
TapToCommandBehavior usage example
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:appBehaviors="clr-namespace:ProjectName.Mobile.Behaviors"
x:Class="ProjectName.Mobile.Views.TestPage">
<!--ContentPage Content-->
<Grid
BackgroundColor="{StaticResource whiteColor}"
RowSpacing="0"
ColumnSpacing="0">
@hamid-shaikh
hamid-shaikh / IApiService.cs
Created July 14, 2019 08:27
Refit + Prism Forms + Fusillade
public interface IApiService<TInterfaceService>
{
// Use to fetch data into a cache when a page loads. Expect that
// these requests will only get so far then give up and start failing
TInterfaceService Speculative { get; }
// Use for network requests that are fetching data that the user is
// waiting on *right now*
TInterfaceService UserInitiated { get; }
@hamid-shaikh
hamid-shaikh / ApiService.cs
Created July 14, 2019 08:35
Refit + Prism Forms + Fusillade + ModernHttpClient
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Fusillade;
using ModernHttpClient;
using Newtonsoft.Json;
using Refit;
/// <summary>
@hamid-shaikh
hamid-shaikh / IAuthenticationService.cs
Created July 14, 2019 08:43
Refit + Prism Forms + Fusillade + ModernHttpClient
using System.Threading.Tasks;
using Refit;
public interface IAuthenticationService
{
[Get("/auth/basiclogin")]
Task<TResult> AuthenticateUserAsync<TResult>([Header("Authorization")] string authorization);
[Get("/auth/logout")]
Task<TResult> LogoutUserAsync<TResult>();
@hamid-shaikh
hamid-shaikh / App.xaml.cs
Created July 14, 2019 08:45
Refit + Prism Forms + Fusillade + ModernHttpClient (Dependency Registeration)
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterSingleton<IApiService<IAuthenticationService>, ApiService<IAuthenticationService>>();
containerRegistry.RegisterForNavigation<NavigationPage>();
containerRegistry.RegisterForNavigation<LoginPage, LoginPageViewModel>();
}