feat: allow switching between bar nad line charts

This commit is contained in:
Matyáš Caras 2023-12-25 19:03:52 +01:00
parent 7830f7854e
commit 1c4bc48e6f
Signed by untrusted user who does not match committer: hernik
GPG key ID: 2A3175F98820C5C6
15 changed files with 729 additions and 206 deletions

View file

@ -1,2 +1,5 @@
# 1.0.0-alpha.2
- Fixed localization issues
- Added graphs for expenses and income per month/year
# 1.0.0-alpha # 1.0.0-alpha
- First public release - First public release

View file

@ -1,3 +1,4 @@
arb-dir: lib/l10n arb-dir: lib/l10n
template-arb-file: app_en.arb template-arb-file: app_en.arb
output-localization-file: app_localizations.dart output-localization-file: app_localizations.dart
nullable-getter: false

View file

@ -1,4 +1,5 @@
{ {
"@@locale": "cs",
"categoryHealth": "Zdraví", "categoryHealth": "Zdraví",
"categoryCar": "Auto", "categoryCar": "Auto",
"categoryFood": "Jídlo", "categoryFood": "Jídlo",
@ -48,9 +49,9 @@
"ocr": "OCR", "ocr": "OCR",
"ocrData": "OCR Data", "ocrData": "OCR Data",
"downloaded": "Staženo", "downloaded": "Staženo",
"deleteOcr": "Opravdu chcete smazat '$lang' OCR data?\nJiž tato data nebudete moct použít při skenování obrázků.", "deleteOcr": "Opravdu chcete smazat '{lang}' OCR data?\nJiž tato data nebudete moct použít při skenování obrázků.",
"langDownloadDialog": "Stahuji $lang, vyčkejte prosím...", "langDownloadDialog": "Stahuji {lang}, vyčkejte prosím...",
"langDownloadProgress": "Postup: $progress %", "langDownloadProgress": "Postup: {progress} %",
"addingFromOcr": "Přidat skrz OCR", "addingFromOcr": "Přidat skrz OCR",
"license":"©️ 2023 Matyáš Caras\nVydáno pod licencí GNU AGPL license verze 3", "license":"©️ 2023 Matyáš Caras\nVydáno pod licencí GNU AGPL license verze 3",
"description":"Popis", "description":"Popis",
@ -61,6 +62,16 @@
"createTestData":"Vytvořit vzorková data", "createTestData":"Vytvořit vzorková data",
"yearly":"Roční", "yearly":"Roční",
"monthly":"Měsíční", "monthly":"Měsíční",
"expenses":"Výdaje" "expenses":"Výdaje",
"expensesForMonth": "Výdaje za {month}: {value}",
"incomeForMonth": "Příjmy za {month}: {value}",
"expensesForDay": "Výdaje: {value}",
"incomeForDay": "Příjmy: {value}",
"settingsAppearance":"Vzhled",
"graphType":"Druh grafu",
"graphTypeDesc":"Zvolte, zda-li použít sloupcový, nebo spojnicový graf, a kde",
"lineChart":"Spojnicový",
"barChart":"Sloupcový",
"selectType":"Zvolte typ"
} }

View file

