91 lines
3.2 KiB
Dart
91 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:grouped_list/grouped_list.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;
|
|
final nonRecurringTemplates =
|
|
state.transactionTemplates.where((t) => !t.recurring).toList();
|
|
return Stack(
|
|
children: [
|
|
CustomScrollView(
|
|
slivers: [
|
|
SliverToBoxAdapter(child: Text("Non-recurring")),
|
|
SliverList.builder(
|
|
itemCount: nonRecurringTemplates.length,
|
|
itemBuilder: (context, index) {
|
|
final template = nonRecurringTemplates[index];
|
|
return ListTile(title: Text(template.name));
|
|
},
|
|
),
|
|
SliverToBoxAdapter(child: Text("Recurring")),
|
|
SliverList.builder(
|
|
itemCount: state.recurringTransactions.length,
|
|
itemBuilder: (context, index) {
|
|
final template = state.recurringTransactions[index];
|
|
return ListTile(title: Text(template.template.value!.name));
|
|
},
|
|
),
|
|
],
|
|
),
|
|
/*Padding(
|
|
padding: EdgeInsets.only(top: 16),
|
|
child: ListView.builder(
|
|
itemCount: state.recurringTransactions.length,
|
|
shrinkWrap: true,
|
|
itemBuilder: (ctx, idx) {
|
|
print(idx);
|
|
return 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,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|