Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Manage multiple streaming URLs in the Settings #707

Merged
merged 41 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b23204a
add: logs
kKaskak Oct 9, 2024
d12766e
feat: Support Multiple Server URLs in the settings
kKaskak Oct 21, 2024
14d5fc3
refactor: handle edge cases correctly
kKaskak Oct 22, 2024
fd88b18
fix: Item and checkbox styles
kKaskak Oct 22, 2024
2237679
refactor: change delete icon
kKaskak Oct 22, 2024
55384ff
refactor: optimisations
kKaskak Oct 22, 2024
2741697
fix: onDelete action + translations strings
kKaskak Oct 22, 2024
9fa17da
fix: minor styles issues
kKaskak Oct 23, 2024
04fdc64
fix: liniting
kKaskak Oct 24, 2024
783c4dc
refactor: rename mtime
kKaskak Oct 24, 2024
e296c76
refactor: address the comments
kKaskak Oct 24, 2024
b6b9128
fix: imports
kKaskak Oct 24, 2024
dc5f90b
refactor: imports resolutions
kKaskak Oct 24, 2024
7e56236
refactor: item component
kKaskak Oct 24, 2024
15ca542
Merge branch 'development' into feat/manage-streaming-urls
kKaskak Oct 24, 2024
603c314
fix: eslint errors
kKaskak Oct 24, 2024
8b067ad
chore: fix eslint (2)
kKaskak Oct 24, 2024
f8cf7f7
refactor: use the other function for submitting
kKaskak Oct 24, 2024
38fc6e3
refactor: separate AddItem
kKaskak Oct 24, 2024
d32782b
refactor: handle ordering by core
kKaskak Oct 24, 2024
ada66b9
refactor: add profile.settings to dependency array
kKaskak Oct 24, 2024
1b1cf2b
add: placeholder
kKaskak Oct 24, 2024
d88aef1
chore: add stremio-core-web dep. of feature branch build
elpiel Nov 8, 2024
ad8e0f9
Merge branch 'development' into feat/manage-streaming-urls
elpiel Nov 8, 2024
9e1e4f0
chore: update pkg integrity
kKaskak Nov 26, 2024
93db086
Merge branch 'development' into feat/manage-streaming-urls
kKaskak Nov 28, 2024
c3611c6
chore(fix): pkg.lock.json
kKaskak Nov 28, 2024
e709976
Merge branch 'development' into feat/manage-streaming-urls
kKaskak Nov 28, 2024
7087033
fix: typo of toggle
kKaskak Nov 29, 2024
ccccce2
refactor: checkbox component
kKaskak Nov 29, 2024
ccde597
refactor: minor improvements, better spacing
kKaskak Nov 29, 2024
a09332e
refactor: use a radio button on the item instead
kKaskak Nov 29, 2024
55eba27
remove: checkbox label css
kKaskak Nov 29, 2024
31b0d06
remove: checkbox component
kKaskak Nov 29, 2024
c49817a
chore: lint fix
kKaskak Nov 29, 2024
50843dc
add: index for checkbox
kKaskak Nov 29, 2024
f2994a5
Revert "add: index for checkbox"
kKaskak Nov 29, 2024
9e3c0c6
refactor: radio button component structure
kKaskak Nov 29, 2024
4ce8af7
chore(pkgs): update core-web
kKaskak Nov 29, 2024
46a29a4
chore(pkgs): update core-web & translations
kKaskak Nov 30, 2024
6d3eeaa
refactor: fix focus on item
kKaskak Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"@babel/runtime": "7.16.0",
"@sentry/browser": "6.13.3",
"@stremio/stremio-colors": "5.0.1",
"@stremio/stremio-core-web": "0.48.0",
"@stremio/stremio-icons": "5.2.0",
"@stremio/stremio-core-web": "https://stremio.github.io/stremio-core/stremio-core-web/feat/streming-server-urls-bucket/dev/stremio-stremio-core-web-0.47.8.tgz",
"@stremio/stremio-icons": "5.4.0",
"@stremio/stremio-video": "0.0.46",
"a-color-picker": "1.2.1",
"bowser": "2.11.0",
Expand Down
2 changes: 2 additions & 0 deletions src/common/CONSTANTS.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (C) 2017-2023 Smart code 203358507

