mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Merge pull request #573 from NativeScript/search-bar-font
Search bar font
This commit is contained in:
@ -646,16 +646,16 @@ function loadViewWithItemNumber(args: listViewModule.ItemEventData) {
|
||||
(<labelModule.Label>args.view).text = "item " + args.index;
|
||||
}
|
||||
|
||||
function getTextFromNativeElementAt(listView: listViewModule.ListView, index: number): any {
|
||||
function getTextFromNativeElementAt(listView: listViewModule.ListView, index: number): string {
|
||||
if (listView.android) {
|
||||
var nativeElement = listView.android.getChildAt(index);
|
||||
if (nativeElement instanceof android.view.ViewGroup) {
|
||||
return (<android.widget.TextView>((<any>nativeElement).getChildAt(0))).getText();
|
||||
return (<android.widget.TextView>((<any>nativeElement).getChildAt(0))).getText() + "";
|
||||
}
|
||||
return (<android.widget.TextView>nativeElement).getText();
|
||||
return (<android.widget.TextView>nativeElement).getText() + "";
|
||||
}
|
||||
else if (listView.ios) {
|
||||
return listView.ios.visibleCells()[index].contentView.subviews[0].text;
|
||||
return listView.ios.visibleCells()[index].contentView.subviews[0].text + "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import colorModule = require("color");
|
||||
import searchBarModule = require("ui/search-bar");
|
||||
import utils = require("utils/utils");
|
||||
|
||||
function getTextView(bar: android.widget.SearchView): android.widget.TextView {
|
||||
if (bar) {
|
||||
@ -20,3 +21,12 @@ export function getNativeHintColor(searchBar: searchBarModule.SearchBar): colorM
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getNativeFontSize(searchBar: searchBarModule.SearchBar): number {
|
||||
var textView = getTextView(searchBar.android);
|
||||
|
||||
if (textView) {
|
||||
return textView.getTextSize() / utils.layout.getDisplayDensity();
|
||||
}
|
||||
return undefined;
|
||||
}
|
@ -3,3 +3,4 @@ import searchBarModule = require("ui/search-bar");
|
||||
import colorModule = require("color");
|
||||
|
||||
export declare function getNativeHintColor(textView: searchBarModule.SearchBar): colorModule.Color;
|
||||
export declare function getNativeFontSize(searchBar: searchBarModule.SearchBar): number;
|
@ -5,3 +5,12 @@ export function getNativeHintColor(searchBar: searchBarModule.SearchBar): colorM
|
||||
// TODO: This test needs to be created
|
||||
return undefined;
|
||||
}
|
||||
export function getNativeFontSize(searchBar: searchBarModule.SearchBar): number {
|
||||
var sf = <UITextField>(<any>searchBar)._textField;
|
||||
if (sf) {
|
||||
return sf.font.pointSize;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,22 @@ export var testSearchBarHintColorAndroid = function () {
|
||||
});
|
||||
};
|
||||
|
||||
export var testSearchBarFontSize = function () {
|
||||
helper.buildUIAndRunTest(_createSearchBarFunc(), function (views: Array<viewModule.View>) {
|
||||
var searchBar = <searchBarModule.SearchBar>views[0];
|
||||
|
||||
searchBar.text = "";
|
||||
searchBar.hint = "hint font-size test";
|
||||
|
||||
var expectedValue = 30;
|
||||
var actualValue;
|
||||
|
||||
searchBar.style.fontSize = expectedValue;
|
||||
actualValue = searchBarTestsNative.getNativeFontSize(searchBar);
|
||||
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
|
||||
});
|
||||
};
|
||||
|
||||
export function test_DummyTestForSnippetOnly() {
|
||||
// <snippet module="ui/search-bar" title="search-bar">
|
||||
// ### Searching
|
||||
|
Reference in New Issue
Block a user