iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hello Crosslight Support,
is it possible to create or do you already have any code for custom library projects.
I will explain what I mean with this:
When creating a couple of apps, there are pieces of code, views, resources and more stuff which one could reuse in every project. Xamarin offers a project template for "library projects". So it would be great if one could create a library project for Android and one for iOS and reuse these parts in every project created with Crosslight.
I tried this approach for Android. I created a Crosslight project with the project wizzard and added a library project to the solution. I added the Intersoft.Crosslight and Intersoft.Crosslight.Android references to the new library project and a reference to the Core project. Everything like in the "regular" Android project. I also referenced the custom Android project in the Crosslight Android project. I moved some activities and some resources to the newly created library project and tried to build the solution. I encountered some problems and could not achieve what I had in mind.
Is it possible to make such an approach in combination with Crosslight?
Does Crosslight recognize the activities belonging to a certain ViewModel when the activities are in a custom library?
How can I include the custom resources to the existing "Resource" class? The "Resource" class is partial and somehow you managed to include the resources from the Intersoft.Crosslight.Android assembly to the resources of the Android project created by Crosslight.
There may be other problems and other iOS specific problems, but I think you solved them all.
I hope I was able to describe my problem and I hope Crosslight will let me build custom library "extensions". If not maybe you take it as a feature request for an upcoming release.
Thanks,
Thomas
...is it possible to create or do you already have any code for custom library projects?
Yes, it is possible to create custom library project. I will start this by creating a simple project by using Crosslight Blank project template. Next, I added an Android Library Project, called as MyAndroidCustomLibrary, to the solution.
Within MyAndroidCustomLibrary, a layout - MyCustomLayout.axml - is added. It is a very simple layout with text. Following references are added into MyAndroidCustomLibrary project:
An Activity called CustomActivity is added. Following snippet code shows the declaration of the CustomActivity class.
[Activity(Label = "CustomActivity")] [ImportBinding(typeof(CustomBindingProvider))] public class CustomActivity : Activity<CustomViewModel> { public CustomActivity() :base(Resource.Layout.MyCustomLayout){ } }
In the Android project of the solution, a reference from MyAndroidCustomLibrary project is added. Add following code into the InitializeService method of AppInitializer class in the Android project in order to be able to consume the CustomActivity.
public void InitializeServices(IApplicationHost appHost) { IApplicationService applicationService = ServiceProvider.GetService<IApplicationService>(); if (applicationService != null) { applicationService.GetContext().AddExportedType(typeof(CustomActivity)); } }
CustomViewModel is added. What will this ViewModel do is quite simple, to assign Text property with a string: "From Custom Activity" in the contructor.
private string _text; public string Text { get { return _text; } set { if (_text != value) { _text = value; this.OnPropertyChanged("Text"); } } } public CustomViewModel() { this.Text = "From Custom Activity"; }
I also add CustomBindingProvider like the following snippet code.
public CustomBindingProvider() { this.AddBinding("TestText", BindableProperties.TextProperty, "Text"); }
Last, I modify the ShowToast command so that when user press Button1 it will navigate to CustomViewModel
Please find CrosslightCustomLibrary.zip file in the attachment for more detail information.
When trying on my own, I missed the "InitializeServices" step.
Is it possible to use the "Resource.Layout.MyCustomLayout" layout in the Android project created by Crosslight? Which means, can I create resources in the custom library and use them in the Crosslight project?
Does the scenario still work when I have a custom core, too?
Open the targeted activity and override ContentLayoutId. Following snippet code shows how to do this in the sample CrosslightCustomLibrary.
protected override int ContentLayoutId { get { return MyAndroidCustomLibrary.Resource.Layout.MyCustomLayout; } }
This should help.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname