Skip to content

Commit

Permalink
prepa 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
byackee committed Nov 25, 2024
1 parent 192e9d0 commit 828fcba
Show file tree
Hide file tree
Showing 28 changed files with 3,394 additions and 1,342 deletions.
4 changes: 1 addition & 3 deletions android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions lib/generated/intl/messages_all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ MessageLookupByLibrary? _findExact(String localeName) {

/// User programs should call this before using [localeName] for messages.
Future<bool> initializeMessages(String localeName) {
var availableLocale = Intl.verifiedLocale(localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null);
var availableLocale = Intl.verifiedLocale(
localeName, (locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null);
if (availableLocale == null) {
return new SynchronousFuture(false);
}
Expand All @@ -74,7 +76,8 @@ bool _messagesExistFor(String locale) {
}

MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
var actualLocale =
Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
if (actualLocale == null) return null;
return _findExact(actualLocale);
}
282 changes: 190 additions & 92 deletions lib/generated/intl/messages_en.dart

Large diffs are not rendered by default.

350 changes: 236 additions & 114 deletions lib/generated/intl/messages_es.dart

Large diffs are not rendered by default.

344 changes: 231 additions & 113 deletions lib/generated/intl/messages_fr.dart

Large diffs are not rendered by default.

338 changes: 228 additions & 110 deletions lib/generated/intl/messages_it.dart

Large diffs are not rendered by default.

348 changes: 234 additions & 114 deletions lib/generated/intl/messages_pt.dart

Large diffs are not rendered by default.

81 changes: 56 additions & 25 deletions lib/generated/intl/messages_zh.dart

Large diffs are not rendered by default.

70 changes: 67 additions & 3 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@
"secondary": "Secondary",
"apyHistory": "APY History",
"roiHistory": "ROI History",
"barChart": "Bar Chart",
"lineChart": "Line Chart",
"rentDistribution": "Rent Distribution",
"country": "Country",
"region": "Region",
"city": "City",
"@propertyMaintenanceMonthly": {
"description": "Monthly maintenance expenses for the property"
},
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/intl_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@
"secondary": "Secundario",
"apyHistory": "Historial APY",
"roiHistory": "Historial ROI",
"barChart": "Gráfico de barras",
"lineChart": "Gráfico de líneas",
"rentDistribution": "Distribución de alquileres",
"country": "País",
"region": "Región",
"city": "Ciudad",
"@propertyMaintenanceMonthly": {
"description": "Gastos mensuales de mantenimiento de la propiedad"
},
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@
"secondary": "Secondaire",
"apyHistory": "Historique APY",
"roiHistory": "Historique ROI",
"barChart": "Diagramme en barres",
"lineChart": "Diagramme linéaire",
"rentDistribution": "Répartition des loyers",
"country": "Pays",
"region": "Région",
"city": "Ville",
"@propertyMaintenanceMonthly": {
"description": "Dépenses mensuelles d'entretien de la propriété"
},
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/intl_it.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@
"secondary": "Secondario",
"apyHistory": "Storico APY",
"roiHistory": "Storico ROI",
"barChart": "Grafico a barre",
"lineChart": "Grafico a linee",
"rentDistribution": "Distribuzione degli affitti",
"country": "Paese",
"region": "Regione",
"city": "Città",
"@propertyMaintenanceMonthly": {
"description": "Spese mensili di manutenzione della proprietà"
},
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/intl_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@
"secondary": "Secundário",
"apyHistory": "Histórico APY",
"roiHistory": "Histórico ROI",
"barChart": "Gráfico de barras",
"lineChart": "Gráfico de linhas",
"rentDistribution": "Distribuição de aluguéis",
"country": "País",
"region": "Região",
"city": "Cidade",
"@propertyMaintenanceMonthly": {
"description": "Despesas mensais de manutenção da propriedade"
},
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@
"secondary": "次要",
"apyHistory": "APY 历史",
"roiHistory": "ROI 历史",
"barChart": "柱状图",
"lineChart": "折线图",
"rentDistribution": "租金分配",
"country": "国家",
"region": "地区",
"city": "城市",
"@propertyMaintenanceMonthly": {
"description": "物业的每月维护费用"
},
Expand Down
148 changes: 144 additions & 4 deletions lib/pages/Statistics/portfolio_stats.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ class _PortfolioStats extends State<PortfolioStats> {
static final logger = Logger(); // Initialiser une instance de logger

late String _selectedPeriod;
late String _selectedFilter; // Ajoutez une variable pour le filtre

@override
void initState() {
super.initState();
_selectedFilter = 'Region'; // Valeur par défaut

SchedulerBinding.instance.addPostFrameCallback((_) async {
try {
final dataManager = Provider.of<DataManager>(context, listen: false);
Expand Down Expand Up @@ -150,26 +153,163 @@ class _PortfolioStats extends State<PortfolioStats> {
// Return widgets based on index
switch (index) {
case 0:
return _buildTokenDistributionCard(dataManager!);
return _buildRentDistributionCard(dataManager!);
case 1:
return _buildTokenDistributionByCountryCard(dataManager!);
return _buildTokenDistributionCard(dataManager!);
case 2:
return _buildTokenDistributionByRegionCard(dataManager!);
return _buildTokenDistributionByCountryCard(dataManager!);
case 3:
return _buildTokenDistributionByRegionCard(dataManager!);
case 4:
return _buildTokenDistributionByCityCard(dataManager!);
default:
return Container();
}
},
childCount: 4, // Total number of chart widgets
childCount: 5, // Total number of chart widgets
),
),
),
],
),
);
}

