From 3d695700995f480983cdc99d2651eefff628bb8a Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Thu, 5 Sep 2024 13:10:58 +0200 Subject: [PATCH] Improve multi-currency support --- src/routes/+page.svelte | 3 +- src/routes/Settings.svelte | 85 ++++++++++++++++++++++++-------------- src/routes/Status.svelte | 4 +- 3 files changed, 57 insertions(+), 35 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 4100d86..9e26acb 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -12,7 +12,8 @@ import { uiSettings } from '$lib/uiSettings'; let settings = writable({ - fgColor: '0' + fgColor: '0', + bgColor: '0' }); // let uiSettings = writable({ diff --git a/src/routes/Settings.svelte b/src/routes/Settings.svelte index 78f1fe1..9a6b0f2 100644 --- a/src/routes/Settings.svelte +++ b/src/routes/Settings.svelte @@ -22,6 +22,7 @@ } from '@sveltestrap/sveltestrap'; import EyeIcon from '../icons/EyeIcon.svelte'; import EyeSlashIcon from '../icons/EyeSlashIcon.svelte'; + import { derived } from 'svelte/store'; export let settings; @@ -160,6 +161,40 @@ let showPassword = false; + let textColor = '0'; + const colorStore = derived(settings, ($settings) => ({ + fgColor: $settings.fgColor, + bgColor: $settings.bgColor + })); + + // $: { + // if ($colorStore) { + // console.log('Settings model changed:', $colorStore); + // if ($colorStore.fgColor < $colorStore.bgColor) + // textColor = "0"; + // else + // textColor = "1"; // 65535 + // } + // } + + colorStore.subscribe(() => { + if ($colorStore) { + if ($colorStore.fgColor < $colorStore.bgColor) textColor = '0'; + else textColor = '1'; // 65535 + } + }); + + const setTextColor = () => { + console.log(textColor); + if (textColor == '1') { + $settings.fgColor = 65535; + $settings.bgColor = 0; + } else { + $settings.fgColor = 0; + $settings.bgColor = 65535; + } + }; + export let xs = 12; export let sm = xs; export let md = sm; @@ -176,41 +211,25 @@
- - - - - - - - - - - - + + + {/if} - - - + {#if !$settings.actCurrencies} + + + + {/if} - {#if $settings.actCurrencies} + {#if $settings.actCurrencies && $settings.ownDataSource}
{#each $settings.actCurrencies as c} @@ -248,7 +248,7 @@ {:else} {$_('section.status.wsDataConnection')}: - {#if $status.connectionStatus && $status.connectionStatus.price} + {#if $status.connectionStatus && $status.connectionStatus.V2} ✅ {:else} ❌