Move styleScope from Page to View

Fix image-source test for API 27
setupAsRootView now makes the component styleScope
set css, addCss & addCssFile makes view to be styleScopeHost which cannot be overriden later from parent
Android modals now call setupAsRootView
Small fixes on ios layouts
launch event fired in andriod too
Moved some requestLayout calls to ios files where they belongs
This commit is contained in:
Hristo Hristov
2017-12-19 16:35:15 +02:00
parent 63ab46eb2a
commit 058a216ac9
19 changed files with 185 additions and 268 deletions

View File

@@ -90,7 +90,7 @@ const fullIosPng = "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAAXNSR0IArs4c
const fullJpegImage = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAAEAAQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+Pz/h5j+1Z/z9fBr/AMRt+AH/AM7uiiiv9fV9E36KOn/HMX0f+n/NlvDT/p3/ANUv/V3vrf8AP1nueaf8LOa9P+ZjjP8Ap3/0/wD6u99b/wD/2Q==";
const expectedJpegStart = "/9j/4AAQSkZJRgAB";
const expectedPngStart = "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAA";
const expectedPngStart = "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAA";
export function testBase64Encode_PNG() {
const img = imageSource.fromFile(smallImagePath);

View File

@@ -78,6 +78,22 @@ function getNativeHeight(view: View): number {
return layout.toDevicePixels(bounds.size.height);
}
export function test_correct_layout_top_bottom_edges_does_not_span_not_scrollable_not_flat() {
test_correct_layout_top_bottom_edges_does_not_span_options(false, false);
}
export function test_correct_layout_top_bottom_edges_does_not_span_scrollable_not_flat() {
test_correct_layout_top_bottom_edges_does_not_span_options(true, false);
}
export function test_correct_layout_top_bottom_edges_does_not_span_not_scrollable_flat() {
test_correct_layout_top_bottom_edges_does_not_span_options(false, true);
}
export function test_correct_layout_top_bottom_edges_does_not_span_scrollable_flat() {
test_correct_layout_top_bottom_edges_does_not_span_options(true, true);
}
export function test_correct_layout_scrollable_content_false() {
const page = new Page();
topmost().viewController.navigationBar.translucent = true;
@@ -251,6 +267,8 @@ export function test_correct_layout_scrollable_content_true_top_edge_does_not_sp
const tabItem = new TabViewItem();
tabItem.title = "Item";
const lbl = new Label();
lbl.viewController = iosView.UILayoutViewController.initWithOwner(new WeakRef(lbl));
lbl.viewController.edgesForExtendedLayout = UIRectEdge.Bottom | UIRectEdge.Left | UIRectEdge.Right;
(<any>lbl).scrollableContent = true;
tabItem.view = lbl;
tabView.items = [tabItem];
@@ -284,6 +302,8 @@ export function test_correct_layout_scrollable_content_true_bottom_edge_does_not
const tabItem = new TabViewItem();
tabItem.title = "Item";
const lbl = new Label();
lbl.viewController = iosView.UILayoutViewController.initWithOwner(new WeakRef(lbl));
lbl.viewController.edgesForExtendedLayout = UIRectEdge.Top | UIRectEdge.Left | UIRectEdge.Right;
(<any>lbl).scrollableContent = true;
tabItem.view = lbl;
tabView.items = [tabItem];
@@ -292,11 +312,7 @@ export function test_correct_layout_scrollable_content_true_bottom_edge_does_not
helper.navigate(() => page);
TKUnit.assertTrue(page.isLoaded, "page NOT loaded!");
TKUnit.assertNotNull(lbl.viewController);
(<UIViewController>lbl.viewController).edgesForExtendedLayout = UIRectEdge.Top | UIRectEdge.Left | UIRectEdge.Right;
lbl.requestLayout();
(<UIView>lbl.nativeViewProtected).setNeedsLayout();
(<UIView>lbl.nativeViewProtected).layoutIfNeeded();
TKUnit.waitUntilReady(() => lbl.isLayoutValid);
const tabBarHeight = uiUtils.ios.getActualHeight(tabView.viewController.tabBar);
const screenHeight = layout.toDevicePixels(UIScreen.mainScreen.bounds.size.height);
@@ -307,58 +323,35 @@ export function test_correct_layout_scrollable_content_true_bottom_edge_does_not
TKUnit.assertEqual(contentHeight, screenHeight - tabBarHeight, "lbl.height !== screenHeight - tabBarHeight");
}
export function test_correct_layout_top_bottom_edges_does_not_span() {
function test_correct_layout_top_bottom_edges_does_not_span_options(scrollable: boolean, flat: boolean) {
const page = new Page();
page.actionBar.flat = false;
(<any>page).scrollableContent = false;
page.actionBar.title = "ActionBar";
(<UIViewController>page.viewController).edgesForExtendedLayout = UIRectEdge.Left | UIRectEdge.Right;
const tabView = new TabView();
(<UIViewController>tabView.viewController).edgesForExtendedLayout = UIRectEdge.Left | UIRectEdge.Right;
const tabItem = new TabViewItem();
tabItem.title = "Item";
const lbl = new Label();
lbl.viewController = iosView.UILayoutViewController.initWithOwner(new WeakRef(lbl));
lbl.viewController.edgesForExtendedLayout = UIRectEdge.Left | UIRectEdge.Right;
tabItem.view = lbl;
tabView.items = [tabItem];
page.content = tabView;
page.actionBar.flat = flat;
(<any>page).scrollableContent = scrollable;
(<any>lbl).scrollableContent = scrollable;
helper.navigate(() => page);
TKUnit.assertTrue(page.isLoaded, "page NOT loaded!");
(<UIViewController>lbl.viewController).edgesForExtendedLayout = UIRectEdge.Left | UIRectEdge.Right;
lbl.requestLayout();
(<UIView>lbl.nativeViewProtected).setNeedsLayout();
(<UIView>lbl.nativeViewProtected).layoutIfNeeded();
TKUnit.waitUntilReady(() => lbl.isLayoutValid);
const statusBarHeight = uiUtils.ios.getStatusBarHeight(page.viewController);
const tabBarHeight = uiUtils.ios.getActualHeight(tabView.viewController.tabBar);
const screenHeight = layout.toDevicePixels(UIScreen.mainScreen.bounds.size.height);
const navBarHeight = uiUtils.ios.getActualHeight(page.frame.ios.controller.navigationBar);
const assert = (scrollable: boolean, flat: boolean) => {
page.actionBar.flat = flat;
(<any>page).scrollableContent = scrollable;
(<any>lbl).scrollableContent = scrollable;
lbl.requestLayout();
TKUnit.waitUntilReady(() => lbl.isLayoutValid);
const pageHeight = getHeight(page);
TKUnit.assertEqual(pageHeight, screenHeight - statusBarHeight - navBarHeight, "page.height !== screenHeight - statusBarHeight - navBarHeight");
const contentHeight = getHeight(lbl);
TKUnit.assertEqual(contentHeight, screenHeight - statusBarHeight - navBarHeight - tabBarHeight, "lbl.height !== screenHeight - statusBarHeight - navBarHeight - tabBarHeight");
};
// scrollable: false, flat: false;
assert(false, false);
// scrollable: true, flat: false;
assert(true, false);
// scrollable: true, flat: true;
assert(true, true);
// scrollable: false, flat: true;
assert(false, true);
const contentHeight = getHeight(lbl);
TKUnit.assertEqual(contentHeight, screenHeight - statusBarHeight - navBarHeight - tabBarHeight, "lbl.height !== screenHeight - statusBarHeight - navBarHeight - tabBarHeight");
}
export function test_showing_native_viewcontroller_doesnt_throw_exception() {