| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9717bbf commit 0197ee1
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 1 | + <Page xmlns="http://schemas.nativescript.org/tns.xsd"> | ||
| 2 | + <StackLayout> | ||
| 3 | + <GridLayout height="60" rows="auto" columns="auto, *"> | ||
| 4 | + <SearchBar backgroundColor="red" id="searchBar1" hint="Search" text="auto(sb), * col, no width" /> | ||
| 5 | + </GridLayout> | ||
| 6 | + <GridLayout height="60" rows="auto" columns="auto, *"> | ||
| 7 | + <SearchBar backgroundColor="green" id="searchBar2" width="100%" hint="Search" text="auto(sb), * col, width 100%" /> | ||
| 8 | + </GridLayout> | ||
| 9 | + <GridLayout height="60" rows="auto" columns="auto, *"> | ||
| 10 | + <SearchBar backgroundColor="blue" id="searchBar3" width="300" hint="Search" text="auto(sb), * col, width 300dip" /> | ||
| 11 | + </GridLayout> | ||
| 12 | + <GridLayout height="60" rows="auto" columns="*, auto"> | ||
| 13 | + <SearchBar col="1" backgroundColor="blue" id="searchBar4" width="300" hint="Search" text="*, auto(sb) col, width 300dip" /> | ||
| 14 | + </GridLayout> | ||
| 15 | + <GridLayout height="60" rows="auto" columns="auto, 200"> | ||
| 16 | + <SearchBar backgroundColor="cyan" id="searchBar5" hint="Search" text="auto(sb), 200 cols, no width" /> | ||
| 17 | + </GridLayout> | ||
| 18 | + <GridLayout height="60" rows="auto" columns="200, auto"> | ||
| 19 | + <SearchBar backgroundColor="magenta" col="1" id="searchBar6" hint="Search" text="200, auto(sb) cols, no width" /> | ||
| 20 | + </GridLayout> | ||
| 21 | + <StackLayout height="60"> | ||
| 22 | + <SearchBar backgroundColor="yellow" id="searchBar7" hint="Search" text="stack, no width" /> | ||
| 23 | + </StackLayout> | ||
| 24 | + <StackLayout height="60"> | ||
| 25 | + <SearchBar backgroundColor="yellow" id="searchBar8" width="300" hint="Search" text="stack, width 300dip" /> | ||
| 26 | + </StackLayout> | ||
| 27 | + </StackLayout> | ||
| 28 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,10 @@ export function pageLoaded(args: EventData) { | |||
| 11 | 11 | ||
| 12 | 12 | export function loadExamples() { | |
| 13 | 13 | const examples = new Map<string, string>(); | |
| 14 | - examples.set("issue-4147", "search-bar/issue-4147"); | ||
| 15 | - examples.set("search-bar", "search-bar/search-bar"); | ||
| 16 | - examples.set("issue-5039","search-bar/issue-5039"); | ||
| 14 | + examples.set("issue-4147", "search-bar/issue-4147"); | ||
| 15 | + examples.set("search-bar", "search-bar/search-bar"); | ||
| 16 | + examples.set("issue-5039", "search-bar/issue-5039"); | ||
| 17 | + examples.set("issue-5655", "search-bar/issue-5655"); | ||
| 18 | + | ||
| 17 | 19 | return examples; | |
| 18 | 20 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,9 +3,12 @@ import { | |||
| 3 | 3 | SearchBarBase, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, fontInternalProperty, | |
| 4 | 4 | textProperty, hintProperty, textFieldHintColorProperty, textFieldBackgroundColorProperty | |
| 5 | 5 | } from "./search-bar-common"; | |
| 6 | + import { ios as iosUtils } from "../../utils/utils"; | ||
| 6 | 7 | ||
| 7 | 8 | export * from "./search-bar-common"; | |
| 8 | 9 | ||
| 10 | + const majorVersion = iosUtils.MajorVersion; | ||
| 11 | + | ||
| 9 | 12 | class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate { | |
| 10 | 13 | public static ObjCProtocols = [UISearchBarDelegate]; | |
| 11 | 14 | ||
@@ -52,6 +55,20 @@ class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate { | |||
| 52 | 55 | } | |
| 53 | 56 | } | |
| 54 | 57 | ||
| 58 | + class UISearchBarImpl extends UISearchBar { | ||
| 59 | + sizeThatFits(size: CGSize): CGSize { | ||
| 60 | + // iOS11 SDK does not support passing sizeThatFits(...) non-finite width value; | ||
| 61 | + // iOS layout system will take care to size the element properly when passed 0 | ||
| 62 | + if (majorVersion >= 11) { | ||
| 63 | + if (!!size.width) { | ||
| 64 | + size.width = 0; | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + return super.sizeThatFits(size); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 55 | 72 | export class SearchBar extends SearchBarBase { | |
| 56 | 73 | private _ios: UISearchBar; | |
| 57 | 74 | private _delegate; | |
@@ -61,7 +78,7 @@ export class SearchBar extends SearchBarBase { | |||
| 61 | 78 | constructor() { | |
| 62 | 79 | super(); | |
| 63 | 80 | ||
| 64 | - this.nativeViewProtected = this._ios = UISearchBar.new(); | ||
| 81 | + this.nativeViewProtected = this._ios = UISearchBarImpl.new(); | ||
| 65 | 82 | this._delegate = UISearchBarDelegateImpl.initWithOwner(new WeakRef(this)); | |
| 66 | 83 | } | |
| 67 | 84 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments