Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to display month at top of the calendar? #35

Open
YogeshLegendkiller opened this issue Jun 7, 2020 · 2 comments
Open

How to display month at top of the calendar? #35

YogeshLegendkiller opened this issue Jun 7, 2020 · 2 comments

Comments

@YogeshLegendkiller
Copy link

How to display the current month with forward and backward like other library ?

@chitgoks
Copy link

doesnt look like this is possible. but an added feature would be nice and an option to hide or show this.

@izik461
Copy link

izik461 commented Jun 22, 2020

I've simply added a text above the calendar and I'm observing the onPageSelected.
Hope it helps @YogeshLegendkiller:

class CreateLessonFormView extends StatefulWidget {
  @override
  _CreateLessonFormViewState createState() => _CreateLessonFormViewState();
}

class _CreateLessonFormViewState extends State<CreateLessonFormView> {
  final _lessonFormKey = GlobalKey<FormState>();
  
  List<DateTime> _selectedDates;
  String visibleDateString;

  void _updateMonthLabelFromVisibleDate(DateTime visibleDate) {
    DateFormat dateFormat = DateFormat.yMMMM();
    visibleDateString = dateFormat.format(visibleDate);
  }

  @override
  Widget build(BuildContext context) {
    var startDate = DateUtils.getFirstDayOfCurrentMonth();
    var endDate = DateUtils.getLastDayOfMonth(DateUtils.addMonths(startDate, 12));
    User user = Provider.of<User>(context);

    if (visibleDateString?.isEmpty ?? true) {
      _updateMonthLabelFromVisibleDate(startDate);
    }

    return Form(
      key: _lessonFormKey,
      child: Column(
        children: <Widget>[
          Calendarro(
              startDate: startDate,
              endDate: endDate,
              displayMode: DisplayMode.MONTHS,
              selectionMode: SelectionMode.MULTI,
              weekdayLabelsRow: Text(visibleDateString ?? ''),
              onPageSelected: (pageStartDate, pageEndDate) {
                setState(() {
                  _updateMonthLabelFromVisibleDate(pageStartDate);
                });
              }),
        ],
      ),
    );
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants