GithubHelp home page GithubHelp logo

feilfeilundfeil / event_calendar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rynssnjn/event_calendar

0.0 1.0 0.0 342 KB

License: Other

Kotlin 0.14% Swift 1.34% Objective-C 0.04% Dart 45.66% Ruby 3.12% CMake 21.67% C++ 24.26% C 1.65% HTML 2.11%

event_calendar's Introduction

event_calendar

A package that displays a calendar with multiple events.

Screen Recording 2022-09-10 at 10 10 55 PM

Installation

dependencies:
    event_calendar: 0.1.1

dependency_overrides:
    event_calendar:
        git: https://github.com/rynssnjn/event_calendar.git

Usage

Initializing an event. The [EventModel] requires a [String] for the title and a [DateTime] for both startDate and endDate. It can also accept an optional value for a [VoidCallback] onSelect that is triggered when the event is tapped as well as optional value for [TextStyle] and [Color] for customizing the UI of the event.

EventModel(
    title: 'Meeting 1',
    startDate: DateTime(2022, 9, 2),
    endDate: DateTime(2022, 9, 10),
    backgroundColor: const Color(0xff31C987),
)

Displaying the calendar with events. Calling [EventCalendar] makes you display the calendar with events. It has a required property called holder wherein you can customize the user interface of the weekdays via [CalendarHolder], weekends and the months. It accepts a list of [EventModel] to show the events on the calendar itself.

EventCalendar(
    holder: CalendarHolder(),
    calendarSize: MediaQuery.of(context).size,
    events: events,
    divisor: 2,
    dateBorderColor: Colors.black,
)

Example

import 'package:event_calendar/event_calendar.dart';
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    final events = [
      EventModel(
        title: 'Meeting 1',
        startDate: DateTime(2022, 9, 2),
        endDate: DateTime(2022, 9, 10),
        backgroundColor: const Color(0xff31C987),
      ),
      EventModel(
        title: 'Meeting 2',
        startDate: DateTime(2022, 11, 1),
        endDate: DateTime(2022, 12, 5),
        backgroundColor: const Color(0xff31C987),
      ),
      EventModel(
        title: 'Meeting 3',
        startDate: DateTime(2022, 12, 3),
        endDate: DateTime(2022, 12, 09),
        backgroundColor: const Color(0xff892486),
      ),
      EventModel(
        title: 'Meeting 4',
        startDate: DateTime(2022, 12, 09),
        endDate: DateTime(2022, 12, 12),
        backgroundColor: const Color(0xff892486),
      ),
      EventModel(
        title: 'Meeting 5',
        startDate: DateTime(2022, 12, 12),
        endDate: DateTime(2022, 12, 12),
        backgroundColor: const Color(0xff892486),
      ),
      EventModel(
        title: 'Meeting 6',
        startDate: DateTime(2022, 12, 12),
        endDate: DateTime(2022, 12, 15),
        backgroundColor: const Color(0xff31C987),
      ),
      EventModel(
        title: 'Meeting 7',
        startDate: DateTime(2022, 12, 6),
        endDate: DateTime(2022, 12, 7),
        backgroundColor: const Color(0xff892486),
      ),
      EventModel(
        title: 'Meeting 8',
        startDate: DateTime(2022, 12, 12),
        endDate: DateTime(2022, 12, 12),
        backgroundColor: const Color(0xff31C987),
      ),
      EventModel(
        title: 'Meeting 9',
        startDate: DateTime(2022, 12, 12),
        endDate: DateTime(2022, 12, 12),
        backgroundColor: const Color(0xff31C987),
      ),
      EventModel(
        title: 'Meeting 10',
        startDate: DateTime(2022, 12, 13),
        endDate: DateTime(2022, 12, 18),
        backgroundColor: const Color(0xff31C987),
      ),
      EventModel(
        title: 'Meeting 11',
        startDate: DateTime(2022, 12, 15),
        endDate: DateTime(2022, 12, 22),
        backgroundColor: const Color(0xff892486),
      ),
      EventModel(
        title: 'Meeting 12',
        startDate: DateTime(2022, 12, 21),
        endDate: DateTime(2022, 12, 24),
        backgroundColor: const Color(0xff31C987),
      ),
      EventModel(
        title: 'Meeting 13',
        startDate: DateTime(2022, 12, 10),
        endDate: DateTime(2022, 12, 10),
        backgroundColor: const Color(0xff31C987),
      ),
      EventModel(
        title: 'Meeting 14',
        startDate: DateTime(2022, 12, 8),
        endDate: DateTime(2022, 12, 10),
        backgroundColor: const Color(0xff31C987),
      ),
      EventModel(
        title: 'Rael birthday',
        startDate: DateTime(2021, 04, 23),
        endDate: DateTime(2021, 04, 23),
        backgroundColor: const Color(0xff31C987),
      ),
    ];
    return Scaffold(
      appBar: AppBar(
        title: const Text('Test Calendar'),
        backgroundColor: const Color(0xff509D56),
      ),
      body: EventCalendar(
        holder: CalendarHolder(),
        calendarSize: MediaQuery.of(context).size,
        events: events,
        divisor: 2,
        dateBorderColor: Colors.black,
      ),
    );
  }
}

event_calendar's People

Contributors

ffuf-calingasan avatar raeeel avatar raelsj avatar rynssnjn 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.