Skip to content

Instantly share code, notes, and snippets.

@NVentimiglia
Last active April 6, 2016 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NVentimiglia/6a7fa8597f61b6b142fe53b78b665906 to your computer and use it in GitHub Desktop.
Save NVentimiglia/6a7fa8597f61b6b142fe53b78b665906 to your computer and use it in GitHub Desktop.
Tok.Xamarin Custom Render
<ContentPage.Content>
<Grid x:Name="MainGrid" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Grid x:Name="videoContainer" />
<!-- Video controll added into the video container. Bunch of Forms buttons and stuf below...-->
<?xml version="1.0" encoding="UTF-8"?>
<View
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Tok.OpenTokView">
</View>
[assembly: Xamarin.Forms.ExportRenderer(typeof(Tok.OpenTokView), typeof(Tok.iOS.OpenTokViewRenderer))]
namespace Tok.iOS
{
public class OpenTokViewRenderer : Xamarin.Forms.Platform.iOS.ViewRenderer, IOpenTok
{
SessionDelegate _sessionDelegate;
PublisherDelegate _publisherDelegate;
SubscriberDelegate _subscriberDelegate;
OTSession _session;
OTPublisher _publisher;
OTSubscriber _subscriber;
protected OpenTokView _openTokView;
protected override void OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs<Xamarin.Forms.View> e)
{
base.OnElementChanged(e);
if (e.NewElement == null)
return;
_openTokView = e.NewElement as OpenTokView;
var width = (float)UIScreen.MainScreen.Bounds.Size.Width;
var height = (float)UIScreen.MainScreen.Bounds.Size.Height - 20;
var view = new UIView(new RectangleF(0, 0, width, height));
this.SetNativeControl(view);
config = _openTokView.Init(this);
_role = config.Role;
DoConnect();
}
void NavigateToDash()
{
Device.BeginInvokeOnMainThread(() =>
{
try
{
App.Logger.WriteLine("Call NavigateToDash");
myMaster.Instance.PopToRoot();
}
catch (Exception ex)
{
App.LogIt("agChat:Failed to navigate - " + ex.Message);
}
});
}
public async void PopToRoot()
{
IsDashboard = true;
IsPresented = false;
try
{
//Navigation View. =(
await Nav.PopToRootAsync(false);
}
catch (Exception ex)
{
Nav.PopAsync(false);
App.LogIt("ERROR: PopToRoot()", ex.Message);
}
PaintBar();
}
@NVentimiglia
Copy link
Author

Parent Page is where we call navigate.Pop(). Works in most other cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment