mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
simple tableview with optional expandable rows
This commit is contained in:
parent
e2bd064ba5
commit
79327a145c
3 changed files with 105 additions and 0 deletions
20
lib/widgets/table_view/table_view.dart
Normal file
20
lib/widgets/table_view/table_view.dart
Normal file
|
@ -0,0 +1,20 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:stackwallet/widgets/table_view/table_view_row.dart';
|
||||
|
||||
class TableView extends StatefulWidget {
|
||||
const TableView({Key? key, required this.rows}) : super(key: key);
|
||||
|
||||
final List<TableViewRow> rows;
|
||||
|
||||
@override
|
||||
State<TableView> createState() => _TableViewState();
|
||||
}
|
||||
|
||||
class _TableViewState extends State<TableView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: widget.rows,
|
||||
);
|
||||
}
|
||||
}
|
17
lib/widgets/table_view/table_view_cell.dart
Normal file
17
lib/widgets/table_view/table_view_cell.dart
Normal file
|
@ -0,0 +1,17 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class TableViewCell extends StatelessWidget {
|
||||
const TableViewCell({
|
||||
Key? key,
|
||||
required this.flex,
|
||||
required this.child,
|
||||
}) : super(key: key);
|
||||
|
||||
final int flex;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return child;
|
||||
}
|
||||
}
|
68
lib/widgets/table_view/table_view_row.dart
Normal file
68
lib/widgets/table_view/table_view_row.dart
Normal file
|
@ -0,0 +1,68 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:stackwallet/utilities/cfcolors.dart';
|
||||
import 'package:stackwallet/widgets/expandable.dart';
|
||||
import 'package:stackwallet/widgets/table_view/table_view_cell.dart';
|
||||
|
||||
class TableViewRow extends StatelessWidget {
|
||||
const TableViewRow({
|
||||
Key? key,
|
||||
required this.cells,
|
||||
required this.expandingChild,
|
||||
this.decoration,
|
||||
this.onExpandChanged,
|
||||
this.padding = const EdgeInsets.all(0),
|
||||
}) : super(key: key);
|
||||
|
||||
final List<TableViewCell> cells;
|
||||
final Widget? expandingChild;
|
||||
final Decoration? decoration;
|
||||
final void Function(ExpandableState)? onExpandChanged;
|
||||
final EdgeInsetsGeometry padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: decoration,
|
||||
child: expandingChild == null
|
||||
? Padding(
|
||||
padding: padding,
|
||||
child: Row(
|
||||
children: [
|
||||
...cells.map(
|
||||
(e) => Expanded(
|
||||
flex: e.flex,
|
||||
child: e,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Expandable(
|
||||
onExpandChanged: onExpandChanged,
|
||||
header: Padding(
|
||||
padding: padding,
|
||||
child: Row(
|
||||
children: [
|
||||
...cells.map(
|
||||
(e) => Expanded(
|
||||
flex: e.flex,
|
||||
child: e,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
color: CFColors.buttonBackSecondary,
|
||||
width: double.infinity,
|
||||
height: 1,
|
||||
),
|
||||
expandingChild!,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue