GithubHelp home page GithubHelp logo

Comments (8)

Somtobro avatar Somtobro commented on June 4, 2024 1

Thanks guys I've fixed it. I came up with a very brilliant solution.
I wrapped the body around a Swipe widget and I used the flutters add and subtract to go back and forth to the next or previous (changing selected and focused days) day that handles it perfectly as it checks if the the next day exists and if it's the last day of the year it goes to the new year as well.
Thanks once more

from table_calendar.

xxwag avatar xxwag commented on June 4, 2024

Sorry i found this and it solves that
#199

, but id still like to ask whether the Calendar Table shouldnt be ready to emit onhandleupdate behaviour for multiple daycell selection or am i wrong? I have to hard code something like this to retrieve the daycell positions and its annoying. Also the usage of the range selection is pretty unclear from my POV.

DateTime _calculateDateFromGesture(Offset localPosition) {
final RenderBox? box =
_calendarKey.currentContext?.findRenderObject() as RenderBox?;
if (box != null) {
double cellWidth = box.size.width / 7;
double rowHeight = _getRowHeight();

  int column = (localPosition.dx / cellWidth).floor();
  int row = (localPosition.dy / rowHeight).floor();

  DateTime firstVisibleDay =
      _focusedDay.subtract(Duration(days: _focusedDay.weekday - 1));
  DateTime calculatedDate =
      firstVisibleDay.add(Duration(days: row * 7 + column));

  print("First Visible Day: $firstVisibleDay");
  print("Calculated Date: $calculatedDate");

  return calculatedDate;
}
return _focusedDay; // Fallback if box is not found

}

from table_calendar.

Somtobro avatar Somtobro commented on June 4, 2024

Bro, totally random but, any idea on how to implement day to day swiping?

from table_calendar.

xxwag avatar xxwag commented on June 4, 2024

Yes, so you need to create an handlepan function or similar and call it from the table calendar gesture detector to interact with the whole table. Not sure if thats what you looking for.

from table_calendar.

Somtobro avatar Somtobro commented on June 4, 2024

Yeah, that's what I'm looking for .
But there's no built bin function to call next day.
For example:
If I'm on the last day of the month eg 30th of April.
Swiping again would go to 31 and then 32.
Do you understand what I'm tryna say?

from table_calendar.

xxwag avatar xxwag commented on June 4, 2024

Try the simpleSwipeConfig = const SimpleSwipeConfig(
verticalThreshold: 25.0,
swipeDetectionBehavior: SwipeDetectionBehavior.continuousDistinct,
),

By now you should already have something like an focused day datetime and you initialize it using date.now right? 

Swipe config would iterate based on the direction, increment the focused day and change its state to represent the change. 

from table_calendar.

Somtobro avatar Somtobro commented on June 4, 2024

Yeah I've figured it out.
The only problem now Is I can't select too far forward or behind.
For example
Currently I can't scroll past August 1st
Today is May 1st

from table_calendar.

xxwag avatar xxwag commented on June 4, 2024

Im doing this to calculate the surrounding days and fill the exit voids, maybe you can use this substract in combination with focused month +-1 to fill the available dates to get swiped on.

  DateTime firstDayOfMonth = DateTime(_focusedDay.year, _focusedDay.month, 1);
    int daysToSubtract = (firstDayOfMonth.weekday - 1) % 7;
    DateTime firstVisibleDay =
        firstDayOfMonth.subtract(Duration(days: daysToSubtract));

    DateTime calculatedDate =
        firstVisibleDay.add(Duration(days: row * 7 + column));

from table_calendar.

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.