Skip to content

Commit

Permalink
Merge pull request #817 from Stremio/feat/shell-updater-banner
Browse files Browse the repository at this point in the history
App: add updater banner
  • Loading branch information
tymmesyde authored Feb 7, 2025
2 parents 9cf8a39 + adebe0c commit 8a1b040
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"react-i18next": "^15.1.3",
"react-is": "18.3.1",
"spatial-navigation-polyfill": "github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6",
"stremio-translations": "github:Stremio/stremio-translations#a0f50634202f748a57907b645d2cd92fbaa479dd",
"stremio-translations": "github:Stremio/stremio-translations#62bcc6e8f44258203c7375af59210771efb6f634",
"url": "0.11.4",
"use-long-press": "^3.2.0"
},
Expand Down
2 changes: 2 additions & 0 deletions src/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { PlatformProvider, ToastProvider, TooltipProvider, CONSTANTS, withCoreSus
const ServicesToaster = require('./ServicesToaster');
const DeepLinkHandler = require('./DeepLinkHandler');
const SearchParamsHandler = require('./SearchParamsHandler');
const { default: UpdaterBanner } = require('./UpdaterBanner');
const ErrorDialog = require('./ErrorDialog');
const withProtectedRoutes = require('./withProtectedRoutes');
const routerViewsConfig = require('./routerViewsConfig');
Expand Down Expand Up @@ -168,6 +169,7 @@ const App = () => {
<ServicesToaster />
<DeepLinkHandler />
<SearchParamsHandler />
<UpdaterBanner className={styles['updater-banner-container']} />
<RouterWithProtectedRoutes
className={styles['router']}
viewsConfig={routerViewsConfig}
Expand Down
46 changes: 46 additions & 0 deletions src/App/UpdaterBanner/UpdaterBanner.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.updater-banner {
height: 4rem;
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
padding: 0 1rem;
font-size: 1rem;
font-weight: bold;
color: var(--primary-foreground-color);
background-color: var(--primary-accent-color);

.button {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
height: 2.5rem;
padding: 0 1rem;
border-radius: var(--border-radius);
color: var(--primary-background-color);
background-color: var(--primary-foreground-color);
transition: all 0.1s ease-out;

&:hover {
color: var(--primary-foreground-color);
background-color: transparent;
box-shadow: inset 0 0 0 0.15rem var(--primary-foreground-color);
}
}

.close {
position: absolute;
right: 0;
height: 4rem;
width: 4rem;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;

.icon {
height: 2rem;
}
}
}
50 changes: 50 additions & 0 deletions src/App/UpdaterBanner/UpdaterBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { useEffect } from 'react';
import Icon from '@stremio/stremio-icons/react';
import { useTranslation } from 'react-i18next';
import { useServices } from 'stremio/services';
import { useBinaryState, useShell } from 'stremio/common';
import { Button, Transition } from 'stremio/components';
import styles from './UpdaterBanner.less';

type Props = {
className: string,
};

const UpdaterBanner = ({ className }: Props) => {
const { t } = useTranslation();
const { shell } = useServices();
const shellTransport = useShell();
const [visible, show, hide] = useBinaryState(false);

const onInstallClick = () => {
shellTransport.send('autoupdater-notif-clicked');
};

useEffect(() => {
shell.transport && shell.transport.on('autoupdater-show-notif', show);

return () => {
shell.transport && shell.transport.off('autoupdater-show-notif', show);
};
}, []);

return (
<div className={className}>
<Transition when={visible} name={'slide-up'}>
<div className={styles['updater-banner']}>
<div className={styles['label']}>
{ t('UPDATER_TITLE') }
</div>
<Button className={styles['button']} onClick={onInstallClick}>
{ t('UPDATER_INSTALL_BUTTON') }
</Button>
<Button className={styles['close']} onClick={hide}>
<Icon className={styles['icon']} name={'close'} />
</Button>
</div>
</Transition>
</div>
);
};

export default UpdaterBanner;
2 changes: 2 additions & 0 deletions src/App/UpdaterBanner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import UpdaterBanner from './UpdaterBanner';
export default UpdaterBanner;
8 changes: 8 additions & 0 deletions src/App/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ html {
}
}

.updater-banner-container {
z-index: 1;
position: absolute;
left: 0;
right: 0;
bottom: 0;
}

.router {
width: 100%;
height: 100%;
Expand Down
2 changes: 1 addition & 1 deletion src/common/Platform/Platform.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { createContext, useContext } from 'react';
import { WHITELISTED_HOSTS } from 'stremio/common/CONSTANTS';
import useShell from './useShell';
import useShell from 'stremio/common/useShell';
import { name, isMobile } from './device';

interface PlatformContext {
Expand Down
13 changes: 13 additions & 0 deletions src/common/animations.less
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@
transform: translateX(100%);
}

.slide-up-enter {
transform: translateY(100%);
}

.slide-up-active {
transform: translateY(0%);
transition: transform 0.3s cubic-bezier(0.32, 0, 0.67, 0);
}

.slide-up-exit {
transform: translateY(100%);
}

@keyframes fade-in-no-motion {
0% {
opacity: 0;
Expand Down
2 changes: 2 additions & 0 deletions src/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const useModelState = require('./useModelState');
const useNotifications = require('./useNotifications');
const useOnScrollToBottom = require('./useOnScrollToBottom');
const useProfile = require('./useProfile');
const { default: useShell } = require('./useShell');
const useStreamingServer = require('./useStreamingServer');
const useTorrent = require('./useTorrent');
const useTranslate = require('./useTranslate');
Expand Down Expand Up @@ -47,6 +48,7 @@ module.exports = {
useNotifications,
useOnScrollToBottom,
useProfile,
useShell,
useStreamingServer,
useTorrent,
useTranslate,
Expand Down
File renamed without changes.

0 comments on commit 8a1b040

Please sign in to comment.