diff --git a/src/routes/Settings/Settings.js b/src/routes/Settings/Settings.js index 843227394..1dfe7fcfd 100644 --- a/src/routes/Settings/Settings.js +++ b/src/routes/Settings/Settings.js @@ -6,7 +6,7 @@ const throttle = require('lodash.throttle'); const Icon = require('stremio-icons/dom'); const { useRouteFocused } = require('stremio-router'); const { useServices } = require('stremio/services'); -const { Button, Checkbox, MainNavBars, Multiselect, ColorInput, TextInput, useProfile } = require('stremio/common'); +const { Button, Checkbox, MainNavBars, Multiselect, ColorInput, TextInput, ModalDialog, useProfile, useBinaryState } = require('stremio/common'); const useStreamingServer = require('./useStreamingServer'); const useProfileSettingsInputs = require('./useProfileSettingsInputs'); const useStreamingServerSettingsInputs = require('./useStreamingServerSettingsInputs'); @@ -21,6 +21,42 @@ const Settings = () => { const { routeFocused } = useRouteFocused(); const profile = useProfile(); const streamingServer = useStreamingServer(); + const [editServerUrlModalOpen, openEditServerUrlModal, closeEditServerUrlModal] = useBinaryState(false); + const editServerUrlInputRef = React.useRef(null); + const editServerUrlOnClick = React.useCallback(() => { + if (editServerUrlInputRef.current !== null) { + core.dispatch({ + action: 'Ctx', + args: { + action: 'UpdateSettings', + args: { + ...profile.settings, + streaming_server_url: editServerUrlInputRef.current.value + } + } + }); + if (typeof closeEditServerUrlModal === 'function') { + closeEditServerUrlModal(); + } + } + }, []); + const editServerUrlModalButtons = React.useMemo(() => { + return [ + { + className: styles['cancel-button'], + label: 'Cancel', + props: { + onClick: closeEditServerUrlModal + } + }, + { + label: 'Edit', + props: { + onClick: editServerUrlOnClick, + } + } + ]; + }, [editServerUrlOnClick]); const { interfaceLanguageSelect, subtitlesLanguageSelect, @@ -104,6 +140,7 @@ const Settings = () => { if (routeFocused) { updateSelectedSectionId(); } + closeEditServerUrlModal(); }, [routeFocused]); return ( @@ -355,10 +392,12 @@ const Settings = () => {
Url
- +
+
{profile.settings.streaming_server_url}
+ +
{ cacheSizeSelect !== null ? @@ -391,6 +430,25 @@ const Settings = () => { + { + editServerUrlModalOpen ? + +
You can edit the default streaming server url
+ +
+ : + null + }
); }; diff --git a/src/routes/Settings/styles.less b/src/routes/Settings/styles.less index a92b1a178..43ac4cea9 100644 --- a/src/routes/Settings/styles.less +++ b/src/routes/Settings/styles.less @@ -11,6 +11,11 @@ multiselect-label: label; } +:import('~stremio/common/ModalDialog/styles.less') { + addon-modal-content: modal-dialog-content; + cancel-button-label: label; +} + .settings-container { width: 100%; height: 100%; @@ -215,18 +220,6 @@ .option-input-container { padding: 1rem; - &.text-input-container { - background-color: @color-background; - color: @color-secondaryvariant1-90; - font-weight: 500; - - &::placeholder { - max-height: 1.2em; - opacity: 0.5; - color: @color-secondaryvariant1-light1-90; - } - } - &.button-container { justify-content: center; background-color: @color-accent3; @@ -287,9 +280,72 @@ } } } + + &.edit-container { + padding: 0; + + .label { + overflow: hidden; + white-space: pre; + text-overflow: ellipsis; + padding: 0 1rem; + } + + .button-container { + flex: auto; + + .icon { + margin: 0; + } + } + } } } } } } +} + +.edit-server-url-modal-container { + .addon-modal-content { + width: 30rem; + + .notice { + margin-bottom: 1.5rem; + font-size: 1rem; + color: @color-background-dark5-90; + } + + .server-url-input { + width: 100%; + padding: 1rem; + color: @color-surface-dark5; + outline: var(--focus-outline-size) solid @color-surface-light2; + outline-offset: calc(-1 * var(--focus-outline-size)); + + &:hover { + outline-color: @color-surface-light4; + } + + &:focus { + outline-color: @color-background-dark5; + } + } + } + + .cancel-button { + background-color: transparent; + + &:hover { + background-color: @color-surface-light3; + } + + &:focus { + outline-color: @color-background-dark5; + } + + .cancel-button-label { + color: @color-surface-dark2; + } + } } \ No newline at end of file