Skip to content

Commit

Permalink
Merge branch 'RIP-Comm:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
giovanni-ercolano authored May 6, 2024
2 parents 08c52fb + 7aa5bd7 commit d1a3d33
Show file tree
Hide file tree
Showing 50 changed files with 2,126 additions and 336 deletions.
Binary file added assets/openVault.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
31 changes: 28 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
PODS:
- Flutter (1.0.0)
- flutter_local_notifications (0.0.1):
- Flutter
- flutter_native_splash (0.0.1):
- Flutter
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- permission_handler_apple (9.3.0):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- sqflite (0.0.3):
- Flutter
- FMDB (>= 2.7.5)
Expand All @@ -25,13 +32,19 @@ PODS:
- sqlite3/rtree
- url_launcher_ios (0.0.1):
- Flutter
- workmanager (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- workmanager (from `.symlinks/plugins/workmanager/ios`)

SPEC REPOS:
trunk:
Expand All @@ -41,24 +54,36 @@ SPEC REPOS:
EXTERNAL SOURCES:
Flutter:
:path: Flutter
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
sqlite3_flutter_libs:
:path: ".symlinks/plugins/sqlite3_flutter_libs/ios"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
workmanager:
:path: ".symlinks/plugins/workmanager/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
sqlite3: 6e2d4a4879854d0ec86b476bf3c3e30870bac273
sqlite3_flutter_libs: eb769059df0356dc52ddda040f09cacc9391a7cf
url_launcher_ios: 68d46cc9766d0c41dbdc884310529557e3cd7a86
workmanager: 0afdcf5628bbde6924c21af7836fed07b42e30e6

PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

COCOAPODS: 1.12.1
COCOAPODS: 1.15.2
26 changes: 22 additions & 4 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
211392328957DBA96447070D /* [CP] Embed Pods Frameworks */,
6090A52EFEF53161A56AE5DE /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -216,7 +217,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down Expand Up @@ -303,6 +304,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
6090A52EFEF53161A56AE5DE /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -453,7 +471,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -580,7 +598,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -629,7 +647,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
7 changes: 6 additions & 1 deletion lib/custom_widgets/budget_circular_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ class BudgetCircularIndicator extends ConsumerWidget with Functions {
progressColor: color,
),
const SizedBox(height: 10),
Text(title, style: Theme.of(context).textTheme.labelMedium),
Row(
children: [
perc >= 0.9 ? const Icon(Icons.error_outline, color: Colors.red, size: 15) : Container(),
const SizedBox(width: 3),
Text(title, style: Theme.of(context).textTheme.bodyLarge),
])
],
);
}
Expand Down
27 changes: 23 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:workmanager/workmanager.dart';
import 'package:sossoldi/utils/worker_manager.dart';

import 'pages/notifications/notifications_service.dart';
import 'providers/theme_provider.dart';
import 'routes.dart';
import 'utils/app_theme.dart';

void main() {
initializeDateFormatting('it_IT', null)
.then((_) => runApp(const ProviderScope(child: Launcher())));
bool? _isFirstLogin = true;

void main() async {
WidgetsFlutterBinding.ensureInitialized();
if(Platform.isAndroid){
requestNotificationPermissions();
initializeNotifications();
Workmanager().initialize(callbackDispatcher);
}
SharedPreferences preferences = await SharedPreferences.getInstance();

bool? getPref = preferences.getBool('is_first_login');
getPref == null ? await preferences.setBool('is_first_login', false) : null;
_isFirstLogin = getPref;

initializeDateFormatting('it_IT', null).then((_) => runApp(const ProviderScope(child: Launcher())));
}

class Launcher extends ConsumerWidget {
Expand All @@ -25,7 +44,7 @@ class Launcher extends ConsumerWidget {
themeMode:
appThemeState.isDarkModeEnabled ? ThemeMode.dark : ThemeMode.light,
onGenerateRoute: makeRoute,
initialRoute: '/',
initialRoute: _isFirstLogin == null || _isFirstLogin! ? '/onboarding' : '/',
);
}
}
2 changes: 1 addition & 1 deletion lib/model/bank_account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class BankAccountMethods extends SossoldiDatabase {
if (maps.isNotEmpty) {
return BankAccount.fromJson(maps.first);
} else {
throw Exception('Main Account not found');
return null;
}
}

Expand Down
67 changes: 67 additions & 0 deletions lib/model/budget.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '../model/transaction.dart';
import '../database/sossoldi_database.dart';
import '../model/category_transaction.dart';
import 'base_entity.dart';
Expand Down Expand Up @@ -78,13 +79,62 @@ class Budget extends BaseEntity {
};
}

