sign in with pocketbase working

This commit is contained in:
davmar
2026-09-09 19:59:38 +02:00
parent ae464ff304
commit c6d1fdb19e
27 changed files with 1267 additions and 312 deletions
+257 -277
View File
@@ -91,15 +91,20 @@ Future<TransactionFilterSelection?> showTransactionFilterDialog(
useSafeArea: true,
showDragHandle: true,
builder: (dialogContext) {
final media = MediaQuery.of(dialogContext);
// Keep the sheet above the keyboard without overflowing.
final maxHeight =
(media.size.height - media.viewInsets.bottom) * 0.92;
return Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.viewInsetsOf(dialogContext).bottom,
),
child: _TransactionFilterDialog(
available: available,
transactions: transactions,
initial: initial,
currentMonth: currentMonth ?? monthStart(DateTime.now()),
padding: EdgeInsets.only(bottom: media.viewInsets.bottom),
child: SizedBox(
height: maxHeight.clamp(320.0, media.size.height),
child: _TransactionFilterDialog(
available: available,
transactions: transactions,
initial: initial,
currentMonth: currentMonth ?? monthStart(DateTime.now()),
),
),
);
},
@@ -201,14 +206,17 @@ class _SimpleLabelFilterDialogState extends State<_SimpleLabelFilterDialog> {
final showUncategorized = widget.includeUncategorized &&
(needle.isEmpty ||
kUncategorizedFilterLabel.name.toLowerCase().contains(needle));
final maxListHeight = MediaQuery.sizeOf(context).height * 0.45;
final media = MediaQuery.of(context);
final maxContentHeight =
((media.size.height - media.viewInsets.bottom) * 0.55)
.clamp(240.0, 560.0);
return AlertDialog(
title: Text(widget.title),
content: SizedBox(
width: double.maxFinite,
height: maxContentHeight,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
@@ -278,8 +286,7 @@ class _SimpleLabelFilterDialogState extends State<_SimpleLabelFilterDialog> {
),
],
const SizedBox(height: 8),
ConstrainedBox(
constraints: BoxConstraints(maxHeight: maxListHeight),
Expanded(
child: _LabelChecklist(
entries: entries,
showUncategorized: showUncategorized,
@@ -483,7 +490,6 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
final theme = Theme.of(context);
final colors = theme.colorScheme;
final meta = context.watch<TxMetaController>();
final size = MediaQuery.sizeOf(context);
final needle = _labelSearchController.text.trim().toLowerCase();
final entries = _filterLabelEntries(
meta: meta,
@@ -494,285 +500,253 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
kUncategorizedFilterLabel.name.toLowerCase().contains(needle);
final sectionStyle = _sectionStyle(theme, colors);
// Fixed sheet height so Expanded labels get a real viewport (not a tiny 220px box).
final sheetHeight = (size.height * 0.92).clamp(420.0, size.height);
return SizedBox(
height: sheetHeight,
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(24, 4, 24, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Filter transactions',
style: theme.textTheme.titleLarge,
// Parent SizedBox already bounds height (and accounts for keyboard).
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(24, 4, 24, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Filter transactions',
style: theme.textTheme.titleLarge,
),
const SizedBox(height: 4),
Text(
'Search, period, flow, amount, and labels.',
style: theme.textTheme.bodyMedium?.copyWith(
color: colors.onSurfaceVariant,
),
const SizedBox(height: 4),
),
],
),
),
const SizedBox(height: 8),
Expanded(
child: ListView(
padding: const EdgeInsets.fromLTRB(24, 4, 24, 8),
children: [
Text('Search text', style: sectionStyle),
const SizedBox(height: 8),
TextField(
controller: _queryController,
textInputAction: TextInputAction.search,
decoration: const InputDecoration(
hintText: 'Description, notes, amount…',
prefixIcon: Icon(Icons.search),
),
),
const SizedBox(height: 14),
Text('Period', style: sectionStyle),
const SizedBox(height: 8),
_RectToggleBar<bool>(
value: _monthOnly,
onChanged: (value) => setState(() => _monthOnly = value),
options: const [
_RectToggleOption(
value: false,
label: 'All',
),
_RectToggleOption(
value: true,
label: 'Month',
icon: Icons.calendar_month,
),
],
),
if (_monthOnly) ...[
const SizedBox(height: 8),
Text(
'Search, period, flow, amount, and labels.',
style: theme.textTheme.bodyMedium?.copyWith(
'Uses ${formatMonthYear(widget.currentMonth)}. '
'Change month on the transactions list.',
style: theme.textTheme.bodySmall?.copyWith(
color: colors.onSurfaceVariant,
),
),
],
),
),
const SizedBox(height: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Flexible(
flex: 2,
child: SingleChildScrollView(
padding: const EdgeInsets.fromLTRB(24, 4, 24, 8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('Search text', style: sectionStyle),
const SizedBox(height: 8),
TextField(
controller: _queryController,
textInputAction: TextInputAction.search,
decoration: const InputDecoration(
hintText: 'Description, notes, amount…',
prefixIcon: Icon(Icons.search),
),
),
const SizedBox(height: 14),
Text('Period', style: sectionStyle),
const SizedBox(height: 8),
_RectToggleBar<bool>(
value: _monthOnly,
onChanged: (value) =>
setState(() => _monthOnly = value),
options: const [
_RectToggleOption(
value: false,
label: 'All',
),
_RectToggleOption(
value: true,
label: 'Month',
icon: Icons.calendar_month,
),
],
),
if (_monthOnly) ...[
const SizedBox(height: 8),
Text(
'Uses ${formatMonthYear(widget.currentMonth)}. '
'Change month on the transactions list.',
style: theme.textTheme.bodySmall?.copyWith(
color: colors.onSurfaceVariant,
),
),
],
const SizedBox(height: 14),
Text('Income / expense', style: sectionStyle),
const SizedBox(height: 8),
_RectToggleBar<TxFlowFilter>(
value: _flow,
onChanged: (value) => setState(() => _flow = value),
options: const [
_RectToggleOption(
value: TxFlowFilter.all,
label: 'All',
),
_RectToggleOption(
value: TxFlowFilter.income,
label: 'In',
icon: Icons.south_west,
),
_RectToggleOption(
value: TxFlowFilter.expense,
label: 'Out',
icon: Icons.north_east,
),
],
),
const SizedBox(height: 14),
Text('Amount', style: sectionStyle),
const SizedBox(height: 8),
Text(
'Exact',
style: theme.textTheme.bodySmall?.copyWith(
color: colors.onSurfaceVariant,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 6),
TextField(
controller: _exactAmountController,
keyboardType: const TextInputType.numberWithOptions(
decimal: true,
),
decoration: InputDecoration(
isDense: true,
hintText: 'e.g. 12.50',
prefixIcon: const Icon(Icons.pin, size: 20),
suffixIcon:
_exactAmountController.text.trim().isEmpty
? null
: IconButton(
tooltip: 'Clear exact',
onPressed: () {
_exactAmountController.clear();
setState(() {});
},
icon: const Icon(Icons.clear, size: 18),
),
),
onChanged: (_) {
setState(() {
_rangeTouched = false;
_amountRange = RangeValues(0, _amountCeil);
});
const SizedBox(height: 14),
Text('Income / expense', style: sectionStyle),
const SizedBox(height: 8),
_RectToggleBar<TxFlowFilter>(
value: _flow,
onChanged: (value) => setState(() => _flow = value),
options: const [
_RectToggleOption(
value: TxFlowFilter.all,
label: 'All',
),
_RectToggleOption(
value: TxFlowFilter.income,
label: 'In',
icon: Icons.south_west,
),
_RectToggleOption(
value: TxFlowFilter.expense,
label: 'Out',
icon: Icons.north_east,
),
],
),
const SizedBox(height: 14),
Text('Amount', style: sectionStyle),
const SizedBox(height: 8),
Text(
'Exact',
style: theme.textTheme.bodySmall?.copyWith(
color: colors.onSurfaceVariant,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 6),
TextField(
controller: _exactAmountController,
keyboardType: const TextInputType.numberWithOptions(
decimal: true,
),
decoration: InputDecoration(
isDense: true,
hintText: 'e.g. 12.50',
prefixIcon: const Icon(Icons.pin, size: 20),
suffixIcon: _exactAmountController.text.trim().isEmpty
? null
: IconButton(
tooltip: 'Clear exact',
onPressed: () {
_exactAmountController.clear();
setState(() {});
},
icon: const Icon(Icons.clear, size: 18),
),
const SizedBox(height: 12),
Text(
'Range',
style: theme.textTheme.bodySmall?.copyWith(
color: colors.onSurfaceVariant,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Text(
_rangeTouched
? '${_amountRange.start.toStringAsFixed(0)} – ${_amountRange.end.toStringAsFixed(0)}'
: 'Any amount',
style: theme.textTheme.bodySmall?.copyWith(
color: colors.onSurfaceVariant,
),
),
RangeSlider(
values: _amountRange,
min: 0,
max: _amountCeil,
labels: RangeLabels(
_amountRange.start.toStringAsFixed(0),
_amountRange.end.toStringAsFixed(0),
),
onChanged: (values) {
setState(() {
_exactAmountController.clear();
_rangeTouched = true;
_amountRange = values;
});
),
onChanged: (_) {
setState(() {
_rangeTouched = false;
_amountRange = RangeValues(0, _amountCeil);
});
},
),
const SizedBox(height: 12),
Text(
'Range',
style: theme.textTheme.bodySmall?.copyWith(
color: colors.onSurfaceVariant,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Text(
_rangeTouched
? '${_amountRange.start.toStringAsFixed(0)} – ${_amountRange.end.toStringAsFixed(0)}'
: 'Any amount',
style: theme.textTheme.bodySmall?.copyWith(
color: colors.onSurfaceVariant,
),
),
RangeSlider(
values: _amountRange,
min: 0,
max: _amountCeil,
labels: RangeLabels(
_amountRange.start.toStringAsFixed(0),
_amountRange.end.toStringAsFixed(0),
),
onChanged: (values) {
setState(() {
_exactAmountController.clear();
_rangeTouched = true;
_amountRange = values;
});
},
),
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: !_rangeTouched
? null
: () {
setState(() {
_rangeTouched = false;
_amountRange = RangeValues(0, _amountCeil);
});
},
child: const Text('Reset range'),
),
),
const SizedBox(height: 8),
Text('Labels', style: sectionStyle),
const SizedBox(height: 8),
TextField(
controller: _labelSearchController,
decoration: InputDecoration(
isDense: true,
hintText: 'Filter labels',
prefixIcon: const Icon(Icons.search, size: 20),
suffixIcon: needle.isEmpty
? null
: IconButton(
onPressed: () {
_labelSearchController.clear();
setState(() {});
},
icon: const Icon(Icons.clear, size: 18),
),
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: !_rangeTouched
? null
: () {
setState(() {
_rangeTouched = false;
_amountRange =
RangeValues(0, _amountCeil);
});
},
child: const Text('Reset range'),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(24, 4, 24, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('Labels', style: sectionStyle),
const SizedBox(height: 8),
TextField(
controller: _labelSearchController,
decoration: InputDecoration(
isDense: true,
hintText: 'Filter labels',
prefixIcon: const Icon(Icons.search, size: 20),
suffixIcon: needle.isEmpty
? null
: IconButton(
onPressed: () {
_labelSearchController.clear();
setState(() {});
},
icon: const Icon(Icons.clear, size: 18),
),
),
onChanged: (_) => setState(() {}),
),
Row(
children: [
TextButton(
onPressed: () {
setState(() {
_selected
..clear()
..addAll(entries.map((e) => e.label.id));
if (showUncategorized) {
_selected.add(kUncategorizedFilterId);
}
});
},
child: const Text('All labels'),
),
TextButton(
onPressed: () =>
setState(() => _selected.clear()),
child: const Text('No labels'),
),
],
),
],
onChanged: (_) => setState(() {}),
),
Row(
children: [
TextButton(
onPressed: () {
setState(() {
_selected
..clear()
..addAll(entries.map((e) => e.label.id));
if (showUncategorized) {
_selected.add(kUncategorizedFilterId);
}
});
},
child: const Text('All labels'),
),
),
Expanded(
flex: 3,
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 0, 24, 8),
child: _LabelChecklist(
entries: entries,
showUncategorized: showUncategorized,
selected: _selected,
onToggle: _toggle,
allowMove: false,
),
TextButton(
onPressed: () => setState(() => _selected.clear()),
child: const Text('No labels'),
),
),
],
),
],
),
const SizedBox(height: 4),
// Inline (no nested scroll) so the whole sheet scrolls as one.
_LabelChecklist(
entries: entries,
showUncategorized: showUncategorized,
selected: _selected,
onToggle: _toggle,
allowMove: false,
shrinkWrap: true,
),
const SizedBox(height: 12),
],
),
Padding(
padding: const EdgeInsets.fromLTRB(24, 4, 24, 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
FilledButton(
onPressed: _apply,
child: const Text('Apply'),
),
const SizedBox(height: 4),
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(24, 4, 24, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
FilledButton(
onPressed: _apply,
child: const Text('Apply'),
),
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
],
),
],
),
),
],
);
}
}
@@ -804,6 +778,7 @@ class _LabelChecklist extends StatelessWidget {
required this.selected,
required this.onToggle,
required this.allowMove,
this.shrinkWrap = false,
});
final List<LabelTreeEntry> entries;
@@ -811,6 +786,7 @@ class _LabelChecklist extends StatelessWidget {
final Set<String> selected;
final void Function(String id, bool selected) onToggle;
final bool allowMove;
final bool shrinkWrap;
@override
Widget build(BuildContext context) {
@@ -850,6 +826,10 @@ class _LabelChecklist extends StatelessWidget {
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: ListView.separated(
shrinkWrap: shrinkWrap,
physics: shrinkWrap
? const NeverScrollableScrollPhysics()
: null,
padding: const EdgeInsets.symmetric(vertical: 4),
itemCount: entries.length + (showUncategorized ? 1 : 0),
separatorBuilder: (_, _) => Divider(
+6 -5
View File
@@ -147,14 +147,17 @@ class _SimilarMatchDialogState extends State<_SimilarMatchDialog> {
final theme = Theme.of(context);
final colors = theme.colorScheme;
final matches = _matches;
final maxListHeight = MediaQuery.sizeOf(context).height * 0.35;
final media = MediaQuery.of(context);
final maxContentHeight =
((media.size.height - media.viewInsets.bottom) * 0.55)
.clamp(240.0, 560.0);
return AlertDialog(
title: const Text('Match similar'),
content: SizedBox(
width: double.maxFinite,
height: maxContentHeight,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextField(
@@ -212,8 +215,7 @@ class _SimilarMatchDialogState extends State<_SimilarMatchDialog> {
),
),
const SizedBox(height: 6),
ConstrainedBox(
constraints: BoxConstraints(maxHeight: maxListHeight),
Expanded(
child: DecoratedBox(
decoration: BoxDecoration(
color: colors.surfaceContainerHighest,
@@ -233,7 +235,6 @@ class _SimilarMatchDialogState extends State<_SimilarMatchDialog> {
),
)
: ListView.separated(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(vertical: 4),
itemCount: matches.length,
separatorBuilder: (_, _) => Divider(