Add dark mode (#33)

Closes: #18

This PR adds dark mode styling and an app setting to choose light, dark, or auto mode.

Reviewed-on: Georgi_Lab/ALVINN_f7#33
This commit is contained in:
2023-12-07 20:39:10 -07:00
parent fb81ebed83
commit 056d835b7c
10 changed files with 119 additions and 32 deletions

View File

@@ -10,24 +10,24 @@
<f7-block class="detect-grid">
<div class="image-container">
<img v-if="imageView" :src="imageView" id="im-display" ref="image_src" style="flex: 1 1 0%; object-fit: contain; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0;" />
<SvgIcon v-else icon="image" fill-color="var(--f7-theme-color)"/>
<div ref="structure_box" style="border: solid 3px yellow; position: absolute; display: none; box-sizing: border-box;" />
<SvgIcon v-else icon="image" fill-color="var(--avn-theme-color)"/>
<div ref="structure_box" style="border: solid 3px var(--avn-structure-box-color); position: absolute; display: none; box-sizing: border-box;" />
</div>
<div v-if="resultData && resultData.detections" class="chip-results" style="grid-area: result-view; flex: 0 0 auto; align-self: center;">
<f7-chip v-for="(result, idx) in resultData.detections" :class="(idx == selectedChip) ? 'selected-chip' : ''" :text="result.label" media=" " :tooltip="result.confidence.toFixed(1)" :media-bg-color="chipColor(result.confidence)" deleteable @click="selectChip(idx)" @delete="deleteChip(idx)" />
</div>
<f7-segmented class="image-menu" raised>
<f7-button popover-open="#region-popover">
<RegionIcon :region="activeRegion" fill-color="var(--f7-theme-color)"/>
<RegionIcon :region="activeRegion" />
</f7-button>
<f7-button @click="selectImage">
<SvgIcon icon="image" fill-color="var(--f7-theme-color)"/>
<SvgIcon icon="image" fill-color="var(--avn-theme-color)"/>
</f7-button>
<f7-button @click="setData" :class="(imageLoaded) ? '' : 'disabled'">
<SvgIcon icon="visibility" fill-color="var(--f7-theme-color)"/>
<SvgIcon icon="visibility" fill-color="var(--avn-theme-color)"/>
</f7-button>
<f7-button class="disabled" @click="setData">
<SvgIcon icon="videocam" fill-color="var(--f7-theme-color)"/>
<SvgIcon icon="videocam" fill-color="var(--avn-theme-color)"/>
</f7-button>
</f7-segmented>
<input type="file" ref="image_chooser" @change="getImage()" accept="image/*" style="display: none;"/>
@@ -115,7 +115,7 @@
.selected-chip {
font-weight: 500;
box-shadow: 4px 4px 1px var(--f7-theme-color);
box-shadow: 4px 4px 1px var(--avn-theme-color);
transform: translate(-2px, -2px);
}

View File

@@ -47,7 +47,7 @@
min-width: 100px;
height: auto;
width: 100%;
background-color: #BDBCAF;
background-color: var(--avn-button-bg-color);
padding: 5px;
}

View File

@@ -15,7 +15,13 @@
<f7-list-input :disabled="!serverSettings.use" v-model:value="serverSettings.address" label="Server address" type="text" placeholder="127.0.0.1" />
<f7-list-input :disabled="!serverSettings.use" v-model:value="serverSettings.port" label="Server port" type="text" placeholder="9001" />
</f7-list>
<f7-button @click="saveServerSettings" >Save</f7-button>
<f7-block-title medium>Dark Mode</f7-block-title>
<f7-list style="width: 100%;">
<f7-list-item title="Auto" :checked="themeSettings.darkMode == 'auto'" radio name="darkmode" radio-icon="end" @change="setDarkMode('auto')" ></f7-list-item>
<f7-list-item title="Light" :checked="themeSettings.darkMode.toString() == 'false'" radio name="darkmode" radio-icon="end" @change="setDarkMode(false)" ></f7-list-item>
<f7-list-item title="Dark" :checked="themeSettings.darkMode.toString() == 'true'" radio name="darkmode" radio-icon="end" @change="setDarkMode(true)" ></f7-list-item>
</f7-list>
<f7-button @click="saveAllSettings" >Save</f7-button>
</div>
</f7-block>
</f7-page>
@@ -27,23 +33,29 @@
export default {
data () {
return {
serverSettings: {
use: false,
address: '10.170.64.22',
port: '9001'
},
serverSettings: {
use: false,
address: '10.170.64.22',
port: '9001'
},
themeSettings: {
darkMode: 'auto'
}
}
},
created () {
var loadServerSettings = localStorage.getItem('serverSettings')
if (loadServerSettings) this.serverSettings = JSON.parse(loadServerSettings)
var loadThemeSettings = localStorage.getItem('themeSettings')
if (loadThemeSettings) this.themeSettings = JSON.parse(loadThemeSettings)
},
methods: {
saveServerSettings () {
saveAllSettings () {
let saveSetting = new Promise(
(saved,failed) => {
try {
localStorage.setItem('serverSettings',JSON.stringify(this.serverSettings))
localStorage.setItem('themeSettings',JSON.stringify(this.themeSettings))
saved()
} catch {
failed()
@@ -67,6 +79,10 @@
}
)
},
setDarkMode (mode) {
this.themeSettings.darkMode = mode
f7.setDarkMode(mode)
}
}
}
</script>