Config: Update Progressive Web App (PWA) flag usage and defaults

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-09-07 22:03:05 +02:00
parent 7d3978cfd4
commit a6f66127fb
3 changed files with 14 additions and 9 deletions

View File

@@ -11,6 +11,9 @@ import (
"github.com/photoprism/photoprism/pkg/txt"
)
// DefaultAppColor specifies the default app background and splash screen color.
var DefaultAppColor = "#19191a"
// AppName returns the app name when installed on a device.
func (c *Config) AppName() string {
name := strings.TrimSpace(c.options.AppName)
@@ -58,10 +61,10 @@ func (c *Config) AppIcon() string {
return defaultIcon
}
// AppColor returns the app splash screen color when installed on a device.
// AppColor returns the app background and splash screen color.
func (c *Config) AppColor() string {
if appColor := clean.Color(c.options.AppColor); appColor == "" {
return "#000000"
return DefaultAppColor
} else {
return appColor
}

View File

@@ -42,11 +42,13 @@ func TestConfig_AppIcon(t *testing.T) {
func TestConfig_AppColor(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, "#000000", c.AppColor())
assert.Equal(t, DefaultAppColor, c.AppColor())
c.options.AppColor = "#aBC123"
assert.Equal(t, "#abc123", c.AppColor())
c.options.AppColor = ""
c.options.AppColor = "#000000"
assert.Equal(t, "#000000", c.AppColor())
c.options.AppColor = ""
assert.Equal(t, DefaultAppColor, c.AppColor())
}
func TestConfig_AppIconsPath(t *testing.T) {

View File

@@ -530,25 +530,25 @@ var Flags = CliFlags{
}}, {
Flag: &cli.StringFlag{
Name: "app-name",
Usage: "progressive web app `NAME` when installed on a device",
Usage: "app `NAME` when installed as a Progressive Web App (PWA)",
Value: "",
EnvVars: EnvVars("APP_NAME"),
}}, {
Flag: &cli.StringFlag{
Name: "app-mode",
Usage: "progressive web app `MODE` (fullscreen, standalone, minimal-ui, browser)",
Usage: "app display `MODE` (fullscreen, standalone, minimal-ui, browser)",
Value: "standalone",
EnvVars: EnvVars("APP_MODE"),
}}, {
Flag: &cli.StringFlag{
Name: "app-icon",
Usage: "home screen `ICON` (logo, app, crisp, mint, bold, square)",
Usage: "home screen app `ICON` (logo, app, crisp, mint, bold, square)",
EnvVars: EnvVars("APP_ICON"),
}}, {
Flag: &cli.StringFlag{
Name: "app-color",
Usage: "splash screen `COLOR` code",
Value: "#000000",
Usage: "app background and splash screen `COLOR`",
Value: DefaultAppColor,
EnvVars: EnvVars("APP_COLOR"),
}}, {
Flag: &cli.StringFlag{