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

Headers are created above its content. #19

Closed
wizzar opened this issue Dec 24, 2019 · 7 comments · Fixed by #27
Closed

Headers are created above its content. #19

wizzar opened this issue Dec 24, 2019 · 7 comments · Fixed by #27
Labels
enhancement New feature or request

Comments

@wizzar
Copy link

wizzar commented Dec 24, 2019

In a simple horizontally scrollable list, the header is always above the items. There should be some kind of margin.
image

Code:

class Test extends StatefulWidget {
  @override
  _TestState createState() => _TestState();
}

class _TestState extends State<Test> {
  String text = "init";
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Container(
            color: Colors.lightBlue,
            child: Text(text),
          ),
          Container(
            margin: EdgeInsets.symmetric(vertical: 30),
            height: 300,
            child: InfiniteList(
              scrollDirection: Axis.horizontal,
              direction: InfiniteListDirection.multi,
              builder: (context, index) {
                return InfiniteListItem(
                  initialHeaderBuild: true,
                  headerAlignment: HeaderAlignment.centerLeft,
                  headerBuilder: (context) {
                    return Container(
                      color: Colors.white,
                      child: Text("header $index"),
                    );
                  },
                  contentBuilder: (context) {
                    return Container(
                      color: RandomColor().randomColor(),
                      child: Padding(
                        padding: const EdgeInsets.only(
                          left: 0, // <- must be set to whatever the header width is to fix the problem.
                        ),
                        child: Row(
                          children: List.generate(7, (itemIndex) {
                            return RaisedButton(
                              child: Text("item $itemIndex ($index)"),
                              onPressed: () {
                                setState(() {
                                  text = "item $itemIndex ($index)";
                                });
                              },
                            );
                          }),
                        ),
                      ),
                    );
                  },
                );
              },
            ),
          )
        ],
      ),
    );
  }
}
@TatsuUkraine
Copy link
Owner

Well, it's expected behavior) by default headers are overlay content

@TatsuUkraine
Copy link
Owner

@wizzar do you want me to make overlay optional for headers?

@wizzar
Copy link
Author

wizzar commented Dec 24, 2019

Oh.. I did not expect that... I understand it should overlay. However, initially, the first item should be visible. I believe that's what most people would expect, to not have the first item not visible.

@wizzar
Copy link
Author

wizzar commented Dec 24, 2019

@wizzar do you want me to make overlay optional for headers?

I believe it would make your plugin more robust.

@TatsuUkraine
Copy link
Owner

TatsuUkraine commented Dec 24, 2019

@wizzar do you want me to make overlay optional for headers?

I believe it would make your plugin more robust.

@wizzar ok) can't guarantee that I will implement this feature today or tomorrow) but for sure will try to do this as soon as I can)

I was just thinking to make it as simple as possible, even made list item classes extendable if needed, just to give full control over layout to the dev. But I think adding ability to switch off overlay from the box good improvement

@TatsuUkraine TatsuUkraine added the enhancement New feature or request label Dec 24, 2019
This was referenced Jul 1, 2020
@TatsuUkraine
Copy link
Owner

@wizzar just published v2, now package supports relative positioning

@TatsuUkraine
Copy link
Owner

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

Successfully merging a pull request may close this issue.

2 participants