Coder Social home page Coder Social logo

gitsunmin / dot_controller Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4.24 MB

flutter library dot controller

License: MIT License

Dart 19.31% Kotlin 0.21% Swift 2.93% Objective-C 0.06% CMake 32.90% C++ 39.05% C 2.41% HTML 3.12%
dart flutter library

dot_controller's Introduction

dot_controller

logo

dot_controller is a Controller, Navigator, and Selector.

You can run a function by simply moving Dot. You can also change the color and icon of Dot.

Usage

1. Define Your Dot

you have to create a "Dot" that can move at a point on the screen.

Scaffold(
  ...,
  body: Stack(
    children: [
      YourWidget(),
      DotController(  // <-- this is your Dot
        actions: [],
      )
    ],
  ),
);
    

2. Add Your Action

You have to declare "Action," the destination of "Dot."

Scaffold(
  ...,
  body: Stack(
    children: [
      YourWidget(),
      DotController(  // <-- this is your Dot
        actions: [ // <--- your Actions
          ActionProp(
            icon: const Icon(Icons.add),
            onAccept: () {
              doSomething();
            },
          ),
          ActionProp(
            icon: const Icon(Icons.remove),
            onAccept: onAccept: () {
              doSomething();
            },
          ),
          ActionProp(
            icon: const Icon(Icons.backspace),
            onAccept: onAccept: () {
              doSomething();
            },
          ),
        ],
      )
    ],
  ),
);

3. Add Your Style

You can style your "Dot" and "Actions".

Scaffold(
  ...,
  body: Stack(
    children: [
      YourWidget(),
      DotController(  // <-- this is your Dot
        draggingBackgroundColor: Colors.amber,
        stickBackgroundColor: Colors.amber,
        actions: [ // <--- your Actions
          ActionProp(
            icon: const Icon(Icons.add),
            backgroundColor: Colors.white,
            borderColor: Colors.black,
            onAccept: () {
              doSomething();
            },
          ),
          ActionProp(
            icon: const Icon(Icons.remove),
            backgroundColor: Colors.red,
            borderColor: Colors.black,
            onAccept: onAccept: () {
              doSomething();
            },
          ),
          ActionProp(
            icon: const Icon(Icons.backspace),
            backgroundColor: Colors.yellow,
            borderColor: Colors.black,
            onAccept: onAccept: () {
              doSomething();
            },
          ),
        ],
      )
    ],
  ),
);

Example

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.teal,
        title: Text(widget.title, style: const TextStyle(color: Colors.white)),
      ),
      body: Stack(
        children: [
          Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const Text(
                  'Counter',
                ),
                Text(
                  '$_counter',
                  style: Theme.of(context).textTheme.headlineMedium,
                ),
              ],
            ),
          ),
          DotController(
            draggingBackgroundColor: Colors.amber,
            stickBackgroundColor: Colors.amber,
            actions: [
              ActionProp(
                icon: const Icon(Icons.add),
                backgroundColor: Colors.white,
                borderColor: Colors.black,
                onAccept: _incrementCounter,
              ),
              ActionProp(
                icon: const Icon(Icons.remove),
                backgroundColor: Colors.red,
                borderColor: Colors.black,
                onAccept: _decrementCounter,
              ),
              ActionProp(
                icon: const Icon(Icons.backspace),
                backgroundColor: Colors.yellow,
                borderColor: Colors.black,
                onAccept: _initCounter,
              ),
            ],
          )
        ],
      ),
    );
  }

example

License

Apache-2.0 license

dot_controller's People

Contributors

gitsunmin 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.