@ -1,4 +1,5 @@
{ {
"@@locale": "en",
"categoryHealth": "Health", "categoryHealth": "Health",
"categoryCar": "Car", "categoryCar": "Car",
"categoryFood": "Food", "categoryFood": "Food",
@ -57,7 +58,7 @@
"ocr": "OCR", "ocr": "OCR",
"ocrData": "OCR Data", "ocrData": "OCR Data",
"downloaded": "Downloaded", "downloaded": "Downloaded",
"deleteOcr": "Do you really want to delete '$lang' OCR data?\nYou will not be able to use these language data when scanning pictures.", "deleteOcr": "Do you really want to delete '{lang}' OCR data?\nYou will not be able to use these language data when scanning pictures.",
"@deleteOcr": { "@deleteOcr": {
"description": "Shown when a user wants to delete OCR data through settings", "description": "Shown when a user wants to delete OCR data through settings",
"placeholders": { "placeholders": {
@ -67,7 +68,7 @@
} }
} }
}, },
"langDownloadDialog": "Downloading $lang, please wait...", "langDownloadDialog": "Downloading {lang}, please wait...",
"@langDownloadDialog": { "@langDownloadDialog": {
"description": "Shown as a title of a dialog while downloading new OCR data", "description": "Shown as a title of a dialog while downloading new OCR data",
"placeholders": { "placeholders": {
@ -77,7 +78,7 @@
} }
} }
}, },
"langDownloadProgress": "Download progress: $progress %", "langDownloadProgress": "Download progress: {progress} %",
"@langDownloadProgress": { "@langDownloadProgress": {
"description": "Progress percentage shown while downloading OCR data", "description": "Progress percentage shown while downloading OCR data",
"placeholders": { "placeholders": {
@ -97,5 +98,59 @@
"createTestData": "Create test data", "createTestData": "Create test data",
"yearly": "Yearly", "yearly": "Yearly",
"monthly": "Monthly", "monthly": "Monthly",
"expenses":"Expenses" "expenses": "Expenses",
"expensesForMonth": "{month} expenses: {value}",
"@expensesForMonth": {
"description": "Shown as a tooltip when touching expense graph",
"placeholders": {
"month": {
"type": "String",
"example": "January"
},
"value": {
"type": "String",
"example": "5000 Kč"
}
}
},
"incomeForMonth": "{month} income: {value}",
"@incomeForMonth": {
"description": "Shown as a tooltip when touching income graph",
"placeholders": {
"month": {
"type": "String",
"example": "January"
},
"value": {
"type": "String",
"example": "5000 Kč"
}
}
},
"expensesForDay": "Expenses: {value}",
"@expensesForDay":{
"description": "Shown as a tooltip when touching expense graph",
"placeholders": {
"value": {
"type": "String",
"example": "5000 Kč"
}
}
},
"incomeForDay": "Income: {value}",
"@incomeForDay":{
"description": "Shown as a tooltip when touching expense graph",
"placeholders": {
"value": {
"type": "String",
"example": "5000 Kč"
}
}
},
"settingsAppearance":"Appearance",
"graphType":"Graph type",
"graphTypeDesc":"Choose whether to show line or bar chart and where",
"lineChart":"Line chart",
"barChart":"Bar chart",
"selectType":"Select type"
} }

View file

@ -12,7 +12,7 @@ Drawer makeDrawer(BuildContext context, int page) => Drawer(
ListTile( ListTile(
leading: const Icon(Icons.home), leading: const Icon(Icons.home),
title: Text( title: Text(
AppLocalizations.of(context)!.home, AppLocalizations.of(context).home,
), ),
selected: page == 1, selected: page == 1,
onTap: () { onTap: () {
@ -27,7 +27,7 @@ Drawer makeDrawer(BuildContext context, int page) => Drawer(
ListTile( ListTile(
leading: const Icon(Icons.bar_chart), leading: const Icon(Icons.bar_chart),
title: Text( title: Text(
AppLocalizations.of(context)!.graphs, AppLocalizations.of(context).graphs,
), ),
selected: page == 2, selected: page == 2,
onTap: () { onTap: () {

View file

@ -1,21 +1,24 @@
import 'package:currency_picker/currency_picker.dart';
import 'package:fl_chart/fl_chart.dart'; import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:prasule/main.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
/// Monthly/Yearly expense/income [LineChart] /// Monthly/Yearly expense/income [LineChart]
class ExpensesChart extends StatelessWidget { class ExpensesLineChart extends StatelessWidget {
const ExpensesChart( const ExpensesLineChart(
{super.key, {super.key,
required this.date, required this.date,
required this.locale, required this.locale,
this.expenseData = const [], required this.expenseData,
this.incomeData = const [], required this.incomeData,
required this.currency,
this.yearly = false}); this.yearly = false});
final bool yearly; final bool yearly;
final DateTime date; final DateTime date;
final String locale; final String locale;
final List<double> expenseData; final List<double> expenseData;
final Currency currency;
List<double> get expenseDataSorted { List<double> get expenseDataSorted {
var list = List<double>.from(expenseData); var list = List<double>.from(expenseData);
list.sort((a, b) => a.compareTo(b)); list.sort((a, b) => a.compareTo(b));
@ -43,10 +46,36 @@ class ExpensesChart extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return LineChart( return LineChart(
LineChartData( LineChartData(
maxX: (yearly) ? 12 : DateTime(date.year, date.month, 0).day.toDouble(), lineTouchData: LineTouchData(
touchTooltipData: LineTouchTooltipData(
getTooltipItems: (spots) => List<LineTooltipItem>.generate(
spots.length,
(index) => LineTooltipItem(
(yearly)
? AppLocalizations.of(context).expensesForMonth(
DateFormat.MMMM(locale).format(
DateTime(date.year, spots[index].x.toInt() + 1, 1)),
NumberFormat.compactCurrency(
locale: locale,
symbol: currency.symbol,
name: currency.name)
.format(spots[index].y))
: AppLocalizations.of(context).expensesForDay(
NumberFormat.compactCurrency(
locale: locale,
symbol: currency.symbol,
name: currency.name)
.format(spots[index].y),
),
TextStyle(color: spots[index].bar.color),
),
),
),
),
maxY: maxY, maxY: maxY,
minX: 1, maxX: (yearly) ? 12 : DateTime(date.year, date.month, 0).day.toDouble(),
minY: 0, minY: 0,
minX: 0,
backgroundColor: Theme.of(context).colorScheme.background, backgroundColor: Theme.of(context).colorScheme.background,
lineBarsData: [ lineBarsData: [
if (incomeData.isNotEmpty) if (incomeData.isNotEmpty)
@ -59,7 +88,7 @@ class ExpensesChart extends StatelessWidget {
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
spots: List.generate( spots: List.generate(
(yearly) ? 12 : DateTime(date.year, date.month, 0).day, (yearly) ? 12 : DateTime(date.year, date.month, 0).day,
(index) => FlSpot(index.toDouble() + 1, incomeData[index]), (index) => FlSpot(index.toDouble(), incomeData[index]),
), ),
), ),
if (expenseData.isNotEmpty) if (expenseData.isNotEmpty)
@ -85,15 +114,16 @@ class ExpensesChart extends StatelessWidget {
), ),
bottomTitles: AxisTitles( bottomTitles: AxisTitles(
sideTitles: SideTitles( sideTitles: SideTitles(
reservedSize: 30,
showTitles: true, showTitles: true,
getTitlesWidget: (value, meta) { getTitlesWidget: (value, meta) {
String text; String text;
if (yearly) { if (yearly) {
text = DateFormat.MMM(locale).format( text = DateFormat.MMM(locale).format(
DateTime(date.year, value.toInt(), 1), DateTime(date.year, value.toInt() + 1, 1),
); );
} else { } else {
text = value.toInt().toString(); text = (value.toInt() + 1).toString();
} }
return SideTitleWidget( return SideTitleWidget(
axisSide: meta.axisSide, child: Text(text)); axisSide: meta.axisSide, child: Text(text));
@ -105,3 +135,141 @@ class ExpensesChart extends StatelessWidget {
); );
} }
} }
class ExpensesBarChart extends StatelessWidget {
const ExpensesBarChart(
{super.key,
required this.yearly,
required this.date,
required this.locale,
required this.expenseData,
required this.incomeData,
required this.currency});
final bool yearly;
final DateTime date;
final String locale;
final List<double> expenseData;
List<double> get expenseDataSorted {
var list = List<double>.from(expenseData);
list.sort((a, b) => a.compareTo(b));
return list;
}
final Currency currency;
final List<double> incomeData;
List<double> get incomeDataSorted {
var list = List<double>.from(incomeData);
list.sort((a, b) => a.compareTo(b));
return list;
}
double get maxY {
if (incomeData.isEmpty) return expenseDataSorted.last;
if (expenseData.isEmpty) return incomeDataSorted.last;
if (expenseDataSorted.last > incomeDataSorted.last) {
return expenseDataSorted.last;
} else {
return incomeDataSorted.last;
}
}
@override
Widget build(BuildContext context) => BarChart(
BarChartData(
barTouchData: BarTouchData(
enabled: true,
touchTooltipData: BarTouchTooltipData(
getTooltipItem: (group, groupIndex, rod, rodIndex) =>
(yearly) // create custom tooltips for graph bars
? BarTooltipItem(
(rodIndex == 1)
? AppLocalizations.of(context).expensesForMonth(
DateFormat.MMMM(locale).format(
DateTime(date.year, groupIndex + 1, 1)),
NumberFormat.compactCurrency(
locale: locale,
symbol: currency.symbol,
name: currency.name)
.format(rod.toY),
)
: AppLocalizations.of(context).incomeForMonth(
DateFormat.MMMM(locale).format(
DateTime(date.year, groupIndex + 1, 1)),
NumberFormat.compactCurrency(
locale: locale,
symbol: currency.symbol,
name: currency.name)
.format(rod.toY),
),
TextStyle(color: rod.color),
)
: BarTooltipItem(
(rodIndex == 1)
? AppLocalizations.of(context).expensesForDay(
NumberFormat.compactCurrency(
locale: locale,
symbol: currency.symbol,
name: currency.name)
.format(rod.toY),
)
: AppLocalizations.of(context).incomeForDay(
NumberFormat.compactCurrency(
locale: locale,
symbol: currency.symbol,
name: currency.name)
.format(rod.toY),
),
TextStyle(color: rod.color),
),
),
),
titlesData: FlTitlesData(
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: 30,
getTitlesWidget: (value, meta) {
String text;
if (yearly) {
text = DateFormat.MMM(locale).format(
DateTime(date.year, value.toInt() + 1, 1),
);
} else {
text = (value.toInt() + 1).toString();
}
return SideTitleWidget(
axisSide: meta.axisSide, child: Text(text));
},
),
),
), // axis descriptions,
minY: 0,
maxY: maxY,
barGroups: List<BarChartGroupData>.generate(
(yearly) ? 12 : DateTime(date.year, date.month, 0).day,
(index) => BarChartGroupData(
x: index,
barRods: [
if (incomeData.isNotEmpty)
BarChartRodData(
toY: incomeData[index],
color: Theme.of(context).colorScheme.primary,
),
if (expenseData.isNotEmpty)
BarChartRodData(
toY: expenseData[index],
color: Theme.of(context).colorScheme.error,
),
],
),
),
),
);
}

View file

@ -40,7 +40,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(AppLocalizations.of(context)!.createEntry), title: Text(AppLocalizations.of(context).createEntry),
), ),
body: SizedBox( body: SizedBox(
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
@ -53,7 +53,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * 0.8, width: MediaQuery.of(context).size.width * 0.8,
child: PlatformField( child: PlatformField(
labelText: AppLocalizations.of(context)!.name, labelText: AppLocalizations.of(context).name,
controller: TextEditingController(text: newEntry.data.name), controller: TextEditingController(text: newEntry.data.name),
onChanged: (v) { onChanged: (v) {
newEntry.data.name = v; newEntry.data.name = v;
@ -66,7 +66,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * 0.8, width: MediaQuery.of(context).size.width * 0.8,
child: PlatformField( child: PlatformField(
labelText: AppLocalizations.of(context)!.amount, labelText: AppLocalizations.of(context).amount,
controller: TextEditingController( controller: TextEditingController(
text: newEntry.data.amount.toString()), text: newEntry.data.amount.toString()),
keyboardType: keyboardType:
@ -83,7 +83,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
Text(AppLocalizations.of(context)!.type), Text(AppLocalizations.of(context).type),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
@ -97,7 +97,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
child: SizedBox( child: SizedBox(
width: MediaQuery.of(context).size.width * 0.8 - 24, width: MediaQuery.of(context).size.width * 0.8 - 24,
child: Text( child: Text(
AppLocalizations.of(context)!.expense, AppLocalizations.of(context).expense,
), ),
), ),
), ),
@ -105,7 +105,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
value: EntryType.income, value: EntryType.income,
child: SizedBox( child: SizedBox(
width: MediaQuery.of(context).size.width * 0.8 - 24, width: MediaQuery.of(context).size.width * 0.8 - 24,
child: Text(AppLocalizations.of(context)!.income), child: Text(AppLocalizations.of(context).income),
), ),
), ),
], ],
@ -119,7 +119,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
Text(AppLocalizations.of(context)!.category), Text(AppLocalizations.of(context).category),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
@ -151,7 +151,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
Text(AppLocalizations.of(context)!.description), Text(AppLocalizations.of(context).description),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
@ -175,14 +175,14 @@ class _CreateEntryViewState extends State<CreateEntryView> {
height: 15, height: 15,
), ),
PlatformButton( PlatformButton(
text: AppLocalizations.of(context)!.save, text: AppLocalizations.of(context).save,
onPressed: () { onPressed: () {
if (newEntry.data.name.isEmpty) { if (newEntry.data.name.isEmpty) {
ScaffoldMessenger.of(context).clearSnackBars(); ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text( content: Text(
AppLocalizations.of(context)!.errorEmptyName), AppLocalizations.of(context).errorEmptyName),
), ),
); );
return; return;

View file

@ -1,4 +1,3 @@
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:prasule/api/category.dart'; import 'package:prasule/api/category.dart';
@ -12,6 +11,7 @@ import 'package:prasule/util/graphs.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:prasule/views/settings/settings.dart'; import 'package:prasule/views/settings/settings.dart';
import 'package:prasule/views/setup.dart'; import 'package:prasule/views/setup.dart';
import 'package:shared_preferences/shared_preferences.dart';
class GraphView extends StatefulWidget { class GraphView extends StatefulWidget {
const GraphView({super.key}); const GraphView({super.key});
@ -71,10 +71,15 @@ class _GraphViewState extends State<GraphView> {
setState(() {}); setState(() {});
} }
int? chartType;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
loadWallet(); loadWallet();
SharedPreferences.getInstance().then((s) {
chartType = s.getInt("monthlygraph") ?? 2;
setState(() {});
});
} }
@override @override
@ -95,7 +100,7 @@ class _GraphViewState extends State<GraphView> {
), ),
DropdownMenuItem( DropdownMenuItem(
value: -1, value: -1,
child: Text(AppLocalizations.of(context)!.newWallet), child: Text(AppLocalizations.of(context).newWallet),
) )
], ],
onChanged: (v) async { onChanged: (v) async {
@ -120,20 +125,20 @@ class _GraphViewState extends State<GraphView> {
actions: [ actions: [
PopupMenuButton( PopupMenuButton(
itemBuilder: (context) => [ itemBuilder: (context) => [
AppLocalizations.of(context)!.settings, AppLocalizations.of(context).settings,
AppLocalizations.of(context)!.about AppLocalizations.of(context).about
].map((e) => PopupMenuItem(value: e, child: Text(e))).toList(), ].map((e) => PopupMenuItem(value: e, child: Text(e))).toList(),
onSelected: (value) { onSelected: (value) {
if (value == AppLocalizations.of(context)!.settings) { if (value == AppLocalizations.of(context).settings) {
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const SettingsView(), builder: (context) => const SettingsView(),
), ),
); );
} else if (value == AppLocalizations.of(context)!.about) { } else if (value == AppLocalizations.of(context).about) {
showAboutDialog( showAboutDialog(
context: context, context: context,
applicationLegalese: AppLocalizations.of(context)!.license, applicationLegalese: AppLocalizations.of(context).license,
applicationName: "Prašule"); applicationName: "Prašule");
} }
}, },
@ -143,7 +148,11 @@ class _GraphViewState extends State<GraphView> {
drawer: makeDrawer(context, 2), drawer: makeDrawer(context, 2),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Center( child: Center(
child: SizedBox( child: (selectedWallet == null)
? const CircularProgressIndicator(
strokeWidth: 5,
)
: SizedBox(
width: MediaQuery.of(context).size.width * 0.9, width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
child: Column( child: Column(
@ -153,11 +162,11 @@ class _GraphViewState extends State<GraphView> {
segments: [ segments: [
ButtonSegment<String>( ButtonSegment<String>(
value: "expense", value: "expense",
label: Text(AppLocalizations.of(context)!.expenses), label: Text(AppLocalizations.of(context).expenses),
), ),
ButtonSegment<String>( ButtonSegment<String>(
value: "income", value: "income",
label: Text(AppLocalizations.of(context)!.income), label: Text(AppLocalizations.of(context).income),
), ),
], ],
selected: graphTypeSet, selected: graphTypeSet,
@ -174,38 +183,56 @@ class _GraphViewState extends State<GraphView> {
segments: [ segments: [
ButtonSegment<String>( ButtonSegment<String>(
value: "yearly", value: "yearly",
label: Text(AppLocalizations.of(context)!.yearly), label: Text(AppLocalizations.of(context).yearly),
), ),
ButtonSegment<String>( ButtonSegment<String>(
value: "monthly", value: "monthly",
label: Text(AppLocalizations.of(context)!.monthly), label: Text(AppLocalizations.of(context).monthly),
), ),
], ],
selected: yearlyBtnSet, selected: yearlyBtnSet,
onSelectionChanged: (selection) { onSelectionChanged: (selection) async {
yearlyBtnSet = selection; yearlyBtnSet = selection;
var s = await SharedPreferences.getInstance();
chartType = (yearly)
? (s.getInt("yearlygraph") ?? 1)
: (s.getInt("monthlygraph") ?? 2);
setState(() {}); setState(() {});
}, },
), ),
const SizedBox(height: 5), const SizedBox(height: 5),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Theme.of(context)
.colorScheme
.secondaryContainer),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
PlatformButton( PlatformButton(
text: (yearly) text: (yearly)
? DateFormat.y(locale).format(_selectedDate) ? DateFormat.y(locale).format(_selectedDate)
: DateFormat.yMMMM(locale).format(_selectedDate), : DateFormat.yMMMM(locale)
.format(_selectedDate),
onPressed: () async { onPressed: () async {
var firstDate = (selectedWallet!.entries var firstDate = (selectedWallet!.entries
..sort((a, b) => a.date.compareTo(b.date))) ..sort(
(a, b) => a.date.compareTo(b.date)))
.first .first
.date; .date;
var lastDate = (selectedWallet!.entries var lastDate = (selectedWallet!.entries
..sort((a, b) => b.date.compareTo(a.date))) ..sort(
(a, b) => b.date.compareTo(a.date)))
.first .first
.date; .date;
logger.i(firstDate); logger.i(firstDate);
logger.i(lastDate); logger.i(lastDate);
var newDate = await showDatePicker( var newDate = await showDatePicker(
context: context, context: context,
initialDate: _selectedDate, initialDate: DateTime(_selectedDate.year,
_selectedDate.month, 1),
firstDate: firstDate, firstDate: firstDate,
lastDate: lastDate, lastDate: lastDate,
initialEntryMode: (yearly) initialEntryMode: (yearly)
@ -225,16 +252,44 @@ class _GraphViewState extends State<GraphView> {
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * 0.9, width: MediaQuery.of(context).size.width * 0.9,
height: 300, height: 300,
child: ExpensesChart( child: (chartType == null)
? const CircularProgressIndicator()
: (chartType == 1)
? ExpensesBarChart(
currency: selectedWallet!.currency,
date: _selectedDate, date: _selectedDate,
locale: locale ?? "en", locale: locale ?? "en",
yearly: yearly, yearly: yearly,
expenseData: (graphTypeSet.contains("expense")) expenseData: (graphTypeSet
? generateChartData(EntryType.expense) .contains("expense"))
? generateChartData(
EntryType.expense)
: [], : [],
incomeData: (graphTypeSet.contains("income")) incomeData: (graphTypeSet
? generateChartData(EntryType.income) .contains("income"))
? generateChartData(
EntryType.income)
: [], : [],
)
: ExpensesLineChart(
currency: selectedWallet!.currency,
date: _selectedDate,
locale: locale ?? "en",
yearly: yearly,
expenseData: (graphTypeSet
.contains("expense"))
? generateChartData(
EntryType.expense)
: [],
incomeData: (graphTypeSet
.contains("income"))
? generateChartData(
EntryType.income)
: [],
),
)
],
),
), ),
) )
], ],

View file

@ -72,7 +72,7 @@ class _HomeViewState extends State<HomeView> {
if (kDebugMode) if (kDebugMode)
SpeedDialChild( SpeedDialChild(
child: const Icon(Icons.bug_report), child: const Icon(Icons.bug_report),
label: AppLocalizations.of(context)!.createTestData, label: AppLocalizations.of(context).createTestData,
onTap: () { onTap: () {
// debug option to quickly fill a wallet with data // debug option to quickly fill a wallet with data
if (selectedWallet == null) return; if (selectedWallet == null) return;
@ -114,7 +114,7 @@ class _HomeViewState extends State<HomeView> {
), ),
SpeedDialChild( SpeedDialChild(
child: const Icon(Icons.edit), child: const Icon(Icons.edit),
label: AppLocalizations.of(context)!.addNew, label: AppLocalizations.of(context).addNew,
onTap: () async { onTap: () async {
var sw = await Navigator.of(context).push<Wallet>( var sw = await Navigator.of(context).push<Wallet>(
MaterialPageRoute( MaterialPageRoute(
@ -128,7 +128,7 @@ class _HomeViewState extends State<HomeView> {
}), }),
SpeedDialChild( SpeedDialChild(
child: const Icon(Icons.camera_alt), child: const Icon(Icons.camera_alt),
label: AppLocalizations.of(context)!.addCamera, label: AppLocalizations.of(context).addCamera,
onTap: () async { onTap: () async {
final ImagePicker picker = ImagePicker(); final ImagePicker picker = ImagePicker();
final XFile? media = final XFile? media =
@ -138,7 +138,7 @@ class _HomeViewState extends State<HomeView> {
), ),
SpeedDialChild( SpeedDialChild(
child: const Icon(Icons.image), child: const Icon(Icons.image),
label: AppLocalizations.of(context)!.addGallery, label: AppLocalizations.of(context).addGallery,
onTap: () { onTap: () {
startOcr(ImageSource.gallery); startOcr(ImageSource.gallery);
}, },
@ -160,7 +160,7 @@ class _HomeViewState extends State<HomeView> {
), ),
DropdownMenuItem( DropdownMenuItem(
value: -1, value: -1,
child: Text(AppLocalizations.of(context)!.newWallet), child: Text(AppLocalizations.of(context).newWallet),
) )
], ],
onChanged: (v) async { onChanged: (v) async {
@ -185,20 +185,20 @@ class _HomeViewState extends State<HomeView> {
actions: [ actions: [
PopupMenuButton( PopupMenuButton(
itemBuilder: (context) => [ itemBuilder: (context) => [
AppLocalizations.of(context)!.settings, AppLocalizations.of(context).settings,
AppLocalizations.of(context)!.about AppLocalizations.of(context).about
].map((e) => PopupMenuItem(value: e, child: Text(e))).toList(), ].map((e) => PopupMenuItem(value: e, child: Text(e))).toList(),
onSelected: (value) { onSelected: (value) {
if (value == AppLocalizations.of(context)!.settings) { if (value == AppLocalizations.of(context).settings) {
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const SettingsView(), builder: (context) => const SettingsView(),
), ),
); );
} else if (value == AppLocalizations.of(context)!.about) { } else if (value == AppLocalizations.of(context).about) {
showAboutDialog( showAboutDialog(
context: context, context: context,
applicationLegalese: AppLocalizations.of(context)!.license, applicationLegalese: AppLocalizations.of(context).license,
applicationName: "Prašule"); applicationName: "Prašule");
} }
}, },
@ -223,14 +223,14 @@ class _HomeViewState extends State<HomeView> {
? Column( ? Column(
children: [ children: [
Text( Text(
AppLocalizations.of(context)!.noEntries, AppLocalizations.of(context).noEntries,
style: const TextStyle( style: const TextStyle(
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
Text( Text(
AppLocalizations.of(context)!.noEntriesSub, AppLocalizations.of(context).noEntriesSub,
) )
], ],
) )
@ -307,12 +307,12 @@ class _HomeViewState extends State<HomeView> {
context: context, context: context,
builder: (cx) => PlatformDialog( builder: (cx) => PlatformDialog(
title: title:
AppLocalizations.of(context)!.sureDialog, AppLocalizations.of(context).sureDialog,
content: Text( content: Text(
AppLocalizations.of(context)!.deleteSure), AppLocalizations.of(context).deleteSure),
actions: [ actions: [
PlatformButton( PlatformButton(
text: AppLocalizations.of(context)!.yes, text: AppLocalizations.of(context).yes,
onPressed: () { onPressed: () {
selectedWallet?.entries.removeWhere( selectedWallet?.entries.removeWhere(
(e) => e.id == element.id); (e) => e.id == element.id);
@ -323,7 +323,7 @@ class _HomeViewState extends State<HomeView> {
}, },
), ),
PlatformButton( PlatformButton(
text: AppLocalizations.of(context)!.no, text: AppLocalizations.of(context).no,
onPressed: () { onPressed: () {
Navigator.of(cx).pop(); Navigator.of(cx).pop();
}, },
@ -365,9 +365,9 @@ class _HomeViewState extends State<HomeView> {
if (!mounted) return; if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text(AppLocalizations.of(context)!.missingOcr), content: Text(AppLocalizations.of(context).missingOcr),
action: SnackBarAction( action: SnackBarAction(
label: AppLocalizations.of(context)!.download, label: AppLocalizations.of(context).download,
onPressed: () { onPressed: () {
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
@ -408,7 +408,7 @@ class _HomeViewState extends State<HomeView> {
showDialog( showDialog(
context: context, context: context,
builder: (c) => PlatformDialog( builder: (c) => PlatformDialog(
title: AppLocalizations.of(context)!.ocrLoading), title: AppLocalizations.of(context).ocrLoading),
barrierDismissible: false); barrierDismissible: false);
var string = await FlutterTesseractOcr.extractText(media.path, var string = await FlutterTesseractOcr.extractText(media.path,
language: selected, language: selected,
@ -472,7 +472,7 @@ class _HomeViewState extends State<HomeView> {
child: const Text("Cancel"), child: const Text("Cancel"),
), ),
], ],
title: AppLocalizations.of(context)!.ocrSelect, title: AppLocalizations.of(context).ocrSelect,
content: Column( content: Column(
children: [ children: [
...List.generate( ...List.generate(

View file

@ -0,0 +1,156 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:prasule/pw/platformdialog.dart';
import 'package:settings_ui/settings_ui.dart';
import 'package:shared_preferences/shared_preferences.dart';
class GraphTypeSettingsView extends StatefulWidget {
const GraphTypeSettingsView({super.key});
@override
State<GraphTypeSettingsView> createState() => _GraphTypeSettingsViewState();
}
class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
var _yearly = 1;
var _monthly = 2;
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((prefs) {
_yearly = prefs.getInt("yearlygraph") ?? 1;
_monthly = prefs.getInt("monthlygraph") ?? 2;
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).graphType),
),
body: SettingsList(
applicationType: ApplicationType.both,
darkTheme: SettingsThemeData(
settingsListBackground: Theme.of(context).colorScheme.background,
titleTextColor: Theme.of(context).colorScheme.primary),
sections: [
SettingsSection(
tiles: [
SettingsTile.navigation(
title: Text(AppLocalizations.of(context).yearly),
value: Text(_yearly == 1
? AppLocalizations.of(context).barChart
: AppLocalizations.of(context).lineChart),
onPressed: (c) => showDialog(
context: c,
builder: (ctx) => PlatformDialog(
title: AppLocalizations.of(context).selectType,
content: Column(
children: [
SizedBox(
width: MediaQuery.of(ctx).size.width,
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(AppLocalizations.of(context).barChart,
textAlign: TextAlign.center),
),
onTap: () async {
var s = await SharedPreferences.getInstance();
s.setInt("yearlygraph", 1);
_yearly = 1;
if (!mounted) return;
Navigator.of(ctx).pop();
setState(() {});
},
),
),
SizedBox(
width: MediaQuery.of(context).size.width,
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
AppLocalizations.of(context).lineChart,
textAlign: TextAlign.center,
),
),
onTap: () async {
var s = await SharedPreferences.getInstance();
s.setInt("yearlygraph", 2);
_yearly = 2;
if (!mounted) return;
Navigator.of(ctx).pop();
setState(() {});
},
),
),
],
),
),
),
),
SettingsTile.navigation(
title: Text(AppLocalizations.of(context).monthly),
value: Text(_monthly == 1
? AppLocalizations.of(context).barChart
: AppLocalizations.of(context).lineChart),
onPressed: (c) => showDialog(
context: c,
builder: (ctx) => PlatformDialog(
title: AppLocalizations.of(context).selectType,
content: Column(
children: [
SizedBox(
width: MediaQuery.of(ctx).size.width,
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
AppLocalizations.of(context).barChart,
textAlign: TextAlign.center,
),
),
onTap: () async {
var s = await SharedPreferences.getInstance();
s.setInt("monthlygraph", 1);
_monthly = 1;
if (!mounted) return;
Navigator.of(ctx).pop();
setState(() {});
},
),
),
SizedBox(
width: MediaQuery.of(ctx).size.width,
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
AppLocalizations.of(context).lineChart,
textAlign: TextAlign.center),
),
onTap: () async {
var s = await SharedPreferences.getInstance();
s.setInt("monthlygraph", 2);
_monthly = 2;
if (!mounted) return;
Navigator.of(ctx).pop();
setState(() {});
},
),
),
],
),
),
),
),
],
)
],
),
);
}
}

View file

@ -1,4 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:prasule/pw/platformroute.dart';
import 'package:prasule/views/settings/graph_type.dart';
import 'package:prasule/views/settings/tessdata_list.dart'; import 'package:prasule/views/settings/tessdata_list.dart';
import 'package:settings_ui/settings_ui.dart'; import 'package:settings_ui/settings_ui.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@ -14,7 +16,7 @@ class _SettingsViewState extends State<SettingsView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(AppLocalizations.of(context)!.settings)), appBar: AppBar(title: Text(AppLocalizations.of(context).settings)),
body: SettingsList( body: SettingsList(
applicationType: ApplicationType.both, applicationType: ApplicationType.both,
darkTheme: SettingsThemeData( darkTheme: SettingsThemeData(
@ -24,16 +26,31 @@ class _SettingsViewState extends State<SettingsView> {
SettingsSection( SettingsSection(
tiles: [ tiles: [
SettingsTile.navigation( SettingsTile.navigation(
title: Text(AppLocalizations.of(context)!.downloadedOcr), title: Text(AppLocalizations.of(context).downloadedOcr),
description: description:
Text(AppLocalizations.of(context)!.downloadedOcrDesc), Text(AppLocalizations.of(context).downloadedOcrDesc),
onPressed: (context) => Navigator.of(context).push( trailing: const Icon(Icons.keyboard_arrow_right),
MaterialPageRoute( onPressed: (context) => Navigator.of(context)
builder: (c) => const TessdataListView())), .push(platformRoute((c) => const TessdataListView())),
) )
], ],
title: Text(AppLocalizations.of(context)!.ocr), title: Text(AppLocalizations.of(context).ocr),
), ),
SettingsSection(
title: Text(AppLocalizations.of(context).settingsAppearance),
tiles: [
SettingsTile.navigation(
title: Text(AppLocalizations.of(context).graphType),
description: Text(AppLocalizations.of(context).graphTypeDesc),
trailing: const Icon(Icons.keyboard_arrow_right),
onPressed: (c) => Navigator.of(c).push(
platformRoute(
(p0) => const GraphTypeSettingsView(),
),
),
)
],
)
], ],
), ),
); );

View file

@ -29,7 +29,7 @@ class _TessdataListViewState extends State<TessdataListView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(AppLocalizations.of(context)!.ocrData)), appBar: AppBar(title: Text(AppLocalizations.of(context).ocrData)),
body: Center( body: Center(
child: SizedBox( child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9, width: MediaQuery.of(context).size.width * 0.9,
@ -50,8 +50,8 @@ class _TessdataListViewState extends State<TessdataListView> {
title: Text(_tessdata[i].keys.first), title: Text(_tessdata[i].keys.first),
trailing: TextButton( trailing: TextButton(
child: Text(_tessdata[i][_tessdata[i].keys.first]! child: Text(_tessdata[i][_tessdata[i].keys.first]!
? AppLocalizations.of(context)!.downloaded ? AppLocalizations.of(context).downloaded
: AppLocalizations.of(context)!.download), : AppLocalizations.of(context).download),
onPressed: () async { onPressed: () async {
var lang = _tessdata[i].keys.first; var lang = _tessdata[i].keys.first;
if (_tessdata[i][lang]!) { if (_tessdata[i][lang]!) {
@ -59,12 +59,12 @@ class _TessdataListViewState extends State<TessdataListView> {
showDialog( showDialog(
context: context, context: context,
builder: (context) => PlatformDialog( builder: (context) => PlatformDialog(
title: AppLocalizations.of(context)!.sureDialog, title: AppLocalizations.of(context).sureDialog,
content: Text(AppLocalizations.of(context)! content: Text(AppLocalizations.of(context)
.deleteOcr(lang)), .deleteOcr(lang)),
actions: [ actions: [
PlatformButton( PlatformButton(
text: AppLocalizations.of(context)!.yes, text: AppLocalizations.of(context).yes,
onPressed: () async { onPressed: () async {
await TessdataApi.deleteData(lang); await TessdataApi.deleteData(lang);
_tessdata[i][lang] = true; _tessdata[i][lang] = true;
@ -72,7 +72,7 @@ class _TessdataListViewState extends State<TessdataListView> {
}, },
), ),
PlatformButton( PlatformButton(
text: AppLocalizations.of(context)!.no, text: AppLocalizations.of(context).no,
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
@ -91,7 +91,7 @@ class _TessdataListViewState extends State<TessdataListView> {
showDialog( showDialog(
context: context, context: context,
builder: (c) => PlatformDialog( builder: (c) => PlatformDialog(
title: AppLocalizations.of(context)! title: AppLocalizations.of(context)
.langDownloadDialog(lang), .langDownloadDialog(lang),
content: StreamBuilder( content: StreamBuilder(
builder: (context, snapshot) { builder: (context, snapshot) {
@ -102,7 +102,7 @@ class _TessdataListViewState extends State<TessdataListView> {
if (snapshot.hasError) { if (snapshot.hasError) {
return const Text("Error"); return const Text("Error");
} }
return Text(AppLocalizations.of(context)! return Text(AppLocalizations.of(context)
.langDownloadProgress(snapshot.data!)); .langDownloadProgress(snapshot.data!));
}, },
stream: progressStream.stream, stream: progressStream.stream,

View file

@ -45,28 +45,28 @@ class _SetupViewState extends State<SetupView> {
if (categories.isEmpty) { if (categories.isEmpty) {
categories = [ categories = [
WalletCategory( WalletCategory(
name: AppLocalizations.of(context)!.categoryHealth, name: AppLocalizations.of(context).categoryHealth,
type: EntryType.expense, type: EntryType.expense,
id: 1, id: 1,
icon: IconData(Icons.medical_information.codePoint, icon: IconData(Icons.medical_information.codePoint,
fontFamily: 'MaterialIcons'), fontFamily: 'MaterialIcons'),
), ),
WalletCategory( WalletCategory(
name: AppLocalizations.of(context)!.categoryCar, name: AppLocalizations.of(context).categoryCar,
type: EntryType.expense, type: EntryType.expense,
id: 2, id: 2,
icon: icon:
IconData(Icons.car_repair.codePoint, fontFamily: 'MaterialIcons'), IconData(Icons.car_repair.codePoint, fontFamily: 'MaterialIcons'),
), ),
WalletCategory( WalletCategory(
name: AppLocalizations.of(context)!.categoryFood, name: AppLocalizations.of(context).categoryFood,
type: EntryType.expense, type: EntryType.expense,
id: 3, id: 3,
icon: icon:
IconData(Icons.restaurant.codePoint, fontFamily: 'MaterialIcons'), IconData(Icons.restaurant.codePoint, fontFamily: 'MaterialIcons'),
), ),
WalletCategory( WalletCategory(
name: AppLocalizations.of(context)!.categoryTravel, name: AppLocalizations.of(context).categoryTravel,
type: EntryType.expense, type: EntryType.expense,
id: 4, id: 4,
icon: IconData(Icons.train.codePoint, fontFamily: 'MaterialIcons'), icon: IconData(Icons.train.codePoint, fontFamily: 'MaterialIcons'),
@ -90,16 +90,16 @@ class _SetupViewState extends State<SetupView> {
showNextButton: true, showNextButton: true,
showBackButton: true, showBackButton: true,
showDoneButton: true, showDoneButton: true,
next: Text(AppLocalizations.of(context)!.next), next: Text(AppLocalizations.of(context).next),
back: Text(AppLocalizations.of(context)!.back), back: Text(AppLocalizations.of(context).back),
done: Text(AppLocalizations.of(context)!.finish), done: Text(AppLocalizations.of(context).finish),
onDone: () { onDone: () {
if (name.isEmpty) { if (name.isEmpty) {
ScaffoldMessenger.of(context) ScaffoldMessenger.of(context)
.clearSnackBars(); // TODO: iOS replacement .clearSnackBars(); // TODO: iOS replacement
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: content:
Text(AppLocalizations.of(context)!.errorEmptyName))); Text(AppLocalizations.of(context).errorEmptyName)));
return; return;
} }
var wallet = Wallet( var wallet = Wallet(
@ -113,7 +113,7 @@ class _SetupViewState extends State<SetupView> {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: content:
Text(AppLocalizations.of(context)!.walletExists), Text(AppLocalizations.of(context).walletExists),
), ),
); );
return; return;
@ -137,7 +137,7 @@ class _SetupViewState extends State<SetupView> {
titleWidget: Padding( titleWidget: Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Text( child: Text(
AppLocalizations.of(context)!.welcome, AppLocalizations.of(context).welcome,
style: const TextStyle( style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.bold), fontSize: 24, fontWeight: FontWeight.bold),
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -150,7 +150,7 @@ class _SetupViewState extends State<SetupView> {
if (!widget.newWallet) if (!widget.newWallet)
Flexible( Flexible(
child: Text( child: Text(
AppLocalizations.of(context)!.welcomeAboutPrasule), AppLocalizations.of(context).welcomeAboutPrasule),
), ),
if (!widget.newWallet) if (!widget.newWallet)
const SizedBox( const SizedBox(
@ -158,7 +158,7 @@ class _SetupViewState extends State<SetupView> {
), ),
Flexible( Flexible(
child: Text( child: Text(
AppLocalizations.of(context)!.welcomeInstruction), AppLocalizations.of(context).welcomeInstruction),
), ),
], ],
), ),
@ -169,7 +169,7 @@ class _SetupViewState extends State<SetupView> {
titleWidget: Padding( titleWidget: Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Text( child: Text(
AppLocalizations.of(context)!.setupWalletNameCurrency, AppLocalizations.of(context).setupWalletNameCurrency,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: const TextStyle( style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.bold), fontSize: 24, fontWeight: FontWeight.bold),
@ -182,7 +182,7 @@ class _SetupViewState extends State<SetupView> {
width: MediaQuery.of(context).size.width * 0.7, width: MediaQuery.of(context).size.width * 0.7,
child: PlatformField( child: PlatformField(
labelText: labelText:
AppLocalizations.of(context)!.setupNamePlaceholder, AppLocalizations.of(context).setupNamePlaceholder,
onChanged: (t) { onChanged: (t) {
name = t; name = t;
}, },
@ -192,7 +192,7 @@ class _SetupViewState extends State<SetupView> {
height: 5, height: 5,
), ),
PlatformButton( PlatformButton(
text: AppLocalizations.of(context)! text: AppLocalizations.of(context)
.setupCurrency(_selectedCurrency.code), .setupCurrency(_selectedCurrency.code),
onPressed: () { onPressed: () {
showCurrencyPicker( showCurrencyPicker(
@ -211,7 +211,7 @@ class _SetupViewState extends State<SetupView> {
width: MediaQuery.of(context).size.width * 0.7, width: MediaQuery.of(context).size.width * 0.7,
child: PlatformField( child: PlatformField(
labelText: labelText:
AppLocalizations.of(context)!.setupStartingBalance, AppLocalizations.of(context).setupStartingBalance,
keyboardType: const TextInputType.numberWithOptions( keyboardType: const TextInputType.numberWithOptions(
decimal: true), decimal: true),
inputFormatters: [ inputFormatters: [
@ -233,7 +233,7 @@ class _SetupViewState extends State<SetupView> {
titleWidget: Padding( titleWidget: Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Text( child: Text(
AppLocalizations.of(context)!.setupCategoriesHeading, AppLocalizations.of(context).setupCategoriesHeading,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: const TextStyle( style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.bold), fontSize: 24, fontWeight: FontWeight.bold),
@ -243,7 +243,7 @@ class _SetupViewState extends State<SetupView> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
AppLocalizations.of(context)!.setupCategoriesEditHint, AppLocalizations.of(context).setupCategoriesEditHint,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
SizedBox( SizedBox(
@ -296,17 +296,17 @@ class _SetupViewState extends State<SetupView> {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
child: Text( child: Text(
AppLocalizations.of(context)!.ok), AppLocalizations.of(context).ok),
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
child: Text( child: Text(
AppLocalizations.of(context)!.cancel), AppLocalizations.of(context).cancel),
), ),
], ],
title: AppLocalizations.of(context)! title: AppLocalizations.of(context)
.setupCategoriesEditingName, .setupCategoriesEditingName,
content: SizedBox( content: SizedBox(
width: 400, width: 400,
@ -336,7 +336,7 @@ class _SetupViewState extends State<SetupView> {
} }
categories.add( categories.add(
WalletCategory( WalletCategory(
name: AppLocalizations.of(context)! name: AppLocalizations.of(context)
.setupWalletNamePlaceholder, .setupWalletNamePlaceholder,
type: EntryType.expense, type: EntryType.expense,
id: id, id: id,

View file

@ -876,6 +876,62 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.2" version: "2.0.2"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7"
url: "https://pub.dev"
source: hosted
version: "2.3.4"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a
url: "https://pub.dev"
source: hosted
version: "2.3.1"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
shelf: shelf:
dependency: transitive dependency: transitive
description: description:
@ -1131,4 +1187,4 @@ packages:
version: "3.1.2" version: "3.1.2"
sdks: sdks:
dart: ">=3.2.0 <4.0.0" dart: ">=3.2.0 <4.0.0"
flutter: ">=3.10.0" flutter: ">=3.16.0"

View file

@ -1,7 +1,7 @@
name: prasule name: prasule
description: Open-source private expense tracker description: Open-source private expense tracker
version: 1.0.0-alpha2+2 version: 1.0.0-alpha.2+2
environment: environment:
sdk: '>=3.1.0-262.2.beta <4.0.0' sdk: '>=3.1.0-262.2.beta <4.0.0'
@ -39,6 +39,7 @@ dependencies:
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
fl_chart: ^0.65.0 fl_chart: ^0.65.0
shared_preferences: ^2.2.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: