Skip to content

Commit 96abc93

Browse files
committed
backgroundColor added in ActionBarStyler
1 parent 7cc4830 commit 96abc93

File tree

2 files changed

+62
-31
lines changed

2 files changed

+62
-31
lines changed

apps/app/ui-tests-app/page/page-status-bar-css.xml

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,42 @@
44
<ActionBar title="Sample title" />
55
</Page.actionBar>
66

7-
<WrapLayout>
8-
<!-- status-bar-style -->
9-
<Button text="11" tap="applyTap" tag="status-bar-style: light;" style.fontSize="8" width="40" height="40" automationText="light;" />
10-
<Button text="12" tap="applyTap" tag="status-bar-style: dark;" style.fontSize="8" width="40" height="40" automationText="dark;" />
11-
12-
<!-- status-bar-style - action-bar - background -->
13-
<Button text="21" tap="applyTapOnStyledActionBar" tag="status-bar-style: light;" style.fontSize="8" width="40" height="40" automationText="light-abb-ruby" />
14-
<Button text="22" tap="applyTapOnStyledActionBar" tag="status-bar-style: dark;" style.fontSize="8" width="40" height="40" automationText="dark-abb-ruby" />
15-
16-
<!-- status-bar-style - action-bar - hidden -->
17-
<Button text="31" tap="applyTapWithHiddenActionBar" tag="status-bar-style: light;" style.fontSize="8" width="40" height="40" automationText="light-ab-hidden" />
18-
<Button text="32" tap="applyTapWithHiddenActionBar" tag="status-bar-style: dark;" style.fontSize="8" width="40" height="40" automationText="ark-ab-hidden" />
19-
20-
<!-- android-status-bar-background -->
21-
<Button text="41" tap="applyTap" tag="android-status-bar-background: #E0115F;" style.fontSize="8" width="40" height="40" automationText="asbb-blue" />
22-
23-
<!-- status-bar-style - page - background -->
24-
<Button text="51" tap="applyTap" tag="status-bar-style: light;background-color: #E0115F;" style.fontSize="8" width="40" height="40" automationText="light-bckg-ruby" />
25-
<Button text="52" tap="applyTap" tag="status-bar-style: dark; background-color: #E0115F;" style.fontSize="8" width="40" height="40" automationText="dark-bckg-ruby" />
26-
27-
<!-- status-bar-style - page - and - action-bar - background -->
28-
<Button text="61" tap="applyTapOnStyledActionBar" tag="status-bar-style: light;background-color: #E0115F;" style.fontSize="8" width="40" height="40" automationText="light-bckg-yellow-abbckg-ruby" />
29-
<Button text="62" tap="applyTapOnStyledActionBar" tag="status-bar-style: dark; ;background-color: #E0115F;" style.fontSize="8" width="40" height="40" automationText="dark-bckg-yellow-abbckg-ruby" />
30-
31-
<!-- status-bar-style - action-bar - hidden - and - backgroundSpanUnderStatusBar -->
32-
<Button text="71" tap="applyTapWithSpan" tag="status-bar-style: light;background-color: yellow" style.fontSize="8" width="40" height="40" automationText="dark-bckg-yellow-bckgsusb-true" />
33-
<Button text="72" tap="applyTapOnStyledActionBarAndSpan" tag="status-bar-style: light;background-color: yellow;" style.fontSize="8" width="40" height="40" automationText="light-bckg-yellow-abbck-ruby-bckgsusb-true" />
34-
35-
<Button text="73" tap="applyTapWithSpan" tag="status-bar-style: dark;background-color: yellow;" style.fontSize="8" width="40" height="40" automationText="light-ab-hidden-bckgsusb-true" />
36-
<Button text="74" tap="applyTapWithActionBarHiddenAndSpan" tag="status-bar-style: dark;background-color: yellow;" style.fontSize="8" width="40" height="40" automationText="dark-ab-hidden-bckgsusb-true" />
37-
</WrapLayout>
7+
<StackLayout padding="10">
8+
<Label text="IOS and Android" fontSize="14"/>
9+
<WrapLayout>
10+
<!-- status-bar-style -->
11+
<Button text="11" tap="applyTap" tag="status-bar-style: light;" style.fontSize="8" width="40" height="40" automationText="light;" />
12+
<Button text="12" tap="applyTap" tag="status-bar-style: dark;" style.fontSize="8" width="40" height="40" automationText="dark;" />
13+
14+
<!-- status-bar-style - action-bar - background -->
15+
<Button text="21" tap="applyTapOnStyledActionBar" tag="status-bar-style: light;" style.fontSize="8" width="40" height="40" automationText="light-abb-ruby" />
16+
<Button text="22" tap="applyTapOnStyledActionBar" tag="status-bar-style: dark;" style.fontSize="8" width="40" height="40" automationText="dark-abb-ruby" />
17+
18+
<!-- status-bar-style - page - background -->
19+
<Button text="51" tap="applyTap" tag="status-bar-style: light;background-color: #E0115F;" style.fontSize="8" width="40" height="40" automationText="light-bckg-ruby" />
20+
<Button text="52" tap="applyTap" tag="status-bar-style: dark; background-color: #E0115F;" style.fontSize="8" width="40" height="40" automationText="dark-bckg-ruby" />
21+
22+
<!-- status-bar-style - page - and - action-bar - background -->
23+
<Button text="61" tap="applyTapOnStyledActionBar" tag="status-bar-style: light;background-color: #E0115F;" style.fontSize="8" width="40" height="40" automationText="light-bckg-yellow-abbckg-ruby" />
24+
<Button text="62" tap="applyTapOnStyledActionBar" tag="status-bar-style: dark; ;background-color: #E0115F;" style.fontSize="8" width="40" height="40" automationText="dark-bckg-yellow-abbckg-ruby" />
25+
26+
<!-- status-bar-style - action-bar - hidden - and - backgroundSpanUnderStatusBar -->
27+
<Button text="71" tap="applyTapWithSpan" tag="status-bar-style: light;background-color: yellow" style.fontSize="8" width="40" height="40" automationText="dark-bckg-yellow-bckgsusb-true" />
28+
<Button text="72" tap="applyTapOnStyledActionBarAndSpan" tag="status-bar-style: light;background-color: yellow;" style.fontSize="8" width="40" height="40" automationText="light-bckg-yellow-abbck-ruby-bckgsusb-true" />
29+
30+
<Button text="73" tap="applyTapWithSpan" tag="status-bar-style: dark;background-color: yellow;" style.fontSize="8" width="40" height="40" automationText="light-ab-hidden-bckgsusb-true" />
31+
<Button text="74" tap="applyTapWithActionBarHiddenAndSpan" tag="status-bar-style: dark;background-color: yellow;" style.fontSize="8" width="40" height="40" automationText="dark-ab-hidden-bckgsusb-true" />
32+
33+
</WrapLayout>
34+
35+
<Label text="Android" fontSize="14" marginTop="10"/>
36+
<WrapLayout>
37+
<!-- status-bar-style - action-bar - hidden -->
38+
<Button text="31" tap="applyTapWithHiddenActionBar" tag="status-bar-style: light;" style.fontSize="8" width="40" height="40" automationText="light-ab-hidden" />
39+
<Button text="32" tap="applyTapWithHiddenActionBar" tag="status-bar-style: dark;" style.fontSize="8" width="40" height="40" automationText="ark-ab-hidden" />
40+
41+
<!-- android-status-bar-background -->
42+
<Button text="41" tap="applyTap" tag="android-status-bar-background: #E0115F;" style.fontSize="8" width="40" height="40" automationText="asbb-ruby" />
43+
</WrapLayout>
44+
</StackLayout>
3845
</Page>

