Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-13317] Ability to add templates to any ViewProxy #4065

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions iphone/Classes/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -2890,6 +2890,33 @@ - (void)setAccessibilityHidden:(id)accessibilityHidden

#pragma mark - View Templates

-(void)addFromTemplate:(id)args
{
ENSURE_SINGLE_ARG(args, NSDictionary);

id<TiEvaluator> context = self.executionContext;
if (context == nil) {
context = self.pageContext;
}
TiViewProxy *templateView = [[self class] unarchiveFromTemplate:args inContext:context];
[self add:templateView];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs [templateView forgetSelf]; see comment to unarchiveFromTemplate


-(id)getViewFromBindId:(id)args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viewWithBindId or getViewByBindId would be better naming

{
ENSURE_SINGLE_ARG(args, NSString);
TiViewProxy *returnedViewProxy = nil;
for(TiViewProxy *subview in [self children])
{
id bindId = [subview valueForKey:@"bindId"];
if (bindId != nil && [bindId isEqual:args]) {
return subview;
}
returnedViewProxy = [subview getViewFromBindId:args];
}
return returnedViewProxy;
}

- (void)unarchiveFromTemplate:(id)viewTemplate_
{
TiViewTemplate *viewTemplate = [TiViewTemplate templateFromViewTemplate:viewTemplate_];
Expand Down