Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the example working #1

Closed
daybson opened this issue Mar 5, 2020 · 5 comments
Closed

Can't get the example working #1

daybson opened this issue Mar 5, 2020 · 5 comments

Comments

@daybson
Copy link

daybson commented Mar 5, 2020

I can't get the code to works. I'm able to draw a list, but it's not dragging items...
Here's my code:

import 'package:boardview/board_item.dart';
import 'package:boardview/board_list.dart';
import 'package:boardview/boardview.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MyView extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return MyViewState();
  }
}

class MyViewState extends State<MyView> {
  @override
  Widget build(BuildContext context) {
    var boardItem0 = BoardItem(
        item: Container(
            height: 8,
            child: Text(
              'TESTE 0',
              style: TextStyle(fontSize: 12),
            )));
    var boardItem1 = BoardItem(
        item: Container(
            width: double.maxFinite,
            height: 10,
            child: Text(
              '  TESTE 1   ',
              style: TextStyle(fontSize: 12),
            )));

    var listBoardItems = List<BoardItem>();
    listBoardItems.add(boardItem0);
    listBoardItems.add(boardItem1);

    var boardList = BoardList(
        backgroundColor: Colors.yellow,
        items: listBoardItems,
        index: 0,
        footer: Container(height: 50));

    var listBoardListItems = List<BoardList>();
    listBoardListItems.add(boardList);

    var boardView0 = BoardView(lists: listBoardListItems);

    return Container(
      child: boardView0,
    );
  }
}
@jakebonk
Copy link
Owner

jakebonk commented Mar 5, 2020

Are the BoardItems not draggable or is it the BoardList? BoardList are draggable from a header widget and I don't see one on yours. So try adding something like header: Container(height: 50,), to it

@daybson
Copy link
Author

daybson commented Mar 5, 2020

The BoardItems are not draggable.
I've atacched a gif with the result of the code above:
https://user-images.githubusercontent.com/3179898/76025793-6495b300-5f0c-11ea-8262-4d3a68addc28.gif
2020-03-05-18-07-14

@jakebonk
Copy link
Owner

jakebonk commented Mar 5, 2020

I tested the above code and it seems to work. I see in your picture that you have an ad in it. Do you also have a Stack or something that would be blocking any touches to the BoardView?

@daybson
Copy link
Author

daybson commented Mar 5, 2020

I've got it!

But there's a small issue: if I click and drag immediately, it doesn't drag at all. I have to pressure for a some time and then drag. Could be the Android Emulator slowing down the UI?

import 'package:boardview/board_item.dart';
import 'package:boardview/board_list.dart';
import 'package:boardview/boardview.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MyView extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return MyViewState();
  }
}

class MyViewState extends State<MyView> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Expanded(
                child: BoardView(
              lists: _get() + _get(),
            )),
          ]),
    );
  }

  List<BoardList> _get() {
    var boardItem0 = BoardItem(
        item: Container(
            height: 20,
            color: Colors.indigo[100],
            child: Text(
              'ABC',
              style: TextStyle(fontSize: 12),
            )));
    var boardItem1 = BoardItem(
        item: Container(
            height: 20,
            color: Colors.purple[100],
            child: Text(
              '123',
              style: TextStyle(fontSize: 12),
            )));

    var listBoardItems = List<BoardItem>();
    listBoardItems.add(boardItem0);
    listBoardItems.add(boardItem1);

    var boardList = BoardList(
        headerBackgroundColor: Colors.green,
        header: Container(
          height: 50,
          color: Colors.blue,
        ),
        items: listBoardItems,
        footer: Container(
          height: 50,
          color: Colors.red,
        ));

    var listBoardListItems = List<BoardList>();
    listBoardListItems.add(boardList);

    return (listBoardListItems);
  }
}

untitled

@jakebonk
Copy link
Owner

jakebonk commented Mar 5, 2020

Awesome! I use onLongPress to detect a drag which I think takes around 1000ms to trigger. I might change it to be customizable in the future though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants