Skip to content

Commit

Permalink
Theme color dark support (#4235)
Browse files Browse the repository at this point in the history
Support themeColorDark for Android CloudAPK.
Minor fix: app name regexp pattern browser error.

Need to merge the CloudAPK itself first:
pwa-builder/CloudAPK#120
  • Loading branch information
khmyznikov authored Aug 22, 2023
1 parent ce1c307 commit 6aa5ff8
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/pwabuilder-vscode/src/android-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface AndroidPackageOptions {
splashScreenFadeOutDuration: number;
startUrl: string;
themeColor: string;
themeColorDark?: string;
webManifestUrl: string;
}
/**
Expand Down
2 changes: 2 additions & 0 deletions apps/pwabuilder-vscode/src/library/package-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const advancedAndroidSettings: AndroidPackageOptions = {
splashScreenFadeOutDuration: 300,
startUrl: "/",
themeColor: "#FFFFFF",
themeColorDark: "#FFFFFF",
shareTarget: [] as any,
webManifestUrl: "https://myapp.com/manifest.json",
};
Expand Down Expand Up @@ -454,6 +455,7 @@ export async function buildAndroidOptions(): Promise<
splashScreenFadeOutDuration: 300,
startUrl: manifest.start_url || "/",
themeColor: manifest.theme_color || "#FFFFFF",
themeColorDark: manifest.theme_color || "#FFFFFF",
shareTarget: manifest.share_target || [],
webManifestUrl: manifestUrl,
};
Expand Down
14 changes: 13 additions & 1 deletion apps/pwabuilder/src/script/components/android-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AppPackageFormBase } from './app-package-form-base';
import { getManifestContext } from '../services/app-info';
import { maxSigningKeySizeInBytes } from '../utils/android-validation';
import { recordPWABuilderProcessStep, AnalyticsBehavior } from '../utils/analytics';
import { AppNameInputPattern } from '../utils/constants';

@customElement('android-form')

Expand Down Expand Up @@ -278,7 +279,7 @@ export class AndroidForm extends AppPackageFormBase {
minLength: 3,
maxLength: 50,
spellcheck: false,
pattern: "[^|$@#><)(!&%*]*$",
pattern: AppNameInputPattern,
validationErrorMessage:
'App name must not include special characters and be between 3 and 50 characters',
inputHandler: (val: string) => this.packageOptions.name = val
Expand Down Expand Up @@ -381,6 +382,17 @@ export class AndroidForm extends AppPackageFormBase {
})}
</div>
<div class="form-group">
${this.renderFormInput({
label: 'Theme dark color',
tooltip: `The theme color used for the Android status bar in your app when the Android device is in dark mode.`,
inputId: 'theme-dark-color-input',
type: 'color',
value: this.packageOptions.themeColorDark,
inputHandler: (val: string) => this.packageOptions.themeColorDark = val
})}
</div>
<div class="form-group">
${this.renderFormInput({
label: 'Background color',
Expand Down
3 changes: 2 additions & 1 deletion apps/pwabuilder/src/script/components/ios-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createIOSPackageOptionsFromManifest, emptyIOSPackageOptions } from '../
import { getManifestContext } from '../services/app-info';
import { AnalyticsBehavior, recordPWABuilderProcessStep } from '../utils/analytics';
import { ManifestContext, PackageOptions } from '../utils/interfaces';
import { AppNameInputPattern } from '../utils/constants';

@customElement('ios-form')

Expand Down Expand Up @@ -169,7 +170,7 @@ export class IOSForm extends AppPackageFormBase {
required: true,
spellcheck: false,
minLength: 3,
pattern: "[^|$@#><)(!&%*]*$",
pattern: AppNameInputPattern,
// pattern: // NOTE: avoid using a regex pattern here, as it often has unintended consequences, such as blocking non-English names
inputHandler: (val: string) => this.packageOptions.name = val
})}
Expand Down
3 changes: 2 additions & 1 deletion apps/pwabuilder/src/script/components/oculus-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SigningMode } from '../utils/oculus-validation';
import { maxSigningKeySizeInBytes } from '../utils/android-validation';
import { recordPWABuilderProcessStep, AnalyticsBehavior } from '../utils/analytics';
import { ManifestContext, PackageOptions } from '../utils/interfaces';
import { AppNameInputPattern } from '../utils/constants';

@customElement('oculus-form')

Expand Down Expand Up @@ -243,7 +244,7 @@ export class OculusForm extends AppPackageFormBase {
required: true,
spellcheck: false,
minLength: 3,
pattern: "[^|$@#><)(!&%*]*$",
pattern: AppNameInputPattern,
// pattern: // NOTE: avoid using a regex pattern here, as it often has unintended consequences, such as blocking non-English names
inputHandler: (val: string) => (this.packageOptions.name = val),
})}
Expand Down
3 changes: 2 additions & 1 deletion apps/pwabuilder/src/script/components/windows-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AppPackageFormBase, FormInput } from './app-package-form-base';
import { fetchOrCreateManifest } from '../services/manifest';
import { AnalyticsBehavior, recordPWABuilderProcessStep } from '../utils/analytics';
import { ManifestContext, PackageOptions } from '../utils/interfaces';
import { AppNameInputPattern } from '../utils/constants';

@customElement('windows-form')

Expand Down Expand Up @@ -412,7 +413,7 @@ export class WindowsForm extends AppPackageFormBase {
maxLength: 256,
value: this.packageOptions.name,
placeholder: 'My Awesome PWA',
pattern: "[^|$@#><)(!&%*]*$",
pattern: AppNameInputPattern,
validationErrorMessage:
'App name must not include special characters and be between 1 and 256 characters',
inputHandler: (val: string) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export function emptyAndroidPackageOptions(): AndroidPackageOptions {
splashScreenFadeOutDuration: 300,
startUrl: '',
themeColor: '#ffffff',
themeColorDark: '#000000',
webManifestUrl: '',
fullScopeUrl: ''
};
Expand Down Expand Up @@ -249,6 +250,7 @@ export function createAndroidPackageOptionsFromManifest(manifestContext: Manifes
new URL(manifestUrlOrRoot)
),
themeColor: manifest.theme_color || '#FFFFFF',
themeColorDark: manifest.theme_color || '#000000',
shareTarget: manifest.share_target,
webManifestUrl: maniUrl,
pwaUrl: manifestContext.siteUrl,
Expand Down
1 change: 1 addition & 0 deletions apps/pwabuilder/src/script/utils/android-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface AndroidPackageOptions extends PackageOptions {
splashScreenFadeOutDuration: number;
startUrl: string;
themeColor: string;
themeColorDark?: string;
webManifestUrl: string;
fullScopeUrl: string;
minSdkVersion?: number;
Expand Down
1 change: 1 addition & 0 deletions apps/pwabuilder/src/script/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const AppNameInputPattern = '[^\\|\\$\\@\\#\\>\\<\\)\\(\\!\\&\\%\\*]+$';

0 comments on commit 6aa5ff8

Please sign in to comment.