Giter Club home page Giter Club logo

Comments (6)

bosskmk avatar bosskmk commented on July 21, 2024 1

Admin input panel

Is it this type of UI?

This is not in PlutoGrid, but I plan to work on a new project called PlutoInputPanel (tentative name).

This hasn't started yet.

I don't know if this will be your reference right away, but I made the structure simple.

However, the code below was written in scratch state without the help of IDE's Auto-complete. Because of this, there may be problems with grammatical errors or referring to missing properties.

class PanelRow extends StatefulWidget {
  final Handler handler;

  final rowIdx;

  PanelRow(this.handler, this.rowIdx);

  @override
  _PanelRowState createState() => _PanelRowState();
}

class _PanelRowState extends State<PanelRow> {
  final FocusNode focusNode = FocusNode();

  @override
  Widget build(BuildContext context) {
    if (widget.handler.currentRowIdx == rowIdx) {
      FocusScope.of(ctx).requestFocus(focusNode);
    }
    return Container(
      child: Row(
        children: [
          TextField(
            focusNode: focusNode,
          ),
          FlatButton(
            onTap: () {
              handler.setCurrentRowIdx(widget.handler.currentRowIdx + 1);
            },
          ),
        ],
      ),
    );
  }
}

class Panel extends StatefulWidget {
  final rows;

  Panel(this.rows);

  @override
  _PanelState createState() => _PanelState();
}

class _PanelState extends State<Panel> {
  final Handler handler;

  final FocusNode focusNode;

  initState() {
    handler = Handler();

    focusNode = FocusNode(onKey: handler.keyboardHandler);
  }

  @override
  Widget build(BuildContext context) {
    return RawKeyboardListner(
      focusNode: focusNode,
      child: ListView.builder(
          itemCount: widget.rows.length,
          builder: (context, index) {
            return PanelRow(
              rowIdx: index,
              handler: handler,
            );
          }
      ),
    );
  }
}


class Handler extends ChangeNotifier {
  int currentRowIdx = 0;

  void setCurrentRowIdx(int idx) {
    currentRowIdx = idx;
    notifyListeners();
  }

  bool keyboardHandler(FocusNode node, RawKeyEvent event) {
      // if key pressed arrowDown
      setCurrentRowIdx(currentRowIdx - 1);

      // if key pressed arrowUp
      setCurrentRowIdx(currentRowIdx + 1);
  }
}

from pluto_grid.

NiranjanShah avatar NiranjanShah commented on July 21, 2024 1

from pluto_grid.

bosskmk avatar bosskmk commented on July 21, 2024

Hello. First of all, thank you for your good comments and good package introduction.

The way the grid works is simple.

The grid uses ChangeNotifier to manage its state.
That's the PlutoStateManager.

The widget receives it and reads the state, or registers an addListener to detect state changes.

The addListener callback detects any state change, and when the widget needs state change, it executes setState to reflect the state change.

This is an explanation of the simple operation.

If you have any further explanations, please ask me and I will sincerely respond.

And, the GetX you mentioned looks very good. I'll take a closer look and try to apply it.

Thanks again for the introduction and comments of the good package.

from pluto_grid.

NiranjanShah avatar NiranjanShah commented on July 21, 2024

from pluto_grid.

NiranjanShah avatar NiranjanShah commented on July 21, 2024

from pluto_grid.

bosskmk avatar bosskmk commented on July 21, 2024

Yes. I also want to quickly enter, edit, and move data using the keyboard.

I would like to quickly implement the requirements you mentioned.

Thanks for the good comment.

from pluto_grid.

Related Issues (20)

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.