64 lines
2.0 KiB
Dart
64 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:rluv/features/budget/widgets/transaction_list_item.dart';
|
|
import 'package:rluv/global/styles.dart';
|
|
|
|
import '../../../global/store.dart';
|
|
|
|
class TransactionsListview extends ConsumerStatefulWidget {
|
|
const TransactionsListview({super.key});
|
|
|
|
@override
|
|
ConsumerState<TransactionsListview> createState() =>
|
|
_TransactionsListviewState();
|
|
}
|
|
|
|
class _TransactionsListviewState extends ConsumerState<TransactionsListview> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final transactions = ref.watch(Store().transactionsProvider);
|
|
transactions.sort(
|
|
(a, b) => b.date.compareTo(a.date),
|
|
);
|
|
return Scaffold(
|
|
backgroundColor: Styles.purpleNurple,
|
|
body: SafeArea(
|
|
child: Stack(
|
|
children: [
|
|
if (transactions.isEmpty) ...[
|
|
const Center(
|
|
child: Text('No transactions'),
|
|
),
|
|
],
|
|
if (transactions.isNotEmpty)
|
|
Column(
|
|
children: [
|
|
const SizedBox(height: 28),
|
|
const Text(
|
|
'Transaction History',
|
|
style: TextStyle(fontSize: 28),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
Expanded(
|
|
child: ListView.builder(
|
|
physics: const BouncingScrollPhysics(),
|
|
itemCount: transactions.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return TransactionListItem(
|
|
index: index,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.chevron_left),
|
|
onPressed: () => Navigator.pop(context)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|