tns-core-modules/ui/action-bar/action-bar.android.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,34 @@ export class ActionBarStyler implements style.Styler {
427427
(<android.support.v7.widget.Toolbar>v._nativeView).setTitleTextColor(nativeValue);
428428
}
429429

430+
// background-color
431+
private static getBackgroundColorProperty(view: view.View): any {
432+
let toolbar = <android.support.v7.widget.Toolbar>view._nativeView;
433+
return toolbar.getBackground();
434+
}
435+
436+
private static setBackgroundColorProperty(v: view.View, newValue: any) {
437+
var toolbar = (<android.support.v7.widget.Toolbar>v._nativeView);
438+
if (toolbar) {
439+
toolbar.setBackgroundColor(newValue);
440+
}
441+
}
442+
443+
private static resetBackgroundColorProperty(v: view.View, nativeValue: any) {
444+
var toolbar = (<android.support.v7.widget.Toolbar>v._nativeView);
445+
if (toolbar) {
446+
toolbar.setBackgroundColor(nativeValue);
447+
}
448+
}
449+
430450
public static registerHandlers() {
431451
style.registerHandler(style.colorProperty, new style.StylePropertyChangedHandler(
432452
ActionBarStyler.setColorProperty,
433453
ActionBarStyler.resetColorProperty), "ActionBar");
454+
style.registerHandler(style.backgroundColorProperty, new style.StylePropertyChangedHandler(
455+
ActionBarStyler.setBackgroundColorProperty,
456+
ActionBarStyler.resetBackgroundColorProperty,
457+
ActionBarStyler.getBackgroundColorProperty), "ActionBar");
434458
}
435459
}
436460

0 commit comments

Comments
 (0)