Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Tizen] Adds Opt-in Init #7209

Merged
merged 1 commit into from
Aug 22, 2019
Merged

Conversation

rookiejava
Copy link
Collaborator

Description of Change

This PR introduces a new Forms.Init() that allows you to customize initialization options. (in the same way as android backend - #6087, #6149)

Issues Resolved

None

API Changes

Added:

  • void Forms.Init(InitializationOptions options)

Platforms Affected

  • Tizen

Behavioral/Visual Changes

This change does not affect the behavior of existing Forms.Init. It's just an addition to the new Forms.Init() having InitializationOption to enable partial init. For example, using this, you can register a certain type of renderers at initialization time.

How to register all default renderers provided by Tizen backend.

// Creates the handler attributes
var assembly = Assembly.GetAssembly(typeof(Forms));
object[] attributes = assembly.GetCustomAttributes(typeof(HandlerAttribute), true);
var handlerAttributes = new HandlerAttribute[attributes.Length];
Array.Copy(attributes, handlerAttributes, attributes.Length);

// Creates the InitializationOptions
var option = new InitializationOptions(app, true, handlerAttributes);

// Initiailize
Forms.Init(option)

How to get handler attributes from a certain type.

//Get Assembly
var assembly = Assembly.GetAssembly(typeof(Forms));

//For renderers for each controls such as Button, Label, ...
//By default, 31 default renderers are provided by Tizen backend
object[] renderers = assembly.GetCustomAttributes(typeof(ExportRendererAttribute), true);

//For Image source handlers such as FileImageSource, StreamImageSource,...
//By default, 3 default image renderers are provided by Tizen backend
object[] imageHanders = assembly.GetCustomAttributes(typeof(ExportImageSourceHandlerAttribute), true);

//For Cell handlers such as TextCellRenderer, ImageCellRenderer,...
//By default, 5 default cell renderers are provided by Tizen backend
object[] cellRenderers = assembly.GetCustomAttributes(typeof(ExportCellAttribute), true);

//For GestureRecognizer handler such as TapGestureHandler, PinchGestureHandler,...
//By default, 3 default gesture recognizer handlers are provided by Tizen backend
object[] gestureHandlers = assembly.GetCustomAttributes(typeof(ExportHandlerAttribute), true);

Before/After Screenshots

Not applicable

PR Checklist

  • Has automated tests
  • Rebased on top of the target branch at time of PR
  • Changes adhere to coding standard

@samhouts samhouts self-requested a review August 21, 2019 00:07
@samhouts samhouts self-assigned this Aug 21, 2019
@rmarinho rmarinho merged commit f948224 into xamarin:master Aug 22, 2019
@rookiejava rookiejava deleted the init-option-tizen branch August 25, 2019 23:12
@samhouts samhouts added this to the 4.3.0 milestone Sep 11, 2019
felipebaltazar pushed a commit to felipebaltazar/Xamarin.Forms that referenced this pull request Oct 16, 2019
felipebaltazar pushed a commit to felipebaltazar/Xamarin.Forms that referenced this pull request Oct 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants