| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2168c36 commit 11f0d6e
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,5 +23,6 @@ export function loadExamples() { | |||
| 23 | 23 | examples.set("text-transform", "tab-view/text-transform"); | |
| 24 | 24 | examples.set("tab-view-bottom-position", "tab-view/tab-view-bottom-position"); | |
| 25 | 25 | examples.set("issue-5470", "tab-view/issue-5470"); | |
| 26 | + examples.set("tab-view-tab-text-font-size", "tab-view/tab-view-tab-text-font-size"); | ||
| 26 | 27 | return examples; | |
| 27 | 28 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + <Page> | ||
| 2 | + <TabView tabTextFontSize="8"> | ||
| 3 | + <TabView.items> | ||
| 4 | + <TabViewItem title="First"> | ||
| 5 | + <TabViewItem.view> | ||
| 6 | + <GridLayout> | ||
| 7 | + <Label text="First View" verticalAlignment="center" horizontalAlignment="center"/> | ||
| 8 | + </GridLayout> | ||
| 9 | + </TabViewItem.view> | ||
| 10 | + </TabViewItem> | ||
| 11 | + <TabViewItem title="Second"> | ||
| 12 | + <TabViewItem.view> | ||
| 13 | + <GridLayout> | ||
| 14 | + <Label text="Second View" verticalAlignment="center" horizontalAlignment="center"/> | ||
| 15 | + </GridLayout> | ||
| 16 | + </TabViewItem.view> | ||
| 17 | + </TabViewItem> | ||
| 18 | + </TabView.items> | ||
| 19 | + </TabView> | ||
| 20 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,6 +120,7 @@ export class Style extends Observable { | |||
| 120 | 120 | public verticalAlignment: VerticalAlignment; | |
| 121 | 121 | ||
| 122 | 122 | // TabView-specific props | |
| 123 | + public tabTextFontSize: number; | ||
| 123 | 124 | public tabTextColor: Color; | |
| 124 | 125 | public tabBackgroundColor: Color; | |
| 125 | 126 | public selectedTabTextColor: Color; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,6 +93,7 @@ export class Style extends Observable implements StyleDefinition { | |||
| 93 | 93 | public verticalAlignment: VerticalAlignment; | |
| 94 | 94 | ||
| 95 | 95 | // TabView-specific props | |
| 96 | + public tabTextFontSize: number; | ||
| 96 | 97 | public tabTextColor: Color; | |
| 97 | 98 | public tabBackgroundColor: Color; | |
| 98 | 99 | public selectedTabTextColor: Color; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -103,6 +103,13 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom | |||
| 103 | 103 | this.style.androidSelectedTabHighlightColor = value; | |
| 104 | 104 | } | |
| 105 | 105 | ||
| 106 | + get tabTextFontSize(): number { | ||
| 107 | + return this.style.tabTextFontSize; | ||
| 108 | + } | ||
| 109 | + set tabTextFontSize(value: number) { | ||
| 110 | + this.style.tabTextFontSize = value; | ||
| 111 | + } | ||
| 112 | + | ||
| 106 | 113 | get tabTextColor(): Color { | |
| 107 | 114 | return this.style.tabTextColor; | |
| 108 | 115 | } | |
@@ -240,6 +247,9 @@ androidOffscreenTabLimitProperty.register(TabViewBase); | |||
| 240 | 247 | export const androidTabsPositionProperty = new Property<TabViewBase, "top" | "bottom">({ name: "androidTabsPosition", defaultValue: "top" }); | |
| 241 | 248 | androidTabsPositionProperty.register(TabViewBase); | |
| 242 | 249 | ||
| 250 | + export const tabTextFontSizeProperty = new CssProperty<Style, number>({ name: "tabTextFontSize", cssName: "tab-text-font-size", valueConverter: (v) => parseFloat(v) }); | ||
| 251 | + tabTextFontSizeProperty.register(Style); | ||
| 252 | + | ||
| 243 | 253 | export const tabTextColorProperty = new CssProperty<Style, Color>({ name: "tabTextColor", cssName: "tab-text-color", equalityComparer: Color.equals, valueConverter: (v) => new Color(v) }); | |
| 244 | 254 | tabTextColorProperty.register(Style); | |
| 245 | 255 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ import { Font } from "../styling/font"; | |||
| 3 | 3 | ||
| 4 | 4 | import { | |
| 5 | 5 | TabViewBase, TabViewItemBase, itemsProperty, selectedIndexProperty, | |
| 6 | - tabTextColorProperty, tabBackgroundColorProperty, selectedTabTextColorProperty, | ||
| 6 | + tabTextColorProperty, tabBackgroundColorProperty, tabTextFontSizeProperty, selectedTabTextColorProperty, | ||
| 7 | 7 | androidSelectedTabHighlightColorProperty, androidOffscreenTabLimitProperty, | |
| 8 | 8 | fontSizeProperty, fontInternalProperty, View, layout, traceCategory, traceEnabled, | |
| 9 | 9 | traceWrite, Color | |
@@ -624,6 +624,17 @@ export class TabView extends TabViewBase { | |||
| 624 | 624 | } | |
| 625 | 625 | } | |
| 626 | 626 | ||
| 627 | + [tabTextFontSizeProperty.getDefault](): number { | ||
| 628 | + return this._tabLayout.getTabTextFontSize(); | ||
| 629 | + } | ||
| 630 | + [tabTextFontSizeProperty.setNative](value: number | { nativeSize: number }) { | ||
| 631 | + if (typeof value === "number") { | ||
| 632 | + this._tabLayout.setTabTextFontSize(value); | ||
| 633 | + } else { | ||
| 634 | + this._tabLayout.setTabTextFontSize(value.nativeSize); | ||
| 635 | + } | ||
| 636 | + } | ||
| 637 | + | ||
| 627 | 638 | [tabTextColorProperty.getDefault](): number { | |
| 628 | 639 | return this._tabLayout.getTabTextColor(); | |
| 629 | 640 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,6 +64,11 @@ export class TabView extends View { | |||
| 64 | 64 | */ | |
| 65 | 65 | selectedIndex: number; | |
| 66 | 66 | ||
| 67 | + /** | ||
| 68 | + * Gets or sets the font size of the tabs titles. | ||
| 69 | + */ | ||
| 70 | + tabTextFontSize: number; | ||
| 71 | + | ||
| 67 | 72 | /** | |
| 68 | 73 | * Gets or sets the text color of the tabs titles. | |
| 69 | 74 | */ | |
@@ -139,6 +144,7 @@ export class TabView extends View { | |||
| 139 | 144 | export const itemsProperty: Property<TabView, TabViewItem[]>; | |
| 140 | 145 | export const selectedIndexProperty: Property<TabView, number>; | |
| 141 | 146 | ||
| 147 | + export const tabTextFontSizeProperty: CssProperty<Style, number>; | ||
| 142 | 148 | export const tabTextColorProperty: CssProperty<Style, Color>; | |
| 143 | 149 | export const tabBackgroundColorProperty: CssProperty<Style, Color>; | |
| 144 | 150 | export const selectedTabTextColorProperty: CssProperty<Style, Color>; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ import { Font } from "../styling/font"; | |||
| 4 | 4 | import { ios as iosView, ViewBase } from "../core/view"; | |
| 5 | 5 | import { | |
| 6 | 6 | TabViewBase, TabViewItemBase, itemsProperty, selectedIndexProperty, | |
| 7 | - tabTextColorProperty, tabBackgroundColorProperty, selectedTabTextColorProperty, iosIconRenderingModeProperty, | ||
| 7 | + tabTextColorProperty, tabTextFontSizeProperty, tabBackgroundColorProperty, selectedTabTextColorProperty, iosIconRenderingModeProperty, | ||
| 8 | 8 | View, fontInternalProperty, layout, traceEnabled, traceWrite, traceCategories, Color | |
| 9 | 9 | } from "./tab-view-common" | |
| 10 | 10 | import { textTransformProperty, TextTransform, getTransformedText } from "../text-base"; | |
@@ -448,6 +448,13 @@ export class TabView extends TabViewBase { | |||
| 448 | 448 | selectedIndexProperty.coerce(this); | |
| 449 | 449 | } | |
| 450 | 450 | ||
| 451 | + [tabTextFontSizeProperty.getDefault](): number { | ||
| 452 | + return null; | ||
| 453 | + } | ||
| 454 | + [tabTextFontSizeProperty.setNative](value: number | { nativeSize: number }) { | ||
| 455 | + this._updateIOSTabBarColorsAndFonts(); | ||
| 456 | + } | ||
| 457 | + | ||
| 451 | 458 | [tabTextColorProperty.getDefault](): UIColor { | |
| 452 | 459 | return null; | |
| 453 | 460 | } | |
@@ -504,7 +511,9 @@ interface TabStates { | |||
| 504 | 511 | function getTitleAttributesForStates(tabView: TabView): TabStates { | |
| 505 | 512 | const result: TabStates = {}; | |
| 506 | 513 | ||
| 507 | - const font = tabView.style.fontInternal.getUIFont(UIFont.systemFontOfSize(10)); | ||
| 514 | + const defaultTabItemFontSize = 10; | ||
| 515 | + const tabItemFontSize = tabView.style.tabTextFontSize || defaultTabItemFontSize; | ||
| 516 | + const font: UIFont = tabView.style.fontInternal.getUIFont(UIFont.systemFontOfSize(tabItemFontSize)); | ||
| 508 | 517 | const tabItemTextColor = tabView.style.tabTextColor; | |
| 509 | 518 | const textColor = tabItemTextColor instanceof Color ? tabItemTextColor.ios : null; | |
| 510 | 519 | result.normalState = { [NSFontAttributeName]: font } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -362,6 +362,8 @@ | |||
| 362 | 362 | getTabTextColor(): number; | |
| 363 | 363 | setSelectedTabTextColor(color: number): void; | |
| 364 | 364 | getSelectedTabTextColor(): number; | |
| 365 | + setTabTextFontSize(fontSize: number): void; | ||
| 366 | + getTabTextFontSize(): number; | ||
| 365 | 367 | ||
| 366 | 368 | setItems(items: Array<TabItemSpec>, viewPager: android.support.v4.view.ViewPager): void; | |
| 367 | 369 | updateItemAt(position: number, itemSpec: TabItemSpec): void; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments