Skip to content

Commit ca30f73

Browse files
committed
feat(core): onPrimaryColor
1 parent cc55c21 commit ca30f73

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/core/index.android.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function createCornerTreatment(cornerFamily: CornerFamily): com.google.android.m
2020
// stub class as we don't use this on android
2121
export class Themer {
2222
primaryColor: string | Color;
23+
onPrimaryColor: string | Color;
2324
accentColor: string | Color;
2425
secondaryColor: string | Color;
2526
primaryColorVariant: string | Color;
@@ -45,6 +46,16 @@ export class Themer {
4546
return this.primaryColor;
4647
}
4748

49+
setOnPrimaryColor(value) {
50+
this.onPrimaryColor = value;
51+
}
52+
getOnPrimaryColor() {
53+
if (!this.onPrimaryColor) {
54+
this.onPrimaryColor = new Color(getAttrColor(Application.android.startActivity, 'colorOnPrimary'));
55+
}
56+
return this.onPrimaryColor;
57+
}
58+
4859
setAccentColor(value: string | Color) {
4960
if (!this.accentColor) {
5061
this.accentColor = new Color(getAttrColor(Application.android.startActivity, 'colorAccent'));

src/core/index.ios.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class Themer {
4747
appColorScheme: MDCSemanticColorScheme;
4848
appTypoScheme: MDCTypographyScheme;
4949
primaryColor: string | Color;
50+
onPrimaryColor: string | Color;
5051
secondaryColor: string | Color;
5152
accentColor: string | Color;
5253
primaryColorVariant: string | Color;
@@ -74,11 +75,20 @@ export class Themer {
7475
const color = value instanceof Color ? value : new Color(value);
7576
colorTheme.primaryColor = color.ios;
7677
this.appColorScheme.primaryColorVariant = this.appColorScheme.primaryColor.colorWithAlphaComponent(0.24);
77-
// colorTheme.primaryColorVariant = new Color(61.2, color.r, color.g, color.b).ios; // default alpha is 0.24
7878
}
7979
getPrimaryColor(): string | Color {
8080
return this.primaryColor;
8181
}
82+
83+
setOnPrimaryColor(value) {
84+
this.onPrimaryColor = value;
85+
const colorTheme = this.getOrcreateAppColorScheme();
86+
const color = value instanceof Color ? value : new Color(value);
87+
colorTheme.onPrimaryColor = color.ios;
88+
}
89+
getOnPrimaryColor() {
90+
return this.onPrimaryColor;
91+
}
8292
setSecondaryColor(value: string | Color) {
8393
this.secondaryColor = value;
8494
const colorTheme = this.getOrcreateAppColorScheme();

0 commit comments

Comments
 (0)