2022-09-19 17:37:27 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-09-22 23:48:50 +00:00
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
2022-09-19 17:37:27 +00:00
|
|
|
import 'package:stackwallet/widgets/expandable.dart';
|
|
|
|
import 'package:stackwallet/widgets/table_view/table_view_cell.dart';
|
|
|
|
|
2022-11-28 21:21:18 +00:00
|
|
|
class TableViewRow extends StatefulWidget {
|
2022-09-19 17:37:27 +00:00
|
|
|
const TableViewRow({
|
|
|
|
Key? key,
|
|
|
|
required this.cells,
|
|
|
|
required this.expandingChild,
|
|
|
|
this.decoration,
|
|
|
|
this.onExpandChanged,
|
|
|
|
this.padding = const EdgeInsets.all(0),
|
2022-09-25 17:25:57 +00:00
|
|
|
this.spacing = 0.0,
|
2022-09-25 19:53:08 +00:00
|
|
|
this.crossAxisAlignment = CrossAxisAlignment.center,
|
2022-09-19 17:37:27 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final List<TableViewCell> cells;
|
|
|
|
final Widget? expandingChild;
|
2022-11-28 21:21:18 +00:00
|
|
|
final BoxDecoration? decoration;
|
2022-09-19 17:37:27 +00:00
|
|
|
final void Function(ExpandableState)? onExpandChanged;
|
|
|
|
final EdgeInsetsGeometry padding;
|
2022-09-25 17:25:57 +00:00
|
|
|
final double spacing;
|
2022-09-25 19:53:08 +00:00
|
|
|
final CrossAxisAlignment crossAxisAlignment;
|
2022-09-19 17:37:27 +00:00
|
|
|
|
2022-11-28 21:21:18 +00:00
|
|
|
@override
|
|
|
|
State<TableViewRow> createState() => _TableViewRowState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _TableViewRowState extends State<TableViewRow> {
|
|
|
|
bool _hovering = false;
|
|
|
|
|
2022-09-19 17:37:27 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-12-05 22:10:18 +00:00
|
|
|
debugPrint("BUILD: $runtimeType");
|
2022-09-19 17:37:27 +00:00
|
|
|
return Container(
|
2022-11-28 21:21:18 +00:00
|
|
|
decoration: !_hovering
|
2022-12-05 22:10:18 +00:00
|
|
|
? widget.decoration
|
|
|
|
: widget.decoration?.copyWith(
|
2022-11-28 21:21:18 +00:00
|
|
|
boxShadow: [
|
|
|
|
Theme.of(context).extension<StackColors>()!.standardBoxShadow,
|
|
|
|
Theme.of(context).extension<StackColors>()!.standardBoxShadow,
|
|
|
|
],
|
|
|
|
),
|
2022-12-05 22:10:18 +00:00
|
|
|
child: widget.expandingChild == null
|
2022-11-28 21:21:18 +00:00
|
|
|
? MouseRegion(
|
|
|
|
onEnter: (_) {
|
|
|
|
setState(() {
|
|
|
|
_hovering = true;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onExit: (_) {
|
|
|
|
setState(() {
|
|
|
|
_hovering = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Padding(
|
2022-12-05 22:10:18 +00:00
|
|
|
padding: widget.padding,
|
2022-09-19 17:37:27 +00:00
|
|
|
child: Row(
|
2022-12-05 22:10:18 +00:00
|
|
|
crossAxisAlignment: widget.crossAxisAlignment,
|
2022-09-19 17:37:27 +00:00
|
|
|
children: [
|
2022-12-05 22:10:18 +00:00
|
|
|
for (int i = 0; i < widget.cells.length; i++) ...[
|
|
|
|
if (i != 0 && i != widget.cells.length)
|
2022-09-25 17:25:57 +00:00
|
|
|
SizedBox(
|
2022-12-05 22:10:18 +00:00
|
|
|
width: widget.spacing,
|
2022-09-25 17:25:57 +00:00
|
|
|
),
|
|
|
|
Expanded(
|
2022-12-05 22:10:18 +00:00
|
|
|
flex: widget.cells[i].flex,
|
|
|
|
child: widget.cells[i],
|
2022-09-19 17:37:27 +00:00
|
|
|
),
|
2022-09-25 17:25:57 +00:00
|
|
|
],
|
2022-09-19 17:37:27 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-11-28 21:21:18 +00:00
|
|
|
)
|
|
|
|
: Expandable(
|
2022-12-05 22:10:18 +00:00
|
|
|
onExpandChanged: widget.onExpandChanged,
|
2022-11-28 21:21:18 +00:00
|
|
|
header: MouseRegion(
|
|
|
|
onEnter: (_) {
|
|
|
|
setState(() {
|
|
|
|
_hovering = true;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onExit: (_) {
|
|
|
|
setState(() {
|
|
|
|
_hovering = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Padding(
|
2022-12-05 22:10:18 +00:00
|
|
|
padding: widget.padding,
|
2022-11-28 21:21:18 +00:00
|
|
|
child: Row(
|
|
|
|
children: [
|
2022-12-05 22:10:18 +00:00
|
|
|
for (int i = 0; i < widget.cells.length; i++) ...[
|
|
|
|
if (i != 0 && i != widget.cells.length)
|
2022-11-28 21:21:18 +00:00
|
|
|
SizedBox(
|
2022-12-05 22:10:18 +00:00
|
|
|
width: widget.spacing,
|
2022-11-28 21:21:18 +00:00
|
|
|
),
|
|
|
|
Expanded(
|
2022-12-05 22:10:18 +00:00
|
|
|
flex: widget.cells[i].flex,
|
|
|
|
child: widget.cells[i],
|
2022-11-28 21:21:18 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-09-19 17:37:27 +00:00
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.buttonBackSecondary,
|
2022-09-19 17:37:27 +00:00
|
|
|
width: double.infinity,
|
|
|
|
height: 1,
|
|
|
|
),
|
2022-12-05 22:10:18 +00:00
|
|
|
widget.expandingChild!,
|
2022-09-19 17:37:27 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|