Skip to content

Commit

Permalink
Implemented property 'visibleScrollbar' (#5)
Browse files Browse the repository at this point in the history
* implemented property 'visibleScrollbar': manages visibility of scrollbars

* Edit README.md and CHANGELOG.md

Co-authored-by: RichiB20 <s227583@studenti.polito.it>
  • Loading branch information
rickypid and RichiB20 committed Jun 7, 2022
1 parent fc3bc27 commit b91a974
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 51 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Flutter Expandable Table

## [1.1.0] - 2022-06-07
#### [@RichiB20](https://github.com/RichiB20)
- implemented property `visibleScrollbar`.

## [1.0.2] - 2022-02-03
#### [@rickypid](https://github.com/rickypid)
- Remove unnecessary imports and unnecessary null check, upgraded dependency.
Expand All @@ -18,4 +22,4 @@

## [0.0.1-alpha] - 2021-07-20
#### [@rickypid](https://github.com/rickypid)
- Initial release.
- Initial release.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ExpandableTable(
* `scrollShadowDuration`: determines duration rendered animation of shadows.
* `scrollShadowCurve`: determines rendered curve animation of shadows.
* `scrollShadowColor`: determines rendered color of shadows.
* `visibleScrollbar`: determines visibility of scrollbar.

&nbsp;

Expand All @@ -73,4 +74,5 @@ ExpandableTable(

| Package | Verison | Score | Likes | Test | Coverage |
|--|--|--|--|--|--|
| [![](https://img.shields.io/static/v1?label=dart&message=cowsay&color=red??style=for-the-badge&logo=GitHub)](https://github.com/rickypid/cowsay) | [![Pub Package](https://img.shields.io/pub/v/cowsay.svg?style=flat-square)](https://pub.dartlang.org/packages/cowsay) | [![pub points](https://badges.bar/cowsay/pub%20points)](https://pub.dev/packages/cowsay/score) | [![likes](https://badges.bar/cowsay/likes)](https://pub.dev/packages/cowsay/score) | [![Test CI](https://github.com/rickypid/cowsay/actions/workflows/test.yml/badge.svg)](https://github.com/rickypid/cowsay/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/rickypid/cowsay/branch/master/graph/badge.svg?token=Z65KEB9SAX)](https://codecov.io/gh/rickypid/cowsay) |
| [![](https://img.shields.io/static/v1?label=dart&message=cowsay&color=red??style=for-the-badge&logo=GitHub)](https://github.com/rickypid/cowsay) | [![Pub Package](https://img.shields.io/pub/v/cowsay.svg?style=flat-square)](https://pub.dartlang.org/packages/cowsay) | [![pub points](https://badges.bar/cowsay/pub%20points)](https://pub.dev/packages/cowsay/score) | [![likes](https://badges.bar/cowsay/likes)](https://pub.dev/packages/cowsay/score) | [![Test CI](https://github.com/rickypid/cowsay/actions/workflows/test.yml/badge.svg)](https://github.com/rickypid/cowsay/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/rickypid/cowsay/branch/master/graph/badge.svg?token=Z65KEB9SAX)](https://codecov.io/gh/rickypid/cowsay) |
| [![](https://img.shields.io/static/v1?label=dart&message=telegram_link&color=red??style=for-the-badge&logo=GitHub)](https://github.com/rickypid/telegram_link) | [![Pub Package](https://img.shields.io/pub/v/telegram_link.svg?style=flat-square)](https://pub.dartlang.org/packages/telegram_link) | [![pub points](https://badges.bar/telegram_link/pub%20points)](https://pub.dev/packages/telegram_link/score) | [![likes](https://badges.bar/telegram_link/likes)](https://pub.dev/packages/telegram_link/score) | [![Test CI](https://github.com/rickypid/telegram_link/actions/workflows/test.yml/badge.svg)](https://github.com/rickypid/telegram_link/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/rickypid/telegram_link/branch/main/graph/badge.svg?token=Z65KEB9SAX)](https://codecov.io/gh/rickypid/telegram_link) |
4 changes: 3 additions & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ExpandableTable(
* `scrollShadowDuration`: determines duration rendered animation of shadows.
* `scrollShadowCurve`: determines rendered curve animation of shadows.
* `scrollShadowColor`: determines rendered color of shadows.
* `visibleScrollbar`: determines visibility of scrollbar.

&nbsp;

Expand All @@ -73,4 +74,5 @@ ExpandableTable(

| Package | Verison | Score | Likes | Test | Coverage |
|--|--|--|--|--|--|
| [![](https://img.shields.io/static/v1?label=dart&message=cowsay&color=red??style=for-the-badge&logo=GitHub)](https://github.com/rickypid/cowsay) | [![Pub Package](https://img.shields.io/pub/v/cowsay.svg?style=flat-square)](https://pub.dartlang.org/packages/cowsay) | [![pub points](https://badges.bar/cowsay/pub%20points)](https://pub.dev/packages/cowsay/score) | [![likes](https://badges.bar/cowsay/likes)](https://pub.dev/packages/cowsay/score) | [![Test CI](https://github.com/rickypid/cowsay/actions/workflows/test.yml/badge.svg)](https://github.com/rickypid/cowsay/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/rickypid/cowsay/branch/master/graph/badge.svg?token=Z65KEB9SAX)](https://codecov.io/gh/rickypid/cowsay) |
| [![](https://img.shields.io/static/v1?label=dart&message=cowsay&color=red??style=for-the-badge&logo=GitHub)](https://github.com/rickypid/cowsay) | [![Pub Package](https://img.shields.io/pub/v/cowsay.svg?style=flat-square)](https://pub.dartlang.org/packages/cowsay) | [![pub points](https://badges.bar/cowsay/pub%20points)](https://pub.dev/packages/cowsay/score) | [![likes](https://badges.bar/cowsay/likes)](https://pub.dev/packages/cowsay/score) | [![Test CI](https://github.com/rickypid/cowsay/actions/workflows/test.yml/badge.svg)](https://github.com/rickypid/cowsay/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/rickypid/cowsay/branch/master/graph/badge.svg?token=Z65KEB9SAX)](https://codecov.io/gh/rickypid/cowsay) |
| [![](https://img.shields.io/static/v1?label=dart&message=telegram_link&color=red??style=for-the-badge&logo=GitHub)](https://github.com/rickypid/telegram_link) | [![Pub Package](https://img.shields.io/pub/v/telegram_link.svg?style=flat-square)](https://pub.dartlang.org/packages/telegram_link) | [![pub points](https://badges.bar/telegram_link/pub%20points)](https://pub.dev/packages/telegram_link/score) | [![likes](https://badges.bar/telegram_link/likes)](https://pub.dev/packages/telegram_link/score) | [![Test CI](https://github.com/rickypid/telegram_link/actions/workflows/test.yml/badge.svg)](https://github.com/rickypid/telegram_link/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/rickypid/telegram_link/branch/main/graph/badge.svg?token=Z65KEB9SAX)](https://codecov.io/gh/rickypid/telegram_link) |
30 changes: 15 additions & 15 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -61,7 +61,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.2"
version: "1.1.0"
flutter_scroll_shadow:
dependency: transitive
description:
Expand All @@ -88,6 +88,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -108,7 +115,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
provider:
dependency: transitive
description:
Expand All @@ -127,7 +134,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -162,21 +169,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.17.0"
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_expandable_table_example
description: A Flutter widget for create an expandable table with header and first column fixed.
version: 1.0.2
version: 1.1.0

environment:
sdk: ">=2.12.0 <3.0.0"
Expand All @@ -16,4 +16,4 @@ dev_dependencies:
path: ../

flutter:
uses-material-design: true
uses-material-design: true
42 changes: 33 additions & 9 deletions lib/src/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import 'data.dart';
class ExpandableTableBody extends StatefulWidget {
final ScrollController scrollController;
final List<ExpandableTableRow> rows;
final bool visibleScrollbar;

ExpandableTableBody({
required this.scrollController,
required this.rows,
required this.visibleScrollbar,
});

@override
Expand Down Expand Up @@ -149,10 +151,21 @@ class _ExpandableTableBodyState extends State<ExpandableTableBody>
curve: ExpandableTableData.of(context).scrollShadowCurve,
duration: ExpandableTableData.of(context).scrollShadowDuration,
controller: _firstColumnController,
child: ListView(
controller: _firstColumnController,
physics: ClampingScrollPhysics(),
children: firstColumn,
child: Builder(
builder: (context) {
Widget child = ListView(
controller: _firstColumnController,
physics: ClampingScrollPhysics(),
children: firstColumn,
);
return ExpandableTableData.of(context).visibleScrollbar
? Scrollbar(
child: child,
thumbVisibility: true,
controller: _firstColumnController,
)
: child;
},
),
),
),
Expand Down Expand Up @@ -181,10 +194,21 @@ class _ExpandableTableBodyState extends State<ExpandableTableBody>
duration:
ExpandableTableData.of(context).scrollShadowDuration,
controller: _restColumnsController,
child: ListView(
controller: _restColumnsController,
physics: const ClampingScrollPhysics(),
children: bodyColumns,
child: Builder(
builder: (context) {
Widget child = ListView(
controller: _restColumnsController,
physics: const ClampingScrollPhysics(),
children: bodyColumns,
);
return ExpandableTableData.of(context).visibleScrollbar
? ScrollConfiguration(
behavior: ScrollConfiguration.of(context)
.copyWith(scrollbars: false),
child: child,
)
: child;
},
),
),
),
Expand All @@ -194,4 +218,4 @@ class _ExpandableTableBodyState extends State<ExpandableTableBody>
],
);
}
}
}
4 changes: 4 additions & 0 deletions lib/src/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ExpandableTableData extends StatefulWidget {
final Duration scrollShadowDuration;
final Curve scrollShadowCurve;
final Color scrollShadowColor;
final bool visibleScrollbar;

ExpandableTableData({
required this.child,
Expand All @@ -39,6 +40,7 @@ class ExpandableTableData extends StatefulWidget {
required this.scrollShadowDuration,
required this.scrollShadowCurve,
required this.scrollShadowColor,
required this.visibleScrollbar,
});

static ExpandableTableDataState of(BuildContext context) {
Expand All @@ -62,6 +64,8 @@ class ExpandableTableDataState extends State<ExpandableTableData> {

Color get scrollShadowColor => widget.scrollShadowColor;

bool get visibleScrollbar => widget.visibleScrollbar;

double get cellWidth => widget.cellWidth;

double get cellHeight => widget.cellHeight;
Expand Down
33 changes: 27 additions & 6 deletions lib/src/expandable_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class ExpandableTable extends StatefulWidget {
/// Default: [Colors.transparent]
final Color scrollShadowColor;

/// [visibleScrollbar] determines visibility of scrollbar.
///
/// Default: [false]
final bool visibleScrollbar;

/// [ExpandableTable] constructor.
/// Required:
/// - rows
Expand All @@ -82,6 +87,7 @@ class ExpandableTable extends StatefulWidget {
this.scrollShadowDuration = const Duration(milliseconds: 500),
this.scrollShadowCurve = Curves.fastOutSlowIn,
this.scrollShadowColor = Colors.transparent,
this.visibleScrollbar = false,
}) : super(key: key);

@override
Expand All @@ -101,6 +107,7 @@ class _ExpandableTableState extends State<ExpandableTable> {
scrollShadowColor: widget.scrollShadowColor,
scrollShadowCurve: widget.scrollShadowCurve,
scrollShadowDuration: widget.scrollShadowDuration,
visibleScrollbar: widget.visibleScrollbar,
child: _Table(
rows: widget.rows,
header: widget.header,
Expand Down Expand Up @@ -215,11 +222,23 @@ class __TableState extends State<_Table> {
duration:
ExpandableTableData.of(context).scrollShadowDuration,
controller: _headController,
child: ListView(
controller: _headController,
physics: ClampingScrollPhysics(),
scrollDirection: Axis.horizontal,
children: _buildHeaderCells(context, widget.header, null),
child: Builder(
builder: (context) {
Widget child = ListView(
controller: _headController,
physics: ClampingScrollPhysics(),
scrollDirection: Axis.horizontal,
children:
_buildHeaderCells(context, widget.header, null),
);
return ExpandableTableData.of(context).visibleScrollbar
? Scrollbar(
child: child,
thumbVisibility: true,
controller: _headController,
)
: child;
},
),
),
),
Expand All @@ -230,10 +249,12 @@ class __TableState extends State<_Table> {
child: ExpandableTableBody(
scrollController: _bodyController,
rows: widget.rows,
visibleScrollbar:
ExpandableTableData.of(context).visibleScrollbar,
),
),
],
),
);
}
}
}
28 changes: 14 additions & 14 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -81,6 +81,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -101,7 +108,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
provider:
dependency: "direct main"
description:
Expand All @@ -120,7 +127,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -155,21 +162,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.17.0"
Loading

0 comments on commit b91a974

Please sign in to comment.