@@ -17,14 +17,17 @@ const SIGNET = require('./signet.png');
1717const TEXT = require ( './text.png' ) ;
1818
1919export const HEADER_HEIGHT =
20- Platform . OS === 'web' ? 64 : Platform . OS === 'macos' ? 128 : 192 ;
20+ Platform . OS === 'web' || Platform . OS === 'macos' ? 64 : 192 ;
2121export const COLLAPSED_HEADER_HEIGHT = 64 ;
2222
2323export interface HeaderProps {
2424 scrollOffset : SharedValue < number > ;
2525}
2626
2727export default function Header ( props : HeaderProps ) {
28+ if ( Platform . OS === 'macos' ) {
29+ return < HeaderMacOS { ...props } /> ;
30+ }
2831 if ( Platform . OS === 'web' ) {
2932 return < HeaderWeb { ...props } /> ;
3033 }
@@ -58,9 +61,7 @@ function HeaderNative(props: HeaderProps) {
5861 } ) ;
5962
6063 const collapsedCoefficient = 0.7 ;
61- const openCoefficient = Platform . OS === 'macos' ? 1 : 0.5 ;
62- const padding = Platform . OS === 'macos' ? 10 : 0 ;
63- const horizontalOffset = Platform . OS === 'macos' ? 50 : 0 ;
64+ const openCoefficient = 0.5 ;
6465
6566 const signetStyle = useAnimatedStyle ( ( ) => {
6667 const size = isMounted . value ? measure ( containerRef ) : undefined ;
@@ -69,20 +70,16 @@ function HeaderNative(props: HeaderProps) {
6970 [ 0 , 1 ] ,
7071 [
7172 headerHeight . value * collapsedCoefficient ,
72- headerHeight . value * openCoefficient - padding ,
73+ headerHeight . value * openCoefficient ,
7374 ]
7475 ) ;
7576 const clampedHeight = Math . min ( headerHeight . value , HEADER_HEIGHT ) ;
7677
77- const signetOpenOffsetCoefficient = Platform . OS === 'macos' ? 0.32 : 0.5 ;
78- const signetOpenOffsetBias =
79- Platform . OS === 'macos' ? 15 - ( size ?. height ?? 0 ) : 0 ;
78+ const signetOpenOffsetCoefficient = 0.5 ;
8079
8180 const signetCollapsedOffset = COLLAPSED_HEADER_HEIGHT * 0.25 ;
8281 const signetOpenOffset =
83- ( ( size ?. width ?? 0 ) - imageSize ) * signetOpenOffsetCoefficient +
84- signetOpenOffsetBias +
85- horizontalOffset ;
82+ ( ( size ?. width ?? 0 ) - imageSize ) * signetOpenOffsetCoefficient ;
8683
8784 return {
8885 position : 'absolute' ,
@@ -91,7 +88,7 @@ function HeaderNative(props: HeaderProps) {
9188 top : interpolate (
9289 Math . sqrt ( expandFactor . value ) ,
9390 [ 0 , 1 ] ,
94- [ clampedHeight * 0.1 , 0 + padding / 2 ]
91+ [ clampedHeight * 0.1 , 0 ]
9592 ) ,
9693 left : interpolate (
9794 expandFactor . value ,
@@ -110,19 +107,18 @@ function HeaderNative(props: HeaderProps) {
110107 [ 0 , 1 ] ,
111108 [
112109 headerHeight . value * collapsedCoefficient ,
113- headerHeight . value * openCoefficient - padding ,
110+ headerHeight . value * openCoefficient ,
114111 ]
115112 ) ;
116113
117114 const widthCoefficient = 0.2 ;
118- const widthBias = Platform . OS === 'macos' ? 0.2 : 0.4 ;
115+ const widthBias = 0.4 ;
119116
120117 const textWidth =
121118 ( size ?. width ?? 0 ) * ( expandFactor . value * widthCoefficient + widthBias ) ;
122119
123120 const textCollapsedOffset = ( ( size ?. width ?? 0 ) - textWidth ) * 0.5 ;
124- const textOpenOffset =
125- ( ( size ?. width ?? 0 ) - textWidth ) * 0.5 + horizontalOffset ;
121+ const textOpenOffset = ( ( size ?. width ?? 0 ) - textWidth ) * 0.5 ;
126122
127123 return {
128124 position : 'absolute' ,
@@ -131,7 +127,7 @@ function HeaderNative(props: HeaderProps) {
131127 bottom : interpolate (
132128 expandFactor . value ,
133129 [ 0 , 1 ] ,
134- [ COLLAPSED_HEADER_HEIGHT * 0.2 , 0 + padding / 2 ]
130+ [ COLLAPSED_HEADER_HEIGHT * 0.2 , 0 ]
135131 ) ,
136132 left : interpolate (
137133 expandFactor . value ,
@@ -185,6 +181,15 @@ function HeaderWeb(_props: HeaderProps) {
185181 ) ;
186182}
187183
184+ function HeaderMacOS ( _props : HeaderProps ) {
185+ return (
186+ < Animated . View collapsable = { false } style = { styles . webHeader } >
187+ < Animated . Image source = { SIGNET } style = { styles . macosSignet } />
188+ < Animated . Image source = { TEXT } style = { styles . macosText } />
189+ </ Animated . View >
190+ ) ;
191+ }
192+
188193const styles = StyleSheet . create ( {
189194 nativeHeader : {
190195 width : '100%' ,
@@ -211,4 +216,15 @@ const styles = StyleSheet.create({
211216 width : 170 ,
212217 height : 32 ,
213218 } ,
219+ macosSignet : {
220+ // macos stretches the images to fill the available space
221+ width : 31 , // 65:100 ratio applied to 48px
222+ height : 48 ,
223+ marginHorizontal : 8.5 ,
224+ } ,
225+ macosText : {
226+ width : 142 , // 1439:323 ratio applied to 32px
227+ height : 32 ,
228+ marginHorizontal : 14 ,
229+ } ,
214230} ) ;
0 commit comments