stack_wallet/lib/widgets/table_view/table_view_row.dart

136 lines
4.1 KiB
Dart
Raw Normal View History

2023-05-26 21:21:16 +00:00
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'package:flutter/material.dart';
import '../../themes/stack_colors.dart';
import '../expandable.dart';
import 'table_view_cell.dart';
2022-11-28 21:21:18 +00:00
class TableViewRow extends StatefulWidget {
const TableViewRow({
2024-05-27 23:56:22 +00:00
super.key,
required this.cells,
required this.expandingChild,
this.decoration,
this.onExpandChanged,
this.expandOverride,
this.padding = const EdgeInsets.all(0),
this.spacing = 0.0,
2022-09-25 19:53:08 +00:00
this.crossAxisAlignment = CrossAxisAlignment.center,
2024-05-27 23:56:22 +00:00
});
final List<TableViewCell> cells;
final Widget? expandingChild;
2022-11-28 21:21:18 +00:00
final BoxDecoration? decoration;
final void Function(ExpandableState)? onExpandChanged;
final VoidCallback? expandOverride;
final EdgeInsetsGeometry padding;
final double spacing;
2022-09-25 19:53:08 +00:00
final CrossAxisAlignment crossAxisAlignment;
2022-11-28 21:21:18 +00:00
@override
State<TableViewRow> createState() => _TableViewRowState();
}
class _TableViewRowState extends State<TableViewRow> {
bool _hovering = false;
@override
Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType");
return Container(
2022-11-28 21:21:18 +00:00
decoration: !_hovering
? 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,
],
),
child: widget.expandingChild == null
2022-11-28 21:21:18 +00:00
? MouseRegion(
onEnter: (_) {
setState(() {
_hovering = true;
});
},
onExit: (_) {
setState(() {
_hovering = false;
});
},
child: Padding(
padding: widget.padding,
child: Row(
crossAxisAlignment: widget.crossAxisAlignment,
children: [
for (int i = 0; i < widget.cells.length; i++) ...[
if (i != 0 && i != widget.cells.length)
SizedBox(
width: widget.spacing,
),
Expanded(
flex: widget.cells[i].flex,
child: widget.cells[i],
),
],
],
),
),
2022-11-28 21:21:18 +00:00
)
: Expandable(
expandOverride: widget.expandOverride,
onExpandChanged: widget.onExpandChanged,
2022-11-28 21:21:18 +00:00
header: MouseRegion(
onEnter: (_) {
setState(() {
_hovering = true;
});
},
onExit: (_) {
setState(() {
_hovering = false;
});
},
child: Padding(
padding: widget.padding,
2022-11-28 21:21:18 +00:00
child: Row(
children: [
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(
width: widget.spacing,
2022-11-28 21:21:18 +00:00
),
Expanded(
flex: widget.cells[i].flex,
child: widget.cells[i],
2022-11-28 21:21:18 +00:00
),
],
],
),
),
),
body: Column(
children: [
Container(
color: Theme.of(context)
.extension<StackColors>()!
.buttonBackSecondary,
width: double.infinity,
height: 1,
),
widget.expandingChild!,
],
),
),
);
}
}