Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Jan 2, 2024
1 parent cbb5e9d commit 84cf3a5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603

- name: Install dependencies
run: dart pub get
run: flutter pub get

# Uncomment this step to verify the use of 'dart format' on each commit.
# - name: Verify formatting
Expand Down
1 change: 1 addition & 0 deletions lib/api/apis/backup_api.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:convert';
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;


Expand Down
13 changes: 12 additions & 1 deletion lib/domain/models/goal.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:wealth_wave/api/db/app_database.dart';
import 'package:wealth_wave/contract/goal_importance.dart';
import 'package:wealth_wave/domain/models/investment.dart';
Expand Down Expand Up @@ -51,14 +53,23 @@ class Goal {
}

double getInvestedValue() {
if(taggedInvestments.isEmpty){
if (taggedInvestments.isEmpty) {
return 0;
}
return taggedInvestments.keys
.map((e) => (e.value / 100) * (taggedInvestments[e] ?? 0))
.reduce((a, b) => a + b);
}

double getFutureValueOnTargetDate() {
double yearsLeft = getYearsLeft();
double growthRate = getIrr();
double value = getInvestedValue();

double progressedValue = value * pow(1 + growthRate, yearsLeft);
return progressedValue;
}

double getProgress() {
double progress = targetAmount > 0 ? getInvestedValue() / targetAmount : 0;
return progress;
Expand Down
9 changes: 9 additions & 0 deletions lib/ui/pages/goals_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ class _GoalsPage extends PageState<GoalsViewState, GoalsPage, GoalsPresenter> {
style: Theme.of(context).textTheme.bodyMedium),
Text('(Invested Amount)',
style: Theme.of(context).textTheme.labelSmall),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(formatToCurrency(goal.getFutureValueOnTargetDate()),
style: Theme.of(context).textTheme.bodyMedium),
Text('(Predicted Amount at Target Date)',
style: Theme.of(context).textTheme.labelSmall),
Text(formatToPercentage(goal.getIrr()),
style: Theme.of(context).textTheme.bodyMedium),
Text('(Growth Rate)',
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/widgets/create_goal_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Future<void> showCreateGoalDialog(
class _CreateGoalDialog extends StatefulWidget {
final Goal? goalToUpdate;

const _CreateGoalDialog({super.key, this.goalToUpdate});
const _CreateGoalDialog({this.goalToUpdate});

@override
State<_CreateGoalDialog> createState() => _CreateGoalPage();
Expand Down
6 changes: 4 additions & 2 deletions lib/utils/ui_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ String formatDate(DateTime date) {

String formatToPercentage(double value) {
double percentage = value * 100;
return percentage == percentage.round() ? '${percentage.round()}%' : '${percentage.toStringAsFixed(2)}%';
return percentage == percentage.round()
? '${percentage.round()}%'
: '${percentage.toStringAsFixed(2)}%';
}

String formatToCurrency(double value) {
return NumberFormat.currency(locale: 'en_IN', symbol: '\').format(value);
return NumberFormat.currency(locale: 'en_IN', symbol: '₹').format(value);
}

0 comments on commit 84cf3a5

Please sign in to comment.