Comments (8)
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.
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.
Bro, totally random but, any idea on how to implement day to day swiping?
from table_calendar.
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.
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.
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.
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.
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)
- How to drag and select range?Is that supported. HOT 1
- The following assertion was thrown building AnimatedContainer(duration: 250ms, Alignment.center, padding: EdgeInsets.zero, bg: BoxDecoration(color: Color(0xff6262d5), borderRadius: BorderRadius.circular(10.0)), margin: EdgeInsets.all(6.0), clipBehavior: Clip.none, dirty, state: _AnimatedContainerState#d3f3a(ticker active, AlignmentGeometryTween(Alignment.center → Alignment.center), padding: EdgeInsetsGeometryTween(EdgeInsets.zero → EdgeInsets.zero), bg: DecorationTween(BoxDecoration(shape: circle) → BoxDecoration(color: Color(0xff6262d5), borderRadius: BorderRadius.circular(10.0))), margin: EdgeInsetsGeometryTween(EdgeInsets.all(6.0) → EdgeInsets.all(6.0)))): 'package:flutter/src/painting/box_decoration.dart': Failed assertion: line 128 pos 12: 'shape != BoxShape.circle || borderRadius == null': is not true. HOT 2
- Please upgrade intl HOT 1
- Is this repo abandoned? Recommended alternatives? HOT 2
- ReorderableDelayedDragStartListener causes changing months not to work HOT 1
- incompatible with flutter_localizations HOT 2
- eventLoader is polling many unnecessary dates during onPageChanged callback HOT 1
- Selected day & backgroud circle HOT 2
- flutter_localizations locks intl version, which conflicts with table_calendar HOT 1
- Weekly Calendar format does not support overlapping of two months HOT 1
- Multiple-month support
- Customizing Date Format When Setting Locale to 'ko_KR' HOT 3
- I'm sorry my phone's been in the background all night
- Vertical time in the calendar
- Focused date behaviour inconsistent if `firstDay` changes HOT 1
- Show last 4 week
- No option for removing cell text localization HOT 1
- Swipe day to another day HOT 1
- update
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from table_calendar.