Skip to content

Commit

Permalink
Fix: maskable icon PWA & fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
sawyerf committed Jan 20, 2025
1 parent b4e07d6 commit d1c5dc3
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 100 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ jobs:
run: npm ci
- name: Export Project
run: npm run export:web
- name: Copy icon.png
run: cp ./assets/icon.png ./web-build/pwa/icon.png
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
11 changes: 4 additions & 7 deletions app/components/bar/TabBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import SideBar from '~/components/bar/SideBar';
const TabBar = ({ state, descriptors, navigation }) => {
const config = React.useContext(ConfigContext)
const settings = React.useContext(SettingsContext)
const [isFullScreen, setIsFullScreen] = React.useState(false)

React.useEffect(() => {
if (config.query === null) {
Expand All @@ -20,13 +19,11 @@ const TabBar = ({ state, descriptors, navigation }) => {
return (
<>
{
!isFullScreen ?
settings.isDesktop ?
<SideBar state={state} descriptors={descriptors} navigation={navigation} />
: <BottomBar state={state} descriptors={descriptors} navigation={navigation} />
: null
settings.isDesktop ?
<SideBar state={state} descriptors={descriptors} navigation={navigation} />
: <BottomBar state={state} descriptors={descriptors} navigation={navigation} />
}
<Player state={state} fullscreen={{ value: isFullScreen, set: setIsFullScreen }} />
<Player state={state} />
</>
);
}
Expand Down
6 changes: 3 additions & 3 deletions app/components/player/BoxDesktopPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import FavoritedButton from '~/components/button/FavoritedButton';
import size from '~/styles/size';
import PlayButton from '~/components/button/PlayButton';

const BoxDesktopPlayer = ({ fullscreen }) => {
const BoxDesktopPlayer = ({ setFullScreen }) => {
const song = React.useContext(SongContext)
const songDispatch = React.useContext(SongDispatchContext)
const config = React.useContext(ConfigContext)
Expand All @@ -27,7 +27,7 @@ const BoxDesktopPlayer = ({ fullscreen }) => {
<View
style={styles.container(theme)}>
<Pressable
onPress={() => fullscreen.set(true)}
onPress={() => setFullScreen(true)}
style={{ flexDirection: 'row', flex: 1 }}
>
<ImageError
Expand Down Expand Up @@ -122,7 +122,7 @@ const BoxDesktopPlayer = ({ fullscreen }) => {
size={17}
style={{ padding: 5, paddingHorizontal: 8, marginStart: 15, borderRadius: 4 }}
color={theme.primaryLight}
onPress={() => fullscreen.set(true)}
onPress={() => setFullScreen(true)}
/>
</View>
</View >
Expand Down
4 changes: 2 additions & 2 deletions app/components/player/BoxPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ImageError from '~/components/ImageError';
import size from '~/styles/size';
import useKeyboardIsOpen from '~/utils/useKeyboardIsOpen';

const BoxPlayer = ({ fullscreen }) => {
const BoxPlayer = ({ setFullScreen }) => {
const song = React.useContext(SongContext)
const songDispatch = React.useContext(SongDispatchContext)
const config = React.useContext(ConfigContext)
Expand All @@ -24,7 +24,7 @@ const BoxPlayer = ({ fullscreen }) => {

return (
<Pressable
onPress={() => fullscreen.set(true)}
onPress={() => setFullScreen(true)}
style={{
position: 'absolute',
bottom: (insets.bottom ? insets.bottom : 15) + 53,
Expand Down
6 changes: 3 additions & 3 deletions app/components/player/FullScreenHorizontalPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const color = {
secondary: '#c6c6c6'
}

const FullScreenHorizontalPlayer = ({ fullscreen }) => {
const FullScreenHorizontalPlayer = ({ setFullScreen }) => {
const [isPreview, setIsPreview] = React.useState(preview.COVER)
const config = React.useContext(ConfigContext)
const insets = useSafeAreaInsets()
Expand All @@ -49,7 +49,7 @@ const FullScreenHorizontalPlayer = ({ fullscreen }) => {

return (
<Modal
visible={fullscreen.value}
visible={true}
transparent={true}
>
<Image
Expand Down Expand Up @@ -237,7 +237,7 @@ const FullScreenHorizontalPlayer = ({ fullscreen }) => {
size={17}
style={{ padding: 5, paddingHorizontal: 8, marginStart: 15, borderRadius: 4 }}
color={color.primary}
onPress={() => fullscreen.set(false)}
onPress={() => setFullScreen(false)}
/>
</View>
</View>
Expand Down
6 changes: 3 additions & 3 deletions app/components/player/FullScreenPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const preview = {
LYRICS: 2
}

const FullScreenPlayer = ({ fullscreen }) => {
const FullScreenPlayer = ({ setFullScreen }) => {
const [isPreview, setIsPreview] = React.useState(preview.COVER)
const song = React.useContext(SongContext)
const songDispatch = React.useContext(SongDispatchContext)
Expand All @@ -42,7 +42,7 @@ const FullScreenPlayer = ({ fullscreen }) => {
return (
<Modal
statusBarTranslucent={true}
onRequestClose={() => fullscreen.set(false)}
onRequestClose={() => setFullScreen(false)}
>
<View style={[ mainStyles.contentMainContainer(insets), styles.mainContainer(insets, theme)]}>
<IconButton
Expand All @@ -53,7 +53,7 @@ const FullScreenPlayer = ({ fullscreen }) => {
}}
icon="chevron-down"
color={theme.primaryLight}
onPress={() => fullscreen.set(false)} />
onPress={() => setFullScreen(false)} />
<View style={styles.playerContainer}>
{
isPreview == preview.COVER &&
Expand Down
15 changes: 8 additions & 7 deletions app/components/player/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ import BoxPlayer from '~/components/player/BoxPlayer'
import FullScreenHorizontalPlayer from '~/components/player/FullScreenHorizontalPlayer'
import FullScreenPlayer from '~/components/player/FullScreenPlayer'

const Player = ({ state, fullscreen }) => {
const Player = ({ state }) => {
const song = React.useContext(SongContext)
const settings = React.useContext(SettingsContext)
const { height, width } = useWindowDimensions()
const [fullScreen, setFullScreen] = React.useState(false)

React.useEffect(() => {
fullscreen.set(false)
setFullScreen(false)
}, [state.index])

if (!song?.songInfo) return null
else if (fullscreen.value) {
if (width <= height) return <FullScreenPlayer fullscreen={fullscreen} />
else return <FullScreenHorizontalPlayer fullscreen={fullscreen} />
else if (fullScreen) {
if (width <= height) return <FullScreenPlayer setFullScreen={setFullScreen} />
else return <FullScreenHorizontalPlayer setFullScreen={setFullScreen} />
}
else if (settings.isDesktop) return <BoxDesktopPlayer fullscreen={fullscreen} />
return <BoxPlayer fullscreen={fullscreen} />
else if (settings.isDesktop) return <BoxDesktopPlayer setFullScreen={setFullScreen} />
return <BoxPlayer setFullScreen={setFullScreen} />
}

export default Player
Binary file added assets/adaptative-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 41 additions & 45 deletions assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 6 additions & 28 deletions web/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,21 @@
"lang": "en",
"display": "standalone",
"orientation": "portrait",
"background_color": "#121212",
"background_color": "#660000",
"theme_color": "#121212",
"start_url": "./index.html",
"icons": [
{
"src": "./pwa/icon.png",
"sizes": "1024x1024",
"type": "image/png",
"src": "./pwa/icon.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "any"
},
{
"src": "./pwa/icon.png",
"src": "./pwa/adaptative-icon.png",
"sizes": "1024x1024",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "./pwa/apple-touch-icon/apple-touch-icon-180.png",
"sizes": "180x180",
"type": "image/png",
"purpose": "any"
},
{
"src": "./pwa/apple-touch-icon/apple-touch-icon-180.png",
"sizes": "180x180",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "./favicon-32.png",
"sizes": "32x32",
"type": "image/png"
},
{
"src": "./favicon-16.png",
"sizes": "16x16",
"type": "image/png"
}
]
}
}
16 changes: 16 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const createExpoWebpackConfigAsync = require("@expo/webpack-config");
const path = require("path");
const WorkboxWebpackPlugin = require("workbox-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');

module.exports = async function (env, argv) {
Expand All @@ -26,6 +27,21 @@ module.exports = async function (env, argv) {
})
);

config.plugins.push(
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, "assets/icon.svg"),
to: path.resolve(__dirname, "web-build/pwa/icon.svg"),
},
{
from: path.resolve(__dirname, "assets/adaptative-icon.png"),
to: path.resolve(__dirname, "web-build/pwa/adaptative-icon.png"),
},
],
}),
)

// Uncomment to analyze bundle size
// config.plugins.push(
// new BundleAnalyzerPlugin({
Expand Down

0 comments on commit d1c5dc3

Please sign in to comment.