class BudgetStats extends BaseEntity {
final int idCategory;
final String? name;
final num amountLimit;
final num spent;

BudgetStats({required this.idCategory, required this.name, required this.amountLimit, required this.spent});

static BudgetStats fromJson(Map<String, Object?> json) => BudgetStats(
idCategory: json[BudgetFields.idCategory] as int,
name: json[BudgetFields.name] as String?,
amountLimit: json[BudgetFields.amountLimit] as num,
spent: json['spent'] as num);

Map<String, Object?> toJson() => {
BudgetFields.idCategory: idCategory,
BudgetFields.name: name,
BudgetFields.amountLimit: amountLimit,
'spent': spent
};
}

class BudgetMethods extends SossoldiDatabase {
Future<Budget> insert(Budget item) async {
final db = await database;
final id = await db.insert(budgetTable, item.toJson());
return item.copy(id: id);
}

Future<Budget> insertOrUpdate(Budget item) async {
final db = await database;

final exists = await checkIfExists(item);
if (exists) {
await db.rawQuery("UPDATE $budgetTable SET amountLimit = ${item.amountLimit} WHERE idCategory = ${item.idCategory}");
} else {
await db.insert(budgetTable, item.toJson());
}

return item.copy(id: item.id);
}

Future<bool> checkIfExists(Budget item) async {
final db = await database;

try {
final exists = await db.rawQuery("SELECT * FROM ${budgetTable} WHERE ${item.idCategory} = idCategory");
if(exists.isNotEmpty) {
return true;
}
return false;
} catch (e) {
return false;
}
}

Future<Budget> selectById(int id) async {
final db = await database;

Expand Down Expand Up @@ -118,6 +168,17 @@ class BudgetMethods extends SossoldiDatabase {
return result.map((json) => Budget.fromJson(json)).toList();
}

Future<List<BudgetStats>> selectMonthlyBudgetsStats() async {
final db = await database;
var query = "SELECT bt.*, SUM(t.amount) as spent FROM $budgetTable as bt "
+ " LEFT JOIN $categoryTransactionTable as ct ON bt.${BudgetFields.idCategory} = ct.${CategoryTransactionFields.id} "
+ " LEFT JOIN '$transactionTable' as t ON t.${TransactionFields.idCategory} = ct.${CategoryTransactionFields.id} "
+ " WHERE bt.active = 1 AND strftime('%m', t.date) = strftime('%m', 'now') AND strftime('%Y', t.date) = strftime('%Y', 'now') "
+ " GROUP BY bt.${BudgetFields.idCategory};";
final result = await db.rawQuery(query);
return result.map((json) => BudgetStats.fromJson(json)).toList();
}

Future<int> updateItem(Budget item) async {
final db = await database;

Expand All @@ -135,4 +196,10 @@ class BudgetMethods extends SossoldiDatabase {

return await db.delete(budgetTable, where: '${BudgetFields.id} = ?', whereArgs: [id]);
}

Future<int> deleteByCategory(int id) async {
final db = await database;

return await db.delete(budgetTable, where: '${BudgetFields.idCategory} = ?', whereArgs: [id]);
}
}
7 changes: 7 additions & 0 deletions lib/model/currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ class CurrencyMethods extends SossoldiDatabase {
return item.copy(id: id);
}

Future<void> insertAll(List<Currency> list) async {
final db = await database;
for(Currency currency in list){
await db.insert(currencyTable, currency.toJson());
}
}

Future<Currency> selectById(int id) async {
final db = await database;

Expand Down
14 changes: 12 additions & 2 deletions lib/pages/add_page/widgets/amount_section.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import "package:flutter_riverpod/flutter_riverpod.dart";

import '../../../constants/functions.dart';
Expand Down Expand Up @@ -162,7 +163,7 @@ class _AmountSectionState extends ConsumerState<AmountSection> with Functions {
),
const Spacer(),
Text(
ref.watch(bankAccountProvider)!.name,
ref.watch(bankAccountProvider)?.name ?? "",
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: grey1,
),
Expand Down Expand Up @@ -282,7 +283,10 @@ class _AmountSectionState extends ConsumerState<AmountSection> with Functions {
.headlineMedium!
.copyWith(color: typeToColor(selectedType)),
),
keyboardType: const TextInputType.numberWithOptions(decimal: true),
keyboardType: const TextInputType.numberWithOptions(decimal: true, signed: true),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d{0,2}')),
],
// inputFormatters: [DecimalTextInputFormatter(decimalDigits: 2)],
autofocus: false,
textAlign: TextAlign.center,
Expand All @@ -292,6 +296,12 @@ class _AmountSectionState extends ConsumerState<AmountSection> with Functions {
fontSize: 58,
fontWeight: FontWeight.bold,
),
onTapOutside: (_){
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/add_page/widgets/category_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class _CategorySelectorState extends ConsumerState<CategorySelector> with Functi
width: double.infinity,
child: categoriesList.when(
data: (categories) => ListView.builder(
itemCount: 4,
itemCount: categories.length, // to prevent range error
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemBuilder: (context, i) {
Expand Down
Loading

0 comments on commit d1a3d33

Please sign in to comment.