Coder Social home page Coder Social logo

santoshgistto / dashboard Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mehmetyaz/dashboard

0.0 0.0 0.0 3.62 MB

Dynamic dashboard widget that allows your users to create their own layouts. Rezise, move, indirect resize/move, auto re-layout are supported.

Home Page: https://pub.dev/packages/dashboard

License: Apache License 2.0

Objective-C 0.02% Java 0.08% Dart 96.71% Swift 0.22% HTML 2.18% Ruby 0.78%

dashboard's Introduction

Dynamic dashboard widget that allows your users to create their own layouts. Rezise, move, indirect resize/move, auto re-layout are supported.

Features

Try online demo

Dashboard can be thought of as a dynamic grid. Your users can create their own layouts, add new widgets or remove widgets.

Layout divides the screen into horizontal slots according to the entered value. The aspect ratio of the slots also determine their height. Widgets called DashboardItem are placed in these slots. This layout can be changed later.

Resize

Dashboard Items can be resized both by long pressing on mobile and by holding and moving on desktop/browser.

Move

Dashboard Item locations can be changed by long pressing on mobile or by holding and pulling on desktop/browser.

Slots Changes

With dynamic slot count, you can re-layout window size changes.

>

Storage Delegate

The layout information of the users can be stored in the database or on the local disk.

Define your storage delegate.

class MyItemStorage extends DashboardItemStorageDelegate {  

  @override  
  FutureOr<List<DashboardItem>> getAllItems(int slotCount) {  
    // return items from db.
  }  
  
  @override  
  FutureOr<void> onItemsUpdated(  
      List<DashboardItem> items, int slotCount) {
      // save new layouts to db.
  }
  //[...]
}

And use it.

DashboardItemController.withDelegate(
    itemStorageDelegate: MyItemsStorage())

Getting started

Define Dashboard

Dashboard(  
  dashboardItemController: itemController,  
  itemBuilder: (item) {
	//return widget
  },  
);

Define Items

Items can come from the database, or can be defined as fixed.

Fixed:

DashboardItemController(items: [
  DashboardItem(width: 2, height: 3, identifier: "id_1"),  
  DashboardItem(  
      startX: 3, startY: 4, width: 3, height: 1, identifier: "id_2"),  
]);

Or with delegate:

DashboardItemController<ADashboardItemImp>.withDelegate(  
    itemStorageDelegate: MyItemStorage())

See example

Define Builder

The Builder is invoked with a DashboardItem and returns a widget.

Dashboard(  
  dashboardItemController: itemController,  
  itemBuilder: (item) {
	return Text(item.identifier);
  },  
);

Parameters

Item Style

Each item is wrapped with a Material widget. You can enter the parameters of the Material widget with item style.

All is optional.

ItemStyle(  
  color: Colors.red,  
  borderRadius: BorderRadius.circular(10),  
  shape: const RoundedRectangleBorder(),  
  shadowColor: Colors.black,  
  animationDuration: const Duration(milliseconds: 200),  
  borderOnForeground: false,  
  clipBehavior: Clip.antiAliasWithSaveLayer,  
  elevation: 10,  
  textStyle: const TextStyle(color: Colors.black),  
  type: MaterialType.card  
);

Slide

Slide to top items initially. Auto relayout places items to top as possible.

slideToTop: true

Before:

>

After:

>

Shrink

Shrink items when re-layout or editing is possible.

Edit Mode Settings

See code comments for edit mode settings parameters.

All is optional.

    EditModeSettings(

        // animation settings
        curve: Curves.easeInOutCirc,
        duration: const Duration(milliseconds: 200),
        
        // fill editing item actual size
        fillEditingBackground: true,

        // space that can be held to resize
        resizeCursorSide: 20,
        
        // draw lines for slots
        paintBackgroundLines: true,
        
        // shrink items when editing if possible and necessary
        shrinkOnMove: true,
        
        // long press to edit
        longPressEnabled: true,
        
        // pan to edit
        panEnabled: true,
        
        backgroundStyle: const EditModeBackgroundStyle(
            fillColor: Colors.red,
            lineWidth: 1.5,
            lineColor: Colors.black,
            
            // line by vertical space
            dualLineHorizontal: true,

            // line by horizontal space
            dualLineVertical: true));

Storage Delegate

See example

Additional

"Buy Me A Coffee"

TODO

  • Define and fix animation bugs.
  • Check performance improvements.
  • Write tests.
  • Add more documentation.
  • Add more example.
  • Create Youtube video.

dashboard's People

Contributors

mehmetyaz avatar mennovanhout avatar rohanjariwala03 avatar kengu avatar auerth avatar yazmehmet 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.