76 lines
2.4 KiB
Dart
76 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:okane/ui/state/core.dart';
|
|
import 'package:okane/ui/utils.dart';
|
|
import 'package:okane/ui/widgets/add_template.dart';
|
|
|
|
class TemplateListPage extends StatefulWidget {
|
|
const TemplateListPage({super.key});
|
|
|
|
@override
|
|
State<TemplateListPage> createState() => TemplateListState();
|
|
}
|
|
|
|
class TemplateListState extends State<TemplateListPage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<CoreCubit, CoreState>(
|
|
builder: (context, state) {
|
|
final account = GetIt.I.get<CoreCubit>().activeAccount;
|
|
return Stack(
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 16),
|
|
child: ListView.builder(
|
|
itemCount: state.recurringTransactions.length,
|
|
shrinkWrap: true,
|
|
itemBuilder:
|
|
(ctx, idx) => Card(
|
|
child: ListTile(
|
|
title: Text(
|
|
state
|
|
.recurringTransactions[idx]
|
|
.template
|
|
.value!
|
|
.name,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Positioned(
|
|
right: 16,
|
|
bottom: 16,
|
|
child: FloatingActionButton(
|
|
child: Icon(Icons.add),
|
|
onPressed:
|
|
account == null
|
|
? () {}
|
|
: () {
|
|
showDialogOrModal(
|
|
context: context,
|
|
builder:
|
|
(ctx) => AddTransactionTemplateWidget(
|
|
activeAccountItem: account,
|
|
onAdd: () {
|
|
setState(() {});
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
showDragHandle: true,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|