Xamarin cross-platform ported controls
All credit goes to: https://github.com/Ramotion/
- Create new
TagListView
var tagsView = new TagListView(true)
{
PaddingY = 4f,
TextFont = UIFont.SystemFontOfSize(20f)
};
- Setup control properties
//Samples
tagsView.Alignment = TagsAlignment.Left;
tagsView.CornerRadius = 17f;
tagsView.PaddingX = 5f;
tagsView.PaddingX = 8f;
tagsView.ControlsDistance = 4f;
tagsView.TagBackgroundColor = UIColor.FromRGB(52, 152, 219);
- Add new tag
private void BtnAdd_TouchUpInside(object sender, EventArgs e)
{
if(!string.IsNullOrEmpty(this.input.Text))
{
tagsView.AddTag(this.input.Text);
this.input.Text = string.Empty;
}
}
- Subscribe event listeners
tagsView.TagButtonTapped += (sender, e) =>
{
tagsView.RemoveTag(e);
};
tagsView.TagSelected += (sender, e) =>
{
//Do something...
};
- Create TagView in XML layout file
<XamControls.Droid.Controls.TagView
android:id="@+id/tagView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"/>
var tagView = FindViewById<TagView>(Resource.Id.tagView);
- Add tags
var tag = new Controls.Tag("This is tag name");
tag.IsDeletable = true; //Show "x" button
tagView.AddTag(tag);
- Setup TagView Listener
tagView.SetOnTagClickListener(new MyOnTagClickListener());
tagView.SetOnTagDeleteListener(new MyOnTagDeleteListener());
tagView.SetOnTagLongClickListener(new MySetOnTagLongClickListenery());
- Configure Firebase in AppDelegate
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
//...
Firebase.Core.App.Configure();
return true;
}
- Initial events
private void RegisterFirebaseEvents()
{
//Ask for permission
RemoteNotification.Instance.RegisterForReceivingRemoteNotifications(isGranted =>
{
//if (isGranted) SaveSetting...
});
//Handle token
FirebaseTokenHandler.Instance.OnRefreshToken = (token) => {
//Register token to server..
};
//Connect
FirebaseTokenHandler.Instance.ConnectToFCM();
}
- Handle recieve remote notificaation
[Export("messaging:didReceiveMessage:")]
public void DidReceiveMessage(Firebase.CloudMessaging.Messaging messaging, Firebase.CloudMessaging.RemoteMessage remoteMessage)
{
//Handle receiving Remote notification
RemoteNotification.Instance.DidReceiveRemoteNotification(messaging, remoteMessage);
}