Community

Topic: Xamarin component

trying to create support for Camarin Forms (SOLVED)

Dino Novak
Saturday, May 5, 2018

Hi all,
I am trying to convert the sample for iOS to support Xamarin Forms.
So far I have created a forms sample that is displaying the view but view is turning up black, looking around I found that this would happen in native iOS app when license is not recognised and geo points are not added. Would appreciate if someone from pikkart team could give it a look.
Whole sample is uploaded to https://gitlab.com/dn-misc/pikkartXamarinFormsDemo
Thanx,
D

user profile image
Support Team  (expert)
Wednesday, May 9, 2018

Hi,
could you please put the gitlab project visibility to public?

Kind Regards

user profile image
Support Team  (expert)
Monday, May 14, 2018

Hi,
we checked the gitlab project and we found some bugs on native view hierarchy. Could you update the files AppDelegate.cs and PikkartPageRenderer.cs as follow

AppDelegate.cs:


....
use window property
public override UIWindow Window
{
get;
set;
}
....

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
// Add window
Window = new UIWindow(UIScreen.MainScreen.Bounds);

return base.FinishedLaunching(app, options);
}

PikkartPageRenderer.cs:
public class PikkartPageRenderer : PageRenderer
{
PKViewController geoMain;

protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);

if (e.OldElement != null || Element == null)
{
return;
}

try
{
var page = e.NewElement as PKPage;
var view = NativeView;

var hostViewController = ViewController;

string kGMapManagerGoogleMapsAPIKey = "AIzaSyA7uiTxeRFbbYaK-Y1j6xmXZtcI8ayOb6Y";
PKTGeoMainController.SetGoogleMapsKey(kGMapManagerGoogleMapsAPIKey);

geoMain = new PKViewController(new GeoViewMarkerAdapter(new CGSize(30, 45)),
new MapViewMarkerAdapter(new CGSize(40, 40)));

geoMain.View.Frame = UIScreen.MainScreen.Bounds;
//hostViewController.AddChildViewController(geoMain);
//hostViewController.View.Add(geoMain.View);
//geoMain.DidMoveToParentViewController(hostViewController);

hostViewController.AddChildViewController(geoMain);
hostViewController.View.AddSubview(geoMain.View);
hostViewController.View.BringSubviewToFront(geoMain.View);
geoMain.View.TranslatesAutoresizingMaskIntoConstraints=false;
geoMain.View.TopAnchor.ConstraintEqualTo(hostViewController.View.TopAnchor).Active=true;
geoMain.View.BottomAnchor.ConstraintEqualTo(hostViewController.View.BottomAnchor).Active=true;
geoMain.View.LeadingAnchor.ConstraintEqualTo(hostViewController.View.LeadingAnchor).Active=true;
geoMain.View.TrailingAnchor.ConstraintEqualTo(hostViewController.View.TrailingAnchor).Active=true;
geoMain.DidMoveToParentViewController(hostViewController);

//var viewController = new UIViewController();
//var label = new UILabel (new RectangleF(0, 40, 320, 40));
//label.Text = "Test text ";
//label.TextColor = UIKit.UIColor.Red;
//viewController.View.Add(label);
//viewController.View.Frame = UIScreen.MainScreen.Bounds;
//viewController.View.BackgroundColor = UIColor.White;
//viewController.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;


//hostViewController.View.Add(viewController.View);
//viewController.DidMoveToParentViewController(hostViewController);

}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"\t\t\tERROR: {ex.Message}");
}
}


Kind Regards

Dino Novak
Tuesday, May 22, 2018

Thank you very much, sample is now working, I will now try to move part of the logic to forms part.

I am now trying to do the same with android part.
I have created a separate activity, but when trying the build I am encountering

Done building project "pikkartXamarinFormsDemo.Droid.csproj" -- FAILED.

Build FAILED.

obj/Debug/android/src/mono/com/pikkart/ar/geo/IArGeoListenerImplementor.java(4,8): error : error: IArGeoListenerImplementor is not abstract and does not override abstract method onGeoBringInterfaceOnTop() in IArGeoListener
obj/Debug/android/src/mono/com/pikkart/ar/geo/IArGeoListenerImplementor.java(4,8): error : public class IArGeoListenerImplementor
obj/Debug/android/src/mono/com/pikkart/ar/geo/IArGeoListenerImplementor.java(4,8): error :
0 Warning(s)
1 Error(s)

is this issue with SDK version or something else is the problem?

Sample containg bot iOS and Android is available on
https://gitlab.com/dn-misc/pikkartXamarinFormsDemo

Thanx,
DiNo

user profile image
Support Team  (expert)
Wednesday, May 23, 2018

Hi,

the onGeoBringInterfaceOnTop() method was added in version 3.5 of the SDK and it is used to inform the app that the GeoFragment has moved its Views on top of the current viewport.
From your solution it looks like you are using version 3.1.1 where that method is not included.
From the logs the problem seems to be in the compilation directories, if you have done a downgrade of the SDK it is possible that there are references in the compilation files, you can delete the bin and obj folders and recompile or upgrade to version 3.5 of the SDK using this tutorial

Best regards,

Sign in to add a comment