Git Product home page Git Product logo

flexiblecalendar's Introduction

FlexibleCalendar

================= Quality Gate Status .github/workflows/main.yml

Introduction

A customizable calendar with customizable events.

Source

The code in this repository was inspired from p-v/FlexibleCalendar - v1.2.1. We are very thankful to p-v.

Screenshot

screenshot

Installation

In order to use the library, add the following line to your root gradle file:

I) For using FlexibleCalendar module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.

dependencies {
        implementation project(':flexiblecalendar')
        implementation fileTree(dir: 'libs', include: ['*.har'])
        testImplementation 'junit:junit:4.13'
}

II) For using FlexibleCalendar in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.

dependencies {
        implementation fileTree(dir: 'libs', include: ['*.har'])
        testImplementation 'junit:junit:4.12'
}

III) For using FlexibleCalendar from a remote repository in separate application, add the below dependencies in entry/build.gradle file.

dependencies {
        implementation 'dev.applibgroup:flexiblecalendar:1.0.0'
        testImplementation 'junit:junit:4.13'
        ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
}

Usage

I). Add FlexiCalendar in layout:

<com.pv.flexiblecalendar.FlexibleCalendarView
        ohos:id="$+id:calendar_view"
        ohos:width="match_parent"
        ohos:height="match_content"
        />

II). Usage in java - Customize FlexibleCalendar using the CalendarView interface:

FlexibleCalendarView calendarView = (FlexibleCalendarView) findComponentById(ResourceTable.Id_calendar_view);
        view.setCalendarView(new FlexibleCalendarView.CalendarView() {

            @Override
            public BaseCellView getCellView(final int position, final Component convertView,
                                            final ComponentContainer parent, final int cellType) {
                BaseCellView cellView = null;

                if (convertView != null) {
                    cellView = (BaseCellView) convertView;
                }
                if (cellView == null) {
                    cellView = (BaseCellView) LayoutBoost.inflate(CalendarActivity5.this,
                            ResourceTable.Layout_calendar5_date_cell_view, null, false);
                }
                return cellView;
            }

            @Override
            public BaseCellView getWeekdayCellView(final int position, final Component convertView,
                                                   final ComponentContainer parent) {
                return null;
            }

            @Override
            public String getDayOfWeekDisplayValue(final int dayOfWeek, final String defaultValue) {
                return null;
            }
        });

III) Display events for a day using the EventDataProvider

 calendarView.setEventDataProvider(new FlexibleCalendarView.EventDataProvider() {
     @Override
     public List<? extends Event> getEventsForTheDay(int year, int month, int day) {
         return getEventColorList(year,month,day);
     }
 });
`

IV) Track the month change event by setting the OnMonthChangeListener

calendarView.setOnMonthChangeListener(new FlexibleCalendarView.OnMonthChangeListener() {
    @Override
    public void onMonthChange(int year, int month, int direction) {
        //do things on month change
    }
});

Customizations:

Customize the cells and events by extending the class BaseCellView.

Existing cells include CircularEventCellView, SquareCellView and EventCountCellView.

Set go to current month from any month in the calendar using FlexibleCalendarView#goToCurrentMonth method

Set go to previous month from any month in the calendar using FlexibleCalendarView#moveToPreviousMonth method

Set go to next month from any month in the calendar using FlexibleCalendarView#moveToNextMonth method

Set the first day of the week using FlexibleCalendarView#setStartDayOfTheWeek method

Staty day as Monday   Start_day_as_Sunday

Support and extension

Currently there is a limitation to

  1. set cell views background using selectors
  2. onclick button actions for calendar 1 will be supported in next release

flexiblecalendar's People

Contributors

applibengineering avatar sreeni-hmos avatar veejay-ks avatar

Stargazers

 avatar

Watchers

 avatar

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.