react-native-keyboard-aware-scroll-view icon indicating copy to clipboard operation
react-native-keyboard-aware-scroll-view copied to clipboard

Support for sticky headers

Open fodjan-philip opened this issue 7 years ago • 18 comments

Whenever I'm trying to use KeyboardAwareScrollView with stickyHeaderIndices or KeyboardAwareSectionList with stickySectionHeadersEnabled, I get the following error:

couldn't find key offset in dynamic object

  • getDouble (ReadableNativeMap.java)

  • init (ValueAnimatedNode.java:31)

  • createAnimatedNode (NativeAnimatedNodesManager.java:91)

  • execute (NativeAnimatedModule.java:204)

  • ...

Everything works as expected with React Native's SectionList and ScrollView. Am I missing something or is it currently not possible to use sticky headers with this library?

fodjan-philip avatar Jun 26 '18 14:06 fodjan-philip

+1

tandat2209 avatar Jul 17 '18 02:07 tandat2209

Update. This happens on Android only

tandat2209 avatar Jul 17 '18 03:07 tandat2209

+1

realcjames avatar Jul 24 '18 07:07 realcjames

+1

murtraja avatar Oct 01 '18 07:10 murtraja

Same issue

ThienMD avatar Nov 07 '18 03:11 ThienMD

I had the same issue. As I read in the documentation of react-native-keyboard-aware-scroll-view:

First, Android natively has this feature, you can easily enable it by setting windowSoftInputMode in AndroidManifest.xml. Check here.

Since I did not use features such as extraHeight, I used KeyboardAwareSectionList on iOS only and simply imported SectionList on Android.

pavelaron avatar Dec 27 '18 01:12 pavelaron

+1

SaltySammy avatar Jan 05 '19 16:01 SaltySammy

+1

bearwmceo avatar May 06 '19 13:05 bearwmceo

+1

Manouli avatar Oct 13 '19 17:10 Manouli

Silently failing on iOS for me - trying to get a header/footer that remains on top of the keyboard despite the scroll, while maintaining "scroll to input" ability.

dancherb avatar Oct 29 '19 06:10 dancherb

+1

franciscailleAstus avatar Nov 13 '19 00:11 franciscailleAstus

give up

zjjjjjjjjjjd avatar Apr 10 '20 07:04 zjjjjjjjjjjd

give up

Can confirm this solution worked for me

dancherb avatar Apr 10 '20 07:04 dancherb

+1

salmandayal avatar May 30 '21 20:05 salmandayal

Here is the solution You need to determine your sticky header and pass it as a prop inside For example I'm using my custom Container component with sticky header view:

 <KeyboardAwareScrollView
          bounces={false}
          enableOnAndroid
          nestedScrollEnabled={true}
          removeClippedSubviews={false}
          scrollEnabled={scrollEnabled}
          keyboardShouldPersistTaps={keyboardShouldPersistTaps}
          enableResetScrollToCoords={enableResetScrollToCoords}
          showsVerticalScrollIndicator={showsVerticalScrollIndicator}
          stickyHeaderIndices={StickyHeaderComponent ? [0] : undefined}> // here I'm telling that if I'll have some component - display it
          {StickyHeaderComponent ? StickyHeaderComponent : null} // and before all children's will be displayed - I just displaying my sticky header. And as it's the first children - it would be selected as this header. 

Inside my place of use:

  <Container
      withSafeArea
      StickyHeaderComponent={<RenderHeader />}>

arbuzaicer avatar Aug 02 '21 09:08 arbuzaicer

Hi everyone, my solution like that

<View style={[{position:'absolute',top:positionTop,zIndex:100,right:0,left:0,height:50},Common.backgroundLight]}> // wrap header view

useEffect(() => { Keyboard.addListener('keyboardDidShow',()=>{ console.log('quillFocus',quillFocus); if(Platform.OS === "android"){ if(quillFocus){ setPositionTop(hp(40)) } } }) if(!quillFocus){ if(positionTop === hp(40)){ LayoutAnimation.configureNext({ duration: 100, create: { type: "linear", property: "opacity" }, update: { type: "linear", property: "opacity" }, delete: { type: "linear", property: "opacity" } }); setPositionTop(0) } }

return () => {
  // Keyboard.removeAllListeners()
}

}, [quillFocus])

congduong97 avatar Oct 07 '22 13:10 congduong97

Hi everyone, my solution like that

<View style={[{position:'absolute',top:positionTop,zIndex:100,right:0,left:0,height:50},Common.backgroundLight]}> // wrap header view

useEffect(() => { Keyboard.addListener('keyboardDidShow',()=>{ console.log('quillFocus',quillFocus); if(Platform.OS === "android"){ if(quillFocus){ setPositionTop(hp(40)) } } }) if(!quillFocus){ if(positionTop === hp(40)){ LayoutAnimation.configureNext({ duration: 100, create: { type: "linear", property: "opacity" }, update: { type: "linear", property: "opacity" }, delete: { type: "linear", property: "opacity" } }); setPositionTop(0) } }

return () => {
  // Keyboard.removeAllListeners()
}

}, [quillFocus])

is not clear how to use your useEffect, what is hp? positionTop? quillFocus?

hotaryuzaki avatar Dec 14 '22 03:12 hotaryuzaki

Hi everyone, my solution like that <View style={[{position:'absolute',top:positionTop,zIndex:100,right:0,left:0,height:50},Common.backgroundLight]}> // wrap header view useEffect(() => { Keyboard.addListener('keyboardDidShow',()=>{ console.log('quillFocus',quillFocus); if(Platform.OS === "android"){ if(quillFocus){ setPositionTop(hp(40)) } } }) if(!quillFocus){ if(positionTop === hp(40)){ LayoutAnimation.configureNext({ duration: 100, create: { type: "linear", property: "opacity" }, update: { type: "linear", property: "opacity" }, delete: { type: "linear", property: "opacity" } }); setPositionTop(0) } }

return () => {
  // Keyboard.removeAllListeners()
}

}, [quillFocus])

is not clear how to use your useEffect, what is hp? positionTop? quillFocus?

i worked with quill editor. you can refer below explain

import { widthPercentageToDP as wp, heightPercentageToDP as hp, } from 'react-native-responsive-screen' ........ <View style={[ { position: 'absolute', top: positionTop, zIndex: 100, right: 0, left: 0, height: 50, }, ]} > {renderHeader()} </View> .........

            <QuillEditor
              style={styles.editor}
              ref={_editor}
              onBlur={() => {
                setQuillFocus(false)
              }}
              onFocus={() => {
                setQuillFocus(true)
                outerScrollRef.current.scrollTo({
                  x: 0,
                  y: Dimensions.get('window').height / 3,
                  animated: true,
                })
              }}
      
              quill={{
                // not required just for to show how to pass this props
                placeholder: '',
                modules: {
                  toolbar: false, // this is default value
                },
                theme: 'snow', // this is default value
              }}
              webview={{
                scrollEnabled: false,
                nestedScrollEnabled: false,
              }}
            />

congduong97 avatar Dec 14 '22 09:12 congduong97