Git Product home page Git Product logo

Comments (11)

maggialejandro avatar maggialejandro commented on July 28, 2024 1

Yeah, sounds good. do you want to create a PR for that?

from react-native-calendario.

mvolonnino avatar mvolonnino commented on July 28, 2024 1

@maggialejandro - Let me know if I did everything correct, this is my first time doing anything for open source! I appreciate you responding and helping me out these past couple days 🙌

from react-native-calendario.

mvolonnino avatar mvolonnino commented on July 28, 2024

*edit

Some further testing - looks like if the startDate is 1 month or ahead of the current date today, the render issue happens above.

So when i select just the date Nov 5th, the render issue does not happen, but if select the startDate to be Nov 6h, the render issue does happen

from react-native-calendario.

maggialejandro avatar maggialejandro commented on July 28, 2024

Hi @mvolonnino
could you please share a reproducible example? that would really help debugging the issue

from react-native-calendario.

mvolonnino avatar mvolonnino commented on July 28, 2024

Yes! so here is actually how im utilizing it and think i found one of the issues:

so my Calendar component looks like this:

return (
    <View>
      <CalendarIcon onPress={() => calendarRef.current?.present()} />
      <BottomSheetModal
        ref={calendarRef}
        footerComponent={renderFooter}
        snapPoints={['65%', '90%']}
        title="Select Dates"
      >
        <BottomSheetFlatList // * BottomSheetFlatList needed for Android scroll support
          data={[{ id: 'calendar' }]}
          contentContainerStyle={{ paddingBottom: 130 }}
          style={{ backgroundColor: colors.background }}
          renderItem={() => (
            <Calendar
              key={dark.toString()} // force rerender on theme change
              startingMonth={new Date().toISOString()}
              viewableRangeOffset={5}
              startDate={selectedDates.startDate}
              endDate={selectedDates.endDate}
              minDate={new Date()}
              monthHeight={MONTH_HEIGHT}
              numberOfMonths={13}
              onPress={selectDates}
              theme={getCalendarTheme(colors)}
              disableOffsetDays
            />
          )}
          keyExtractor={item => item.id}
        />
      </BottomSheetModal>
    </View>
  );

So to be able to actually scroll within a BottomSheetModal from gorham on Android, you need to either have it inside a FlatList from react-native-gesture-handler or its BottomSheetFlatList component. This gives gesture support to the bottom sheet, while also being able to scroll within the flatlist.

Looks like when i remove it from the BottomSheetFlatList, the calendar opens up to the month that has the startDate selected, and scrolling up shows the current month (in this case Oct).

This breaks the gesture support within the BottomSheetModal though, and I cannot scroll at all on Android device through the Calendar, instead, the gesture is captured only by the BottomSheetModal.

So looks like by implementing the workaround for Android to get scrolling of the months possible in the bottom sheet, this render issue happens

@maggialejandro - sorry, i've also never done a 'reproducible example' before, is there something else you need me to do?

from react-native-calendario.

maggialejandro avatar maggialejandro commented on July 28, 2024

I couldn't reproduce the bug
check this branch

Simulator.Screen.Recording.-.iPhone.14.-.2023-10-08.at.20.14.13.mp4

from react-native-calendario.

mvolonnino avatar mvolonnino commented on July 28, 2024

mhm, in your code it doesn't look like the Calendar component wrapped within a BottomSheetFlatList as well. Im curious, are you able to scroll through the calendar on an Android device? The issue I have is that the scrolling does not pass through to the Calendar component while its wrapped in that BottomSheetModal.

Need that type of setup for the Gorham Bottom Sheet to be able to scroll within the Calendar component on Android. iOS worked without doing needing that workaround

Im wondering if there could be a prop passed to the Calendar component that would always have it open to the startingMonth prop or something like that

from react-native-calendario.

maggialejandro avatar maggialejandro commented on July 28, 2024

I see, it seems to be a @gorhom/bottom-sheet issue on Android.
It makes sense that if you add a scrollable component the calendar won't scroll to the correct month.

You could fork this library and replace Calendar's FlatList with gorhom's BottomSheetFlatList instead

from react-native-calendario.

mvolonnino avatar mvolonnino commented on July 28, 2024

I just tried and tested with the BottomSheetFlatList component, the performance takes a bit of a hit when just plugging that in.

I think a pretty simple and easy fix/workaround could be just exposing the initialScrollIndex that can override if one is passed in

      initialScrollIndex={
        props.initialScrollIndex ?? !isWeb && !calculateMonthHeightDynamically ? firstMonthIndex : 0
      }

when commenting out that line in Calendar.tsx line 286, the render issue is gone, and performance stays the same when testing on iOS and Android device.

This way, the Calendar can still be used within a BottomSheetFlatList in how I have it implemented above, with passing initialScrollIndex={0} and startingMonth in conjunction to have it open to the starting month everytime and not worry about scrolling to the selected date.

Do you think that is a valid fix for this specific issue im running into?

from react-native-calendario.

maggialejandro avatar maggialejandro commented on July 28, 2024

awesome, thank you!

from react-native-calendario.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.