const CHROMECAST_RECEIVER_APP_ID = '1634F54B';
const DEFAULT_STREAMING_SERVER_URL = 'http://127.0.0.1:11470/';
const SUBTITLES_SIZES = [75, 100, 125, 150, 175, 200, 250];
const SUBTITLES_FONTS = ['PlusJakartaSans', 'Arial', 'Halvetica', 'Times New Roman', 'Verdana', 'Courier', 'Lucida Console', 'sans-serif', 'serif', 'monospace'];
const SEEK_TIME_DURATIONS = [3000, 5000, 10000, 15000, 20000, 30000];
Expand Down Expand Up @@ -97,6 +98,7 @@ const WHITELISTED_HOSTS = ['stremio.com', 'strem.io', 'stremio.zendesk.com', 'go

module.exports = {
CHROMECAST_RECEIVER_APP_ID,
DEFAULT_STREAMING_SERVER_URL,
SUBTITLES_SIZES,
SUBTITLES_FONTS,
SEEK_TIME_DURATIONS,
Expand Down
86 changes: 86 additions & 0 deletions src/common/Checkbox/Checkbox.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright (C) 2017-2024 Smart code 203358507

.checkbox {
display: flex;
align-items: center;

label {
display: flex;
align-items: center;
cursor: pointer;

.checkbox-checked {
.checkbox-container {
background-color: var(--primary-accent-color);
border-color: var(--primary-accent-color);
}

.checkbox-icon {
color: var(--secondary-foreground-color);
}
}

.checkbox-unchecked {
.checkbox-container {
background-color: transparent;
border-color: var(--primary-accent-color);
}
}

.checkbox-disabled {
cursor: not-allowed;

.checkbox-container {
cursor: not-allowed;
}

.checkbox-label {
color: var(--primary-foreground-color);
opacity: 0.6;
}
}

.checkbox-error {
.checkbox-container {
border-color: var(--color-reddit);
}

.checkbox-label {
color: var(--color-reddit);
}
}

.checkbox-container {
position: relative;
width: 1.25rem;
height: 1.25rem;
border: 2px solid var(--primary-accent-color);
border-radius: 0.25rem;
background-color: transparent;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease-in-out;
cursor: pointer;
outline: none;
user-select: none;

&:focus {
outline: var(--focus-outline-size) solid var(--primary-accent-color);
outline-offset: 2px;
}

input[type='checkbox'] {
opacity: 0;
width: 0;
height: 0;
position: absolute;
}

.checkbox-icon {
color: var(--primary-background-color);
width: 1rem;
}
}
}
}
83 changes: 83 additions & 0 deletions src/common/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (C) 2017-2024 Smart code 203358507

import React, { useState, useEffect, useCallback, DetailedHTMLProps, HTMLAttributes } from 'react';
import classNames from 'classnames';
import styles from './Checkbox.less';
import Icon from '@stremio/stremio-icons/react';

type Props = {
disabled?: boolean;
value?: boolean;
className?: string;
onChange?: (checked: boolean) => void;
ariaLabel?: string;
error?: string;
};

const Checkbox = ({ disabled, value, className, onChange, ariaLabel, error }: Props) => {
const [isChecked, setIsChecked] = useState(false);
kKaskak marked this conversation as resolved.
Show resolved Hide resolved
const [isError, setIsError] = useState(false);
const [isDisabled, setIsDisabled] = useState(disabled);

const handleChangeCheckbox = useCallback(() => {
kKaskak marked this conversation as resolved.
Show resolved Hide resolved
if (disabled) {
return;
}

setIsChecked(!isChecked);
onChange && onChange(!isChecked);
}, [disabled]);

const handleEnterPress = useCallback((event: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => {
kKaskak marked this conversation as resolved.
Show resolved Hide resolved
if ((event.key === 'Enter' || event.key === ' ') && !disabled) {
setIsChecked(!isChecked);
onChange && onChange(!isChecked);
}
}, [disabled]);

useEffect(() => setIsDisabled(disabled), [disabled]);
kKaskak marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => setIsError(!!error), [error]);
kKaskak marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
kKaskak marked this conversation as resolved.
Show resolved Hide resolved
const checked = typeof value === 'boolean' ? value : false;
setIsChecked(checked);
}, [value]);

return (
<div className={classNames(styles['checkbox'], className)}>
<label>
<div
className={classNames({
[styles['checkbox-checked']]: isChecked,
[styles['checkbox-unchecked']]: !isChecked,
[styles['checkbox-error']]: isError,
[styles['checkbox-disabled']]: isDisabled,
})}
>
<div
className={styles['checkbox-container']}
role={'input'}
tabIndex={0}
onKeyDown={handleEnterPress}
>
<input
type={'checkbox'}
kKaskak marked this conversation as resolved.
Show resolved Hide resolved
onChange={handleChangeCheckbox}
aria-label={ariaLabel}
tabIndex={-1}
disabled={disabled}
/>
{
isChecked ?
<Icon name={'checkmark'} className={styles['checkbox-icon']} />
: null
}
</div>
</div>
</label>
</div>
);
};

