Skip to content

Commit 651dd1c

Browse files
committed
refactor: extract duplicated footer inner
1 parent 2c6f093 commit 651dd1c

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

packages/core-mobile/app/new/common/components/ScrollScreen.tsx

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -221,41 +221,33 @@ export const ScrollScreen = ({
221221
if (renderFooter) {
222222
const footer = renderFooter()
223223
if (footer) {
224+
const footerInner = (
225+
<View onLayout={onFooterLayout}>
226+
<LinearGradientBottomWrapper>
227+
<Animated.View
228+
style={{
229+
paddingHorizontal: 16,
230+
paddingBottom: insets.bottom + 16
231+
}}>
232+
{footer}
233+
</Animated.View>
234+
</LinearGradientBottomWrapper>
235+
</View>
236+
)
237+
224238
if (shouldAvoidKeyboard) {
225239
return (
226240
<KeyboardStickyView
227241
enabled={!disableStickyFooter}
228242
offset={{
229243
opened: insets.bottom
230244
}}>
231-
<View onLayout={onFooterLayout}>
232-
<LinearGradientBottomWrapper>
233-
<Animated.View
234-
style={{
235-
paddingHorizontal: 16,
236-
paddingBottom: insets.bottom + 16
237-
}}>
238-
{footer}
239-
</Animated.View>
240-
</LinearGradientBottomWrapper>
241-
</View>
245+
{footerInner}
242246
</KeyboardStickyView>
243247
)
244-
} else {
245-
return (
246-
<View onLayout={onFooterLayout}>
247-
<LinearGradientBottomWrapper>
248-
<Animated.View
249-
style={{
250-
paddingHorizontal: 16,
251-
paddingBottom: insets.bottom + 16
252-
}}>
253-
{footer}
254-
</Animated.View>
255-
</LinearGradientBottomWrapper>
256-
</View>
257-
)
258248
}
249+
250+
return footerInner
259251
}
260252
}
261253

0 commit comments

Comments
 (0)