Compare commits

...

4 commits

Author SHA1 Message Date
Matyáš Caras
d1f37282f0
chore: check deps 2023-11-01 15:48:14 +01:00
Matyáš Caras
d82a5f4b1f
wip: work on adding data from OCR 2023-11-01 15:39:25 +01:00
Matyáš Caras
f8f40f6db6
feat: localization 2023-11-01 15:39:24 +01:00
Matyáš Caras
de8f57fcc8
feat(ocr): 🚧 work on adding entries through OCR 2023-11-01 15:39:24 +01:00
19 changed files with 464 additions and 225 deletions

View file

@ -1,5 +1,5 @@
# prasule
[![Codemagic build status](https://api.codemagic.io/apps/64faee78aae8c48abc70dbc6/64faee78aae8c48abc70dbc5/status_badge.svg)](https://codemagic.io/apps/64faee78aae8c48abc70dbc6/64faee78aae8c48abc70dbc5/latest_build) [![Bug issue count](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.mnau.xyz%2Fapi%2Fv1%2Frepos%2Fhernik%2Fprasule%2Fissues%3Flabels%3DKind%2FBug&query=%24.length&logo=forgejo&label=bug%20issues&color=red)](https://git.mnau.xyz/hernik/prasule/issues?q=&type=all&sort=&state=open&labels=144&milestone=0&project=0&assignee=0&poster=0)
[![Codemagic build status](https://api.codemagic.io/apps/64faee78aae8c48abc70dbc6/64faee78aae8c48abc70dbc5/status_badge.svg)](https://codemagic.io/apps/64faee78aae8c48abc70dbc6/64faee78aae8c48abc70dbc5/latest_build) [![Bug issue count](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.mnau.xyz%2Fapi%2Fv1%2Frepos%2Fhernik%2Fprasule%2Fissues%3Flabels%3DKind%2FBug&query=%24.length&logo=forgejo&label=bug%20issues&color=red)](https://git.mnau.xyz/hernik/prasule/issues?q=&type=all&sort=&state=open&labels=144&milestone=0&project=0&assignee=0&poster=0) [![wakatime](https://wakatime.com/badge/user/17178fab-a33c-430f-a764-7b3f26c7b966/project/bf1f40b0-c8c0-4f72-8ad6-c861ecdcc90c.svg)](https://wakatime.com/badge/user/17178fab-a33c-430f-a764-7b3f26c7b966/project/bf1f40b0-c8c0-4f72-8ad6-c861ecdcc90c)
Expense manager

3
l10n.yaml Normal file
View file

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

15
lib/api/entry_data.dart Normal file
View file

@ -0,0 +1,15 @@
import 'package:json_annotation/json_annotation.dart';
part 'entry_data.g.dart';
@JsonSerializable()
class EntryData {
String name;
double amount;
EntryData({required this.name, required this.amount});
factory EntryData.fromJson(Map<String, dynamic> json) =>
_$EntryDataFromJson(json);
Map<String, dynamic> toJson() => _$EntryDataToJson(this);
}

17
lib/api/entry_data.g.dart Normal file
View file

@ -0,0 +1,17 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'entry_data.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
EntryData _$EntryDataFromJson(Map<String, dynamic> json) => EntryData(
name: json['name'] as String,
amount: (json['amount'] as num).toDouble(),
);
Map<String, dynamic> _$EntryDataToJson(EntryData instance) => <String, dynamic>{
'name': instance.name,
'amount': instance.amount,
};

25
lib/api/multientry.dart Normal file
View file

@ -0,0 +1,25 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:prasule/api/category.dart';
import 'package:prasule/api/entry_data.dart';
part 'multientry.g.dart';
@JsonSerializable()
class MultiEntry {
EntryType type;
List<EntryData> data;
DateTime date;
WalletCategory category;
int id;
MultiEntry(
{required this.data,
required this.type,
required this.date,
required this.category,
required this.id});
factory MultiEntry.fromJson(Map<String, dynamic> json) =>
_$MultiEntryFromJson(json);
Map<String, dynamic> toJson() => _$MultiEntryToJson(this);
}

32
lib/api/multientry.g.dart Normal file
View file

@ -0,0 +1,32 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'multientry.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
MultiEntry _$MultiEntryFromJson(Map<String, dynamic> json) => MultiEntry(
data: (json['data'] as List<dynamic>)
.map((e) => EntryData.fromJson(e as Map<String, dynamic>))
.toList(),
type: $enumDecode(_$EntryTypeEnumMap, json['type']),
date: DateTime.parse(json['date'] as String),
category:
WalletCategory.fromJson(json['category'] as Map<String, dynamic>),
id: json['id'] as int,
);
Map<String, dynamic> _$MultiEntryToJson(MultiEntry instance) =>
<String, dynamic>{
'type': _$EntryTypeEnumMap[instance.type]!,
'data': instance.data,
'date': instance.date.toIso8601String(),
'category': instance.category,
'id': instance.id,
};
const _$EntryTypeEnumMap = {
EntryType.expense: 'expense',
EntryType.income: 'income',
};

View file

@ -1,7 +1,7 @@
import 'package:currency_picker/currency_picker.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:prasule/api/category.dart';
import 'package:prasule/api/entry.dart';
import 'package:prasule/api/walletentry.dart';
part 'wallet.g.dart';
Currency _currencyFromJson(Map<String, dynamic> data) =>
@ -11,7 +11,7 @@ Currency _currencyFromJson(Map<String, dynamic> data) =>
class Wallet {
final String name;
final List<WalletCategory> categories;
final List<WalletEntry> entries;
final List<WalletSingleEntry> entries;
double availableAmount;
@JsonKey(fromJson: _currencyFromJson)
final Currency currency;

View file

@ -14,7 +14,8 @@ Wallet _$WalletFromJson(Map<String, dynamic> json) => Wallet(
.toList() ??
const [],
entries: (json['entries'] as List<dynamic>?)
?.map((e) => WalletEntry.fromJson(e as Map<String, dynamic>))
?.map(
(e) => WalletSingleEntry.fromJson(e as Map<String, dynamic>))
.toList() ??
const [],
availableAmount: (json['availableAmount'] as num?)?.toDouble() ?? 0,

View file

@ -1,19 +1,20 @@
import 'package:prasule/api/category.dart';
import 'package:json_annotation/json_annotation.dart';
part 'entry.g.dart';
import 'package:prasule/api/entry_data.dart';
part 'walletentry.g.dart';
@JsonSerializable()
class WalletEntry {
/// This is an entry containing a single item
class WalletSingleEntry {
EntryType type;
String name;
double amount;
EntryData data;
DateTime date;
WalletCategory category;
int id;
WalletEntry(
{required this.name,
required this.amount,
WalletSingleEntry(
{required this.data,
required this.type,
required this.date,
required this.category,
@ -21,9 +22,9 @@ class WalletEntry {
/// Connect the generated [_$WalletEntry] function to the `fromJson`
/// factory.
factory WalletEntry.fromJson(Map<String, dynamic> json) =>
_$WalletEntryFromJson(json);
factory WalletSingleEntry.fromJson(Map<String, dynamic> json) =>
_$WalletSingleEntryFromJson(json);
/// Connect the generated [_$WalletEntryToJson] function to the `toJson` method.
Map<String, dynamic> toJson() => _$WalletEntryToJson(this);
Map<String, dynamic> toJson() => _$WalletSingleEntryToJson(this);
}

View file

@ -1,14 +1,14 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'entry.dart';
part of 'walletentry.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
WalletEntry _$WalletEntryFromJson(Map<String, dynamic> json) => WalletEntry(
name: json['name'] as String,
amount: (json['amount'] as num).toDouble(),
WalletSingleEntry _$WalletSingleEntryFromJson(Map<String, dynamic> json) =>
WalletSingleEntry(
data: EntryData.fromJson(json['data'] as Map<String, dynamic>),
type: $enumDecode(_$EntryTypeEnumMap, json['type']),
date: DateTime.parse(json['date'] as String),
category:
@ -16,11 +16,10 @@ WalletEntry _$WalletEntryFromJson(Map<String, dynamic> json) => WalletEntry(
id: json['id'] as int,
);
Map<String, dynamic> _$WalletEntryToJson(WalletEntry instance) =>
Map<String, dynamic> _$WalletSingleEntryToJson(WalletSingleEntry instance) =>
<String, dynamic>{
'type': _$EntryTypeEnumMap[instance.type]!,
'name': instance.name,
'amount': instance.amount,
'data': instance.data,
'date': instance.date.toIso8601String(),
'category': instance.category,
'id': instance.id,

92
lib/l10n/app_en.arb Normal file
View file

@ -0,0 +1,92 @@
{
"categoryHealth": "Health",
"categoryCar": "Car",
"categoryFood": "Food",
"categoryTravel": "Travel",
"next": "Next",
"back": "Back",
"finish": "Finish",
"errorEmptyName": "Name cannot be empty",
"welcome": "Welcome!",
"welcomeAboutPrasule": "Prašule is an expense tracker tool designed for people, who don't want to spend too much time filling in all the little details.",
"welcomeInstruction": "On this screen you will set up your 'wallet', in which you will track your expenses categorized under categories, which you can later set in the settings menu.",
"setupWalletNameCurrency": "Set your wallet's name and currency",
"setupNamePlaceholder": "Your awesome name here...",
"setupCurrency": "Currency: {currency}",
"@setupCurrency": {
"description": "Shows the currently selected currency on the setup screen",
"placeholders": {
"currency": {
"type": "String",
"example": "CZK"
}
}
},
"setupCategoriesHeading": "Create categories",
"setupCategoriesEditHint": "Tap on the icon or name to edit it",
"ok": "Ok",
"cancel": "Cancel",
"setupCategoriesEditingName": "Editing name",
"setupWalletNamePlaceholder": "Edit me",
"addNew": "Add new",
"addCamera": "Add through camera",
"addGallery": "Add through saved image",
"home": "Home",
"settings": "Settings",
"about": "About",
"noEntries": "No entries :(",
"noEntriesSub": "Add one using the floating action button.",
"sureDialog": "Are you sure?",
"deleteSure": "Do you really want to delete this entry?",
"missingOcr": "You don't have any OCR language data downloaded!",
"download": "Download",
"ocrLoading": "Loading text from image, please wait a moment...",
"yes": "Yes",
"no": "No",
"ocrSelect": "Select languages for OCR",
"createEntry": "Create new entry",
"name": "Name",
"amount": "Amount",
"type": "Type",
"expense": "Expense",
"income": "Income",
"category": "Category",
"save": "Save",
"downloadedOcr": "View downloaded OCR data",
"downloadedOcrDesc": "This data is used by the OCR engine to recognize text from pictues",
"ocr": "OCR",
"ocrData": "OCR Data",
"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": {
"description": "Shown when a user wants to delete OCR data through settings",
"placeholders": {
"lang": {
"type": "String",
"example": "ces"
}
}
},
"langDownloadDialog": "Downloading $lang, please wait...",
"@langDownloadDialog": {
"description": "Shown as a title of a dialog while downloading new OCR data",
"placeholders": {
"lang": {
"type": "String",
"example": "ces"
}
}
},
"langDownloadProgress": "Download progress: $progress %",
"@langDownloadProgress": {
"description": "Progress percentage shown while downloading OCR data",
"placeholders": {
"progress":{
"type":"num",
"example":"99.7"
}
}
},
"addingFromOcr": "Add from OCR",
"license":"©️ 2023 Matyáš Caras\nReleased under the GNU AGPL license version 3"
}

View file

@ -3,9 +3,11 @@ import 'dart:io';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:logger/logger.dart';
import 'package:prasule/util/color_schemes.g.dart';
import 'package:prasule/views/home.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
void main() {
runApp(const MyApp());
@ -22,6 +24,12 @@ class MyApp extends StatelessWidget {
return (Platform.isAndroid)
? DynamicColorBuilder(
builder: (light, dark) => MaterialApp(
localizationsDelegates: const [
AppLocalizations.delegate,
...GlobalMaterialLocalizations.delegates,
...GlobalCupertinoLocalizations.delegates
],
supportedLocales: AppLocalizations.supportedLocales,
title: 'Prašule',
theme: ThemeData(
colorScheme: light ?? lightColorScheme,

View file

@ -1,15 +1,17 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:prasule/api/category.dart';
import 'package:prasule/api/entry.dart';
import 'package:prasule/api/entry_data.dart';
import 'package:prasule/api/walletentry.dart';
import 'package:prasule/api/wallet.dart';
import 'package:prasule/api/walletmanager.dart';
import 'package:prasule/pw/platformbutton.dart';
import 'package:prasule/pw/platformfield.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class CreateEntryView extends StatefulWidget {
final Wallet w;
final WalletEntry? editEntry;
final WalletSingleEntry? editEntry;
const CreateEntryView({super.key, required this.w, this.editEntry});
@override
@ -17,7 +19,7 @@ class CreateEntryView extends StatefulWidget {
}
class _CreateEntryViewState extends State<CreateEntryView> {
late WalletEntry newEntry;
late WalletSingleEntry newEntry;
@override
void initState() {
super.initState();
@ -28,10 +30,9 @@ class _CreateEntryViewState extends State<CreateEntryView> {
while (widget.w.entries.where((element) => element.id == id).isNotEmpty) {
id++; // create unique ID
}
newEntry = WalletEntry(
newEntry = WalletSingleEntry(
id: id,
name: "",
amount: 0,
data: EntryData(amount: 0, name: ""),
type: EntryType.expense,
date: DateTime.now(),
category: widget.w.categories.first);
@ -43,7 +44,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Create new entry"),
title: Text(AppLocalizations.of(context)!.createEntry),
),
body: SizedBox(
width: MediaQuery.of(context).size.width,
@ -56,10 +57,10 @@ class _CreateEntryViewState extends State<CreateEntryView> {
SizedBox(
width: MediaQuery.of(context).size.width * 0.8,
child: PlatformField(
labelText: "Name",
controller: TextEditingController(text: newEntry.name),
labelText: AppLocalizations.of(context)!.name,
controller: TextEditingController(text: newEntry.data.name),
onChanged: (v) {
newEntry.name = v;
newEntry.data.name = v;
},
),
),
@ -69,9 +70,9 @@ class _CreateEntryViewState extends State<CreateEntryView> {
SizedBox(
width: MediaQuery.of(context).size.width * 0.8,
child: PlatformField(
labelText: "Amount",
controller:
TextEditingController(text: newEntry.amount.toString()),
labelText: AppLocalizations.of(context)!.amount,
controller: TextEditingController(
text: newEntry.data.amount.toString()),
keyboardType:
const TextInputType.numberWithOptions(decimal: true),
inputFormatters: [
@ -79,7 +80,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
RegExp(r'\d+[\.,]{0,1}\d{0,}'))
],
onChanged: (v) {
newEntry.amount = double.parse(v);
newEntry.data.amount = double.parse(v);
},
),
),
@ -99,8 +100,8 @@ class _CreateEntryViewState extends State<CreateEntryView> {
value: EntryType.expense,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.8 - 24,
child: const Text(
"Expense",
child: Text(
AppLocalizations.of(context)!.expense,
),
),
),
@ -108,7 +109,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
value: EntryType.income,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.8 - 24,
child: const Text("Income"),
child: Text(AppLocalizations.of(context)!.income),
),
),
],
@ -122,7 +123,7 @@ class _CreateEntryViewState extends State<CreateEntryView> {
const SizedBox(
height: 20,
),
const Text("Category"),
Text(AppLocalizations.of(context)!.category),
const SizedBox(
height: 10,
),
@ -155,13 +156,14 @@ class _CreateEntryViewState extends State<CreateEntryView> {
height: 15,
),
PlatformButton(
text: "Save",
text: AppLocalizations.of(context)!.save,
onPressed: () {
if (newEntry.name.isEmpty) {
if (newEntry.data.name.isEmpty) {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Name cannot be empty"),
SnackBar(
content: Text(
AppLocalizations.of(context)!.errorEmptyName),
),
);
return;

View file

@ -6,7 +6,8 @@ import 'package:grouped_list/grouped_list.dart';
import 'package:image_picker/image_picker.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
import 'package:prasule/api/entry.dart';
import 'package:prasule/api/entry_data.dart';
import 'package:prasule/api/walletentry.dart';
import 'package:prasule/api/wallet.dart';
import 'package:prasule/api/walletmanager.dart';
import 'package:prasule/main.dart';
@ -17,6 +18,7 @@ import 'package:prasule/views/create_entry.dart';
import 'package:prasule/views/settings/settings.dart';
import 'package:prasule/views/settings/tessdata_list.dart';
import 'package:prasule/views/setup.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class HomeView extends StatefulWidget {
const HomeView({super.key});
@ -62,7 +64,7 @@ class _HomeViewState extends State<HomeView> {
children: [
SpeedDialChild(
child: const Icon(Icons.edit),
label: "Add new",
label: AppLocalizations.of(context)!.addNew,
onTap: () async {
var sw = await Navigator.of(context).push<Wallet>(
MaterialPageRoute(
@ -76,7 +78,7 @@ class _HomeViewState extends State<HomeView> {
}),
SpeedDialChild(
child: const Icon(Icons.camera_alt),
label: "Add through camera",
label: AppLocalizations.of(context)!.addCamera,
onTap: () async {
final ImagePicker picker = ImagePicker();
final XFile? media =
@ -86,7 +88,7 @@ class _HomeViewState extends State<HomeView> {
),
SpeedDialChild(
child: const Icon(Icons.image),
label: "Add through saved image",
label: AppLocalizations.of(context)!.addGallery,
onTap: () {
startOcr(ImageSource.gallery);
},
@ -94,24 +96,24 @@ class _HomeViewState extends State<HomeView> {
],
),
appBar: AppBar(
title: const Text("Home"),
title: Text(AppLocalizations.of(context)!.home),
actions: [
PopupMenuButton(
itemBuilder: (context) => ["Settings", "About"]
.map((e) => PopupMenuItem(value: e, child: Text(e)))
.toList(),
itemBuilder: (context) => [
AppLocalizations.of(context)!.settings,
AppLocalizations.of(context)!.about
].map((e) => PopupMenuItem(value: e, child: Text(e))).toList(),
onSelected: (value) {
if (value == "Settings") {
if (value == AppLocalizations.of(context)!.settings) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const SettingsView(),
),
);
} else if (value == "About") {
} else if (value == AppLocalizations.of(context)!.about) {
showAboutDialog(
context: context,
applicationLegalese:
"©️ 2023 Matyáš Caras\nReleased under the GNU AGPL license version 3",
applicationLegalese: AppLocalizations.of(context)!.license,
applicationName: "Prašule");
}
},
@ -133,17 +135,17 @@ class _HomeViewState extends State<HomeView> {
],
)
: (selectedWallet!.entries.isEmpty)
? const Column(
? Column(
children: [
Text(
"No entries :(",
style: TextStyle(
AppLocalizations.of(context)!.noEntries,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
Text(
"Add one using the floating action button.",
AppLocalizations.of(context)!.noEntriesSub,
)
],
)
@ -162,7 +164,7 @@ class _HomeViewState extends State<HomeView> {
SlidableAction(
onPressed: (c) {
Navigator.of(context)
.push<WalletEntry>(
.push<WalletSingleEntry>(
MaterialPageRoute(
builder: (c) => CreateEntryView(
w: selectedWallet!,
@ -196,9 +198,10 @@ class _HomeViewState extends State<HomeView> {
showDialog(
context: context,
builder: (cx) => PlatformDialog(
title: "Are you sure",
content: const Text(
"Do you really want to delete this entry?"),
title:
AppLocalizations.of(context)!.sureDialog,
content: Text(
AppLocalizations.of(context)!.deleteSure),
actions: [
PlatformButton(
text: "Yes",
@ -237,9 +240,9 @@ class _HomeViewState extends State<HomeView> {
),
),
),
title: Text(element.name),
title: Text(element.data.name),
subtitle: Text(
"${element.amount} ${selectedWallet!.currency.symbol}"),
"${element.data.amount} ${selectedWallet!.currency.symbol}"),
),
),
),
@ -254,10 +257,9 @@ class _HomeViewState extends State<HomeView> {
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content:
const Text("You do not have any OCR language data downloaded"),
content: Text(AppLocalizations.of(context)!.missingOcr),
action: SnackBarAction(
label: "Download",
label: AppLocalizations.of(context)!.download,
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
@ -272,12 +274,12 @@ class _HomeViewState extends State<HomeView> {
}
if (!mounted) return;
var selectedLanguages = List<bool>.filled(availableLanguages.length, false);
if (selectedLanguages.length == 1) {
selectedLanguages[0] = true;
}
showDialog(
context: context,
builder: (c) => PlatformDialog(
builder: (c) => StatefulBuilder(
builder: (ctx, setState) => PlatformDialog(
actions: [
TextButton(
onPressed: () async {
@ -289,20 +291,44 @@ class _HomeViewState extends State<HomeView> {
}
// get selected languages
var selected = availableLanguages
.where((element) =>
selectedLanguages[availableLanguages.indexOf(element)])
.where((element) => selectedLanguages[
availableLanguages.indexOf(element)])
.join("+")
.replaceAll(".traineddata", "");
logger.i(selected);
if (!mounted) return;
showDialog(
context: context,
builder: (c) => PlatformDialog(
title: AppLocalizations.of(context)!.ocrLoading),
barrierDismissible: false);
var string = await FlutterTesseractOcr.extractText(media.path,
language: selected,
args: {
//"psm": "4",
"psm": "4",
"preserve_interword_spaces": "1",
});
if (!mounted) return;
Navigator.of(context).pop();
logger.i(string);
if (mounted) Navigator.of(context).pop();
return;
if (!mounted) return;
var lines = string.split("\n")
..removeWhere((element) {
element.trim();
return element.isEmpty;
});
var data = <EntryData>[];
for (var line in lines) {
var regex = RegExp(r'\d+(?:\.|,)\d+');
var price = 0.0;
for (var match in regex.allMatches(line)) {
price += double.tryParse(match.group(0).toString()) ?? 0;
}
data.add(EntryData(name: "Idk", amount: price));
}
Navigator.of(context).pop();
// TODO: send to create
},
child: const Text("Ok")),
TextButton(
@ -311,7 +337,7 @@ class _HomeViewState extends State<HomeView> {
},
child: const Text("Cancel")),
],
title: "Select languages for OCR",
title: AppLocalizations.of(context)!.ocrSelect,
content: Column(
children: [
...List.generate(
@ -328,7 +354,7 @@ class _HomeViewState extends State<HomeView> {
1 &&
!value)) return;
selectedLanguages[index] = value;
setState(() {}); // todo: builder
setState(() {});
},
),
const SizedBox(
@ -341,6 +367,7 @@ class _HomeViewState extends State<HomeView> {
],
),
),
),
);
}
@ -352,6 +379,7 @@ class _HomeViewState extends State<HomeView> {
}
final List<XFile>? files = response.files;
if (files != null) {
logger.i("Found lost files");
_handleLostFiles(files);
} else {
logger.e(response.exception);

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:prasule/views/settings/tessdata_list.dart';
import 'package:settings_ui/settings_ui.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class SettingsView extends StatefulWidget {
const SettingsView({super.key});
@ -13,7 +14,7 @@ class _SettingsViewState extends State<SettingsView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Settings")),
appBar: AppBar(title: Text(AppLocalizations.of(context)!.settings)),
body: SettingsList(
applicationType: ApplicationType.both,
darkTheme: SettingsThemeData(
@ -23,15 +24,15 @@ class _SettingsViewState extends State<SettingsView> {
SettingsSection(
tiles: [
SettingsTile.navigation(
title: const Text("View downloaded OCR data"),
description: const Text(
"This data is used by the OCR to recognise text from pictures"),
title: Text(AppLocalizations.of(context)!.downloadedOcr),
description:
Text(AppLocalizations.of(context)!.downloadedOcrDesc),
onPressed: (context) => Navigator.of(context).push(
MaterialPageRoute(
builder: (c) => const TessdataListView())),
)
],
title: const Text("OCR"),
title: Text(AppLocalizations.of(context)!.ocr),
),
],
),

View file

@ -7,6 +7,7 @@ import 'package:prasule/main.dart';
import 'package:prasule/network/tessdata.dart';
import 'package:prasule/pw/platformbutton.dart';
import 'package:prasule/pw/platformdialog.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class TessdataListView extends StatefulWidget {
const TessdataListView({super.key});
@ -28,7 +29,7 @@ class _TessdataListViewState extends State<TessdataListView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("OCR data")),
appBar: AppBar(title: Text(AppLocalizations.of(context)!.ocrData)),
body: Center(
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
@ -49,8 +50,8 @@ class _TessdataListViewState extends State<TessdataListView> {
title: Text(_tessdata[i].keys.first),
trailing: TextButton(
child: Text(_tessdata[i][_tessdata[i].keys.first]!
? "Downloaded"
: "Download"),
? AppLocalizations.of(context)!.downloaded
: AppLocalizations.of(context)!.download),
onPressed: () async {
var lang = _tessdata[i].keys.first;
if (_tessdata[i][lang]!) {
@ -58,12 +59,12 @@ class _TessdataListViewState extends State<TessdataListView> {
showDialog(
context: context,
builder: (context) => PlatformDialog(
title: "Warning",
content: Text(
"Do you want to delete '$lang' OCR data?\nYou will not be able to utilize this language when using the OCR functions."),
title: AppLocalizations.of(context)!.sureDialog,
content: Text(AppLocalizations.of(context)!
.deleteOcr(lang)),
actions: [
PlatformButton(
text: "Yes",
text: AppLocalizations.of(context)!.yes,
onPressed: () async {
await TessdataApi.deleteData(lang);
_tessdata[i][lang] = true;
@ -71,7 +72,7 @@ class _TessdataListViewState extends State<TessdataListView> {
},
),
PlatformButton(
text: "No",
text: AppLocalizations.of(context)!.no,
onPressed: () {
Navigator.of(context).pop();
},
@ -90,7 +91,8 @@ class _TessdataListViewState extends State<TessdataListView> {
showDialog(
context: context,
builder: (c) => PlatformDialog(
title: "Downloading $lang, please wait...",
title: AppLocalizations.of(context)!
.langDownloadDialog(lang),
content: StreamBuilder(
builder: (context, snapshot) {
if (snapshot.connectionState ==
@ -100,8 +102,8 @@ class _TessdataListViewState extends State<TessdataListView> {
if (snapshot.hasError) {
return const Text("Error");
}
return Text(
"Download progress: ${snapshot.data} %");
return Text(AppLocalizations.of(context)!
.langDownloadProgress(snapshot.data!));
},
stream: progressStream.stream,
),

View file

@ -9,6 +9,7 @@ import 'package:prasule/pw/platformbutton.dart';
import 'package:prasule/pw/platformdialog.dart';
import 'package:prasule/pw/platformfield.dart';
import 'package:prasule/views/home.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class SetupView extends StatefulWidget {
const SetupView({super.key});
@ -31,34 +32,42 @@ class _SetupViewState extends State<SetupView> {
"space_between_amount_and_symbol": false,
"symbol_on_left": true,
});
var categories = <WalletCategory>[
var categories = <WalletCategory>[];
var name = "";
@override
void initState() {
super.initState();
categories = [
WalletCategory(
name: "Health",
name: AppLocalizations.of(context)!.categoryHealth,
type: EntryType.expense,
id: 1,
icon: IconData(Icons.medical_information.codePoint,
fontFamily: 'MaterialIcons'),
),
WalletCategory(
name: "Car",
name: AppLocalizations.of(context)!.categoryCar,
type: EntryType.expense,
id: 2,
icon: IconData(Icons.car_repair.codePoint, fontFamily: 'MaterialIcons'),
),
WalletCategory(
name: "Food",
name: AppLocalizations.of(context)!.categoryFood,
type: EntryType.expense,
id: 3,
icon: IconData(Icons.restaurant.codePoint, fontFamily: 'MaterialIcons'),
),
WalletCategory(
name: "Travel",
name: AppLocalizations.of(context)!.categoryTravel,
type: EntryType.expense,
id: 4,
icon: IconData(Icons.train.codePoint, fontFamily: 'MaterialIcons'),
),
];
var name = "";
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -73,15 +82,16 @@ class _SetupViewState extends State<SetupView> {
showNextButton: true,
showBackButton: true,
showDoneButton: true,
next: const Text("Next"),
back: const Text("Back"),
done: const Text("Finish"),
next: Text(AppLocalizations.of(context)!.next),
back: Text(AppLocalizations.of(context)!.back),
done: Text(AppLocalizations.of(context)!.finish),
onDone: () {
if (name.isEmpty) {
ScaffoldMessenger.of(context)
.clearSnackBars(); // TODO: iOS replacement
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Name cannot be empty")));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content:
Text(AppLocalizations.of(context)!.errorEmptyName)));
return;
}
var wallet = Wallet(
@ -100,39 +110,43 @@ class _SetupViewState extends State<SetupView> {
PageViewModel(
decoration:
const PageDecoration(bodyAlignment: Alignment.center),
titleWidget: const Padding(
padding: EdgeInsets.all(8),
titleWidget: Padding(
padding: const EdgeInsets.all(8),
child: Text(
"Welcome!",
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
AppLocalizations.of(context)!.welcome,
style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
bodyWidget: const Column(
bodyWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
"Prašule is an expense tracker tool designed for people, who don't want to spend too much time filling in all the little details.")),
SizedBox(
AppLocalizations.of(context)!.welcomeAboutPrasule),
),
const SizedBox(
height: 5,
),
Flexible(
child: Text(
"On this screen you will set up your 'wallet', in which you will track your expenses categorized under categories, which you can later set in the settings menu.")),
AppLocalizations.of(context)!.welcomeInstruction),
),
],
),
),
PageViewModel(
decoration:
const PageDecoration(bodyAlignment: Alignment.center),
titleWidget: const Padding(
padding: EdgeInsets.all(8),
titleWidget: Padding(
padding: const EdgeInsets.all(8),
child: Text(
"Set your wallet's name and currency",
AppLocalizations.of(context)!.setupWalletNameCurrency,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.bold),
),
),
bodyWidget: Column(
@ -141,7 +155,8 @@ class _SetupViewState extends State<SetupView> {
SizedBox(
width: MediaQuery.of(context).size.width * 0.7,
child: PlatformField(
labelText: "Your awesome name here...",
labelText:
AppLocalizations.of(context)!.setupNamePlaceholder,
onChanged: (t) {
name = t;
},
@ -151,7 +166,8 @@ class _SetupViewState extends State<SetupView> {
height: 5,
),
PlatformButton(
text: "Currency: ${_selectedCurrency.code}",
text: AppLocalizations.of(context)!
.setupCurrency(_selectedCurrency.code),
onPressed: () {
showCurrencyPicker(
context: context,
@ -168,19 +184,20 @@ class _SetupViewState extends State<SetupView> {
PageViewModel(
decoration:
const PageDecoration(bodyAlignment: Alignment.center),
titleWidget: const Padding(
padding: EdgeInsets.all(8),
titleWidget: Padding(
padding: const EdgeInsets.all(8),
child: Text(
"Create categories",
AppLocalizations.of(context)!.setupCategoriesHeading,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.bold),
),
),
bodyWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Tap on the icon or name to edit it",
Text(
AppLocalizations.of(context)!.setupCategoriesEditHint,
textAlign: TextAlign.center,
),
SizedBox(
@ -232,16 +249,19 @@ class _SetupViewState extends State<SetupView> {
categories[i].name = controller.text;
Navigator.of(context).pop();
},
child: const Text("Ok"),
child: Text(
AppLocalizations.of(context)!.ok),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text("Cancel"),
child: Text(
AppLocalizations.of(context)!.cancel),
),
],
title: "Editing name",
title: AppLocalizations.of(context)!
.setupCategoriesEditingName,
content: SizedBox(
width: 400,
child:
@ -270,7 +290,8 @@ class _SetupViewState extends State<SetupView> {
}
categories.add(
WalletCategory(
name: "Edit me",
name: AppLocalizations.of(context)!
.setupWalletNamePlaceholder,
type: EntryType.expense,
id: id,
icon: IconData(Icons.question_mark.codePoint,

View file

@ -387,6 +387,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
flutter_localizations:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
@ -534,10 +539,10 @@ packages:
dependency: transitive
description:
name: image_picker_ios
sha256: c5538cacefacac733c724be7484377923b476216ad1ead35a0d2eadcdc0fc497
sha256: "76ec722aeea419d03aa915c2c96bf5b47214b053899088c9abb4086ceecf97a7"
url: "https://pub.dev"
source: hosted
version: "0.8.8+2"
version: "0.8.8+4"
image_picker_linux:
dependency: transitive
description:

View file

@ -1,21 +1,6 @@
name: prasule
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
description: Open-source private expense tracker
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
@ -45,12 +30,14 @@ dependencies:
flutter_iconpicker: ^3.2.4
dynamic_color: ^1.6.6
introduction_screen: ^3.1.11
intl: ^0.18.1
intl: any
grouped_list: ^5.1.2
flutter_speed_dial: ^7.0.0
image_picker: ^1.0.1
flutter_tesseract_ocr: ^0.4.23
flutter_slidable: ^3.0.0
flutter_localizations:
sdk: flutter
dev_dependencies:
flutter_test:
@ -91,7 +78,7 @@ flutter_launcher_icons:
# The following section is specific to Flutter packages.
flutter:
generate: true
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.