export default Checkbox;
5 changes: 0 additions & 5 deletions src/common/Checkbox/index.js

This file was deleted.

5 changes: 5 additions & 0 deletions src/common/Checkbox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (C) 2017-2024 Smart code 203358507

import Checkbox from './Checkbox';

export default Checkbox;
2 changes: 1 addition & 1 deletion src/common/NavBar/HorizontalNavBar/SearchBar/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const { useTranslation } = require('react-i18next');
const { default: Icon } = require('@stremio/stremio-icons/react');
const { useRouteFocused } = require('stremio-router');
const Button = require('stremio/common/Button');
const TextInput = require('stremio/common/TextInput');
const useTorrent = require('stremio/common/useTorrent');
const { withCoreSuspender } = require('stremio/common/CoreSuspender');
const useSearchHistory = require('./useSearchHistory');
const useLocalSearch = require('./useLocalSearch');
const styles = require('./styles');
const useBinaryState = require('stremio/common/useBinaryState');
const { default: TextInput } = require('stremio/common/TextInput');

const SearchBar = React.memo(({ className, query, active }) => {
const { t } = useTranslation();
Expand Down
2 changes: 1 addition & 1 deletion src/common/SearchBar/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const React = require('react');
const PropTypes = require('prop-types');
const classnames = require('classnames');
const { default: Icon } = require('@stremio/stremio-icons/react');
const TextInput = require('stremio/common/TextInput');
const { default: TextInput } = require('../TextInput');
const SearchBarPlaceholder = require('./SearchBarPlaceholder');
const styles = require('./styles');

Expand Down
2 changes: 1 addition & 1 deletion src/common/SharePrompt/SharePrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const { default: Icon } = require('@stremio/stremio-icons/react');
const { useRouteFocused } = require('stremio-router');
const { useServices } = require('stremio/services');
const useToast = require('stremio/common/Toast/useToast');
const { default: TextInput } = require('../TextInput');
const Button = require('stremio/common/Button');
const TextInput = require('stremio/common/TextInput');
const styles = require('./styles');

const SharePrompt = ({ className, url }) => {
Expand Down
43 changes: 0 additions & 43 deletions src/common/TextInput/TextInput.js

This file was deleted.

49 changes: 49 additions & 0 deletions src/common/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (C) 2017-2024 Smart code 203358507

import React from 'react';
import classnames from 'classnames';
import styles from './styles.less';

type Props = React.InputHTMLAttributes<HTMLInputElement> & {
className?: string;
disabled?: boolean;
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
onSubmit?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
};

const TextInput = React.forwardRef<HTMLInputElement, Props>((props, ref) => {
const { onSubmit, className, disabled, ...rest } = props;

const onKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {
if (typeof props.onKeyDown === 'function') {
props.onKeyDown(event);
}

if (
event.key === 'Enter' &&
!(event.nativeEvent as any).submitPrevented &&
typeof onSubmit === 'function'
) {
onSubmit(event);
}
}, [props.onKeyDown, onSubmit]);

return (
<input
size={1}
autoCorrect={'off'}
autoCapitalize={'off'}
autoComplete={'off'}
spellCheck={false}
tabIndex={0}
ref={ref}
className={classnames(className, styles['text-input'], { disabled })}
onKeyDown={onKeyDown}
{...rest}
/>
);
});

TextInput.displayName = 'TextInput';

export default TextInput;
5 changes: 0 additions & 5 deletions src/common/TextInput/index.js

This file was deleted.

5 changes: 5 additions & 0 deletions src/common/TextInput/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (C) 2017-2024 Smart code 203358507

import TextInput from './TextInput';

export default TextInput;
Loading