Widget _buildRentDistributionCard(DataManager dataManager) {
final appState = Provider.of<AppState>(context);

return Card(
elevation: 0,
color: Theme.of(context).cardColor,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
S.of(context).rentDistribution,
style: TextStyle(
fontSize: 20 + appState.getTextSizeOffset(),
fontWeight: FontWeight.bold,
),
),
DropdownButton<String>(
value: _selectedFilter,
items: [
DropdownMenuItem(value: 'Country', child: Text(S.of(context).country)),
DropdownMenuItem(value: 'Region', child: Text(S.of(context).region)),
DropdownMenuItem(value: 'City', child: Text(S.of(context).city)),
],
onChanged: (String? value) {
setState(() {
_selectedFilter = value!;
});
},
),
],
),
const SizedBox(height: 20),
SizedBox(
height: 200,
child: PieChart(
PieChartData(
sections: _buildRentDonutChartData(dataManager),
centerSpaceRadius: 50,
sectionsSpace: 2,
borderData: FlBorderData(show: false),
),
),
),
const SizedBox(height: 20),
_buildRentLegend(dataManager),
],
),
),
);
}

Widget _buildRentLegend(DataManager dataManager) {
final Map<String, double> groupedData = _groupRentDataBySelectedFilter(dataManager);
final appState = Provider.of<AppState>(context);

return Wrap(
spacing: 8.0,
runSpacing: 4.0,
children: groupedData.entries.map((entry) {
final index = groupedData.keys.toList().indexOf(entry.key);
final color = generateColor(index);

return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 16,
height: 16,
color: color,
),
const SizedBox(width: 4),
Text(
'${entry.key}: ${Utils.formatCurrency(dataManager.convert(entry.value), dataManager.currencySymbol)}',
style: TextStyle(fontSize: 13 + appState.getTextSizeOffset()),
),
],
);
}).toList(),
);
}


List<PieChartSectionData> _buildRentDonutChartData(DataManager dataManager) {
final Map<String, double> groupedData = _groupRentDataBySelectedFilter(dataManager);

final totalRent = groupedData.values.fold(0.0, (sum, value) => sum + value);

return groupedData.entries.map((entry) {
final percentage = (entry.value / totalRent) * 100;
return PieChartSectionData(
value: entry.value,
title: '${percentage.toStringAsFixed(1)}%',
color: generateColor(groupedData.keys.toList().indexOf(entry.key)),
radius: 50,
titleStyle: TextStyle(
fontSize: 10 + Provider.of<AppState>(context).getTextSizeOffset(),
color: Colors.white,
fontWeight: FontWeight.bold,
),
);
}).toList();
}

Map<String, double> _groupRentDataBySelectedFilter(DataManager dataManager) {
Map<String, double> groupedData = {};

for (var token in dataManager.portfolio) {
String key;
switch (_selectedFilter) {
case 'Country':
key = token['country'] ?? 'Unknown Country';
break;
case 'Region':
key = token['regionCode'] ?? 'Unknown Region';
break;
case 'City':
key = token['city'] ?? 'Unknown City';
break;
default:
key = 'Unknown';
}

// Additionner les revenus locatifs (monthlyIncome)
groupedData[key] = (groupedData[key] ?? 0) + (token['monthlyIncome'] ?? 0.0);
}

return groupedData;
}


Widget _buildTokenDistributionCard(DataManager dataManager) {
final appState = Provider.of<AppState>(context);

Expand Down
Loading

0 comments on commit 828fcba

Please sign in to comment.