Skip to content

Commit

Permalink
Merge pull request #129 from lucaantonelli/main
Browse files Browse the repository at this point in the history
Transactions page filters + dashboard real data + settings improvement
  • Loading branch information
lucaantonelli authored Dec 29, 2023
2 parents 44d85b2 + 1a4af39 commit c4556a5
Show file tree
Hide file tree
Showing 57 changed files with 2,883 additions and 2,981 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/flutter-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
- name: Flutter action
uses: subosito/flutter-action@v2
with:
flutter-version: '3.13.9'
flutter-version: '3.16.5'
channel: stable
cache: true
cache-key: flutter
cache-path: ${{ runner.tool_cache }}/flutter

- run: |
flutter pub get
flutter test
Expand Down
11 changes: 6 additions & 5 deletions lib/constants/functions.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

import '../constants/style.dart';
import '../model/transaction.dart';

mixin Functions {
String numToCurrency(num? value) {
if (value == null) return '';
return value.toStringAsFixed(2).replaceAll(".", ",");
return value.toStringAsFixed(2);
}

num currencyToNum(String value) {
Expand All @@ -21,13 +22,13 @@ mixin Functions {
return format.format(date);
}

Color typeToColor(Type type) {
Color typeToColor(TransactionType type) {
switch (type) {
case Type.income:
case TransactionType.income:
return green;
case Type.expense:
case TransactionType.expense:
return red;
case Type.transfer:
case TransactionType.transfer:
return blue3;
default:
return blue3;
Expand Down
2 changes: 0 additions & 2 deletions lib/custom_widgets/account_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ class AccountDialog extends StatelessWidget with Functions {
line2Data: <FlSpot>[],
colorLine2Data: Color(0xffffffff),
colorBackground: Color(0xff356CA3),
maxY: 5.0,
minY: -5.0,
maxDays: 30.0,
),
const Padding(
Expand Down
74 changes: 23 additions & 51 deletions lib/custom_widgets/accounts_sum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class AccountsSum extends ConsumerWidget with Functions {
final BankAccount account;

const AccountsSum({
Key? key,
super.key,
required this.account,
}) : super(key: key);
});

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand All @@ -40,8 +40,7 @@ class AccountsSum extends ConsumerWidget with Functions {
await ref
.read(accountsProvider.notifier)
.selectedAccount(account)
.whenComplete(
() => Navigator.of(context).pushNamed('/account'));
.whenComplete(() => Navigator.of(context).pushNamed('/account'));
},
child: Container(
padding: const EdgeInsets.fromLTRB(12, 8, 12, 8),
Expand All @@ -68,53 +67,26 @@ class AccountsSum extends ConsumerWidget with Functions {
children: [
Text(
account.name,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(color: darkBlue7),
), // TODO: set dinamically instead of hardcoded
FutureBuilder<num?>(
future: BankAccountMethods().getAccountSum(account.id),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
// Show a loading indicator while waiting for the future to complete
return Transform.scale(
scale: 0.5,
child: const CircularProgressIndicator(),
);
} else if (snapshot.hasError) {
// Show an error message if the future encounters an error
return Text('Error: ${snapshot.error}');
} else {
// Display the result once the future completes successfully
final accountSum = snapshot.data ?? 0;
return RichText(
textScaleFactor:
MediaQuery.of(context).textScaleFactor,
text: TextSpan(
children: [
TextSpan(
text: numToCurrency(accountSum),
style:
Theme.of(context).textTheme.titleSmall!.copyWith(color: darkBlue7),
),
TextSpan(
text: "€",
style: Theme.of(context)
.textTheme
.bodyMedium
?.apply(
fontFeatures: [
const FontFeature.subscripts()
],
).copyWith(color: darkBlue7),
),
],
),
);
}
},
style: Theme.of(context).textTheme.bodyLarge!.copyWith(color: darkBlue7),
),
RichText(
text: TextSpan(
children: [
TextSpan(
text: numToCurrency(account.total),
style: Theme.of(context)
.textTheme
.titleSmall!
.copyWith(color: darkBlue7),
),
TextSpan(
text: "€",
style: Theme.of(context).textTheme.bodyMedium?.apply(
fontFeatures: [const FontFeature.subscripts()],
).copyWith(color: darkBlue7),
),
],
),
),
],
),
Expand Down
38 changes: 38 additions & 0 deletions lib/custom_widgets/default_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';

import 'default_container.dart';

class DefaultCard extends StatefulWidget {
const DefaultCard({required this.child, required this.onTap, super.key});

final Widget child;
final GestureTapCallback? onTap;

@override
State<DefaultCard> createState() => _DefaultCardState();
}

class _DefaultCardState extends State<DefaultCard> {
@override
Widget build(BuildContext context) {
return DefaultContainer(
padding: const EdgeInsets.all(0),
child: Material(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(8),
child: InkWell(
borderRadius: BorderRadius.circular(8),
onTap: widget.onTap,
child: Ink(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(8),
),
child: widget.child,
),
),
),
);
}
}
25 changes: 6 additions & 19 deletions lib/custom_widgets/default_container.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:flutter/material.dart';

import '../constants/style.dart';

class DefaultContainer extends StatefulWidget {
const DefaultContainer({required this.child, required this.onTap, super.key});
const DefaultContainer({required this.child, this.padding = const EdgeInsets.all(16.0), super.key});

final Widget child;
final GestureTapCallback? onTap;
final EdgeInsetsGeometry? padding;

@override
State<DefaultContainer> createState() => _DefaultContainerState();
Expand All @@ -15,28 +16,14 @@ class _DefaultContainerState extends State<DefaultContainer> {
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16.0),
padding: widget.padding,
margin: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(8),
boxShadow: [defaultShadow],
),
child: Material(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(8),
child: InkWell(
borderRadius: BorderRadius.circular(8),
onTap: widget.onTap,
child: Ink(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(8),
),
child: widget.child,
),
),
),
child: widget.child,
);
}
}
Loading

0 comments on commit c4556a5

Please sign in to comment.