Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/components/base/pageBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { StyleSheet, View } from "react-native";
import Image from "./image";
import useColors from "@/hooks/useColors";
import Theme from "@/core/theme";
import useBackgroundInsets from "@/hooks/useBackgroundInsets";

function PageBackground() {
const theme = Theme.useTheme();
const background = Theme.useBackground();
const colors = useColors();
const backgroundInsets = useBackgroundInsets();

return (
<>
Expand All @@ -17,6 +19,7 @@ function PageBackground() {
{
backgroundColor:
colors?.pageBackground ?? colors.background,
...backgroundInsets,
},
]}
/>
Expand All @@ -27,6 +30,7 @@ function PageBackground() {
style.wrapper,
{
opacity: background?.opacity ?? 0.6,
...backgroundInsets,
},
]}
blurRadius={background?.blur ?? 20}
Expand Down
16 changes: 16 additions & 0 deletions src/hooks/useBackgroundInsets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useSafeAreaInsets } from "react-native-safe-area-context";

/**
* Hook that returns negative safe area insets for extending backgrounds
* beyond safe area boundaries to cover the entire screen.
*/
export default function useBackgroundInsets() {
const insets = useSafeAreaInsets();

return {
top: -insets.top,
bottom: -insets.bottom,
left: -insets.left,
right: -insets.right,
};
}
16 changes: 14 additions & 2 deletions src/pages/musicDetail/components/background.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import React, { useMemo } from "react";
import { Image, StyleSheet, View } from "react-native";
import { ImgAsset } from "@/constants/assetsConst";
import { useCurrentMusic } from "@/core/trackPlayer";
import useBackgroundInsets from "@/hooks/useBackgroundInsets";

export default function Background() {
const musicItem = useCurrentMusic();
const backgroundInsets = useBackgroundInsets();

const artworkSource = useMemo(() => {
if (!musicItem?.artwork) {
Expand All @@ -22,8 +24,18 @@ export default function Background() {

return (
<>
<View style={style.background} />
<Image style={style.blur} blurRadius={50} source={artworkSource} />
<View style={[
style.background,
backgroundInsets
]} />
<Image
style={[
style.blur,
backgroundInsets
]}
blurRadius={50}
source={artworkSource}
/>
</>
);
}
Expand Down