Compare commits
1 commit
7a2eed855d
...
fedb98c500
Author | SHA1 | Date | |
---|---|---|---|
|
fedb98c500 |
7 changed files with 388 additions and 503 deletions
|
@ -1,7 +1,3 @@
|
|||
|
||||
# 1.0.0-alpha+5
|
||||
- Add tests
|
||||
- Add searching through entries to homepage
|
||||
# 1.0.0-alpha+4
|
||||
- Fix OCR downloads
|
||||
# 1.0.0-alpha+3
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
<application
|
||||
android:label="Prašule"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:enableOnBackInvokedCallback="true">
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
|
|
|
@ -90,6 +90,5 @@
|
|||
"startingWithDate": "počínaje datem",
|
||||
"evenMoney":"Váš stav je stejný jako minulý měsíc.",
|
||||
"balanceStatusA": "Váš stav je ",
|
||||
"balanceStatusB": " oproti minulému měsíci.",
|
||||
"searchLabel":"Prohledat záznamy..."
|
||||
"balanceStatusB": " oproti minulému měsíci."
|
||||
}
|
|
@ -206,6 +206,5 @@
|
|||
},
|
||||
"evenMoney":"You're on the same balance as last month.",
|
||||
"balanceStatusA": "Your balance is ",
|
||||
"balanceStatusB": " compared to last month.",
|
||||
"searchLabel":"Search entries..."
|
||||
"balanceStatusB": " compared to last month."
|
||||
}
|
|
@ -21,8 +21,6 @@ class PlatformField extends PlatformWidget<TextField, CupertinoTextField> {
|
|||
this.textStyle,
|
||||
this.textAlign = TextAlign.start,
|
||||
this.maxLines = 1,
|
||||
this.focusNode,
|
||||
this.inputBorder = const OutlineInputBorder(),
|
||||
});
|
||||
final TextEditingController? controller;
|
||||
final bool? enabled;
|
||||
|
@ -36,8 +34,6 @@ class PlatformField extends PlatformWidget<TextField, CupertinoTextField> {
|
|||
final TextStyle? textStyle;
|
||||
final TextAlign textAlign;
|
||||
final int? maxLines;
|
||||
final InputBorder inputBorder;
|
||||
final FocusNode? focusNode;
|
||||
|
||||
@override
|
||||
TextField createAndroidWidget(BuildContext context) => TextField(
|
||||
|
@ -47,11 +43,10 @@ class PlatformField extends PlatformWidget<TextField, CupertinoTextField> {
|
|||
obscureText: obscureText,
|
||||
decoration: InputDecoration(
|
||||
labelText: labelText,
|
||||
border: inputBorder,
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(4)),
|
||||
),
|
||||
autocorrect: autocorrect,
|
||||
keyboardType: keyboardType,
|
||||
focusNode: focusNode,
|
||||
style: textStyle,
|
||||
inputFormatters: inputFormatters,
|
||||
onChanged: onChanged,
|
||||
|
@ -71,7 +66,6 @@ class PlatformField extends PlatformWidget<TextField, CupertinoTextField> {
|
|||
keyboardType: keyboardType,
|
||||
inputFormatters: inputFormatters,
|
||||
onChanged: onChanged,
|
||||
focusNode: focusNode,
|
||||
maxLines: maxLines,
|
||||
style: textStyle,
|
||||
);
|
||||
|
|
|
@ -22,7 +22,6 @@ 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:prasule/pw/platformfield.dart';
|
||||
import 'package:prasule/pw/platformroute.dart';
|
||||
import 'package:prasule/util/drawer.dart';
|
||||
import 'package:prasule/util/text_color.dart';
|
||||
|
@ -45,9 +44,6 @@ class _HomeViewState extends State<HomeView> {
|
|||
List<Wallet> wallets = [];
|
||||
DateTime? prevDate;
|
||||
late String locale;
|
||||
var _searchActive = false;
|
||||
var _filter = "";
|
||||
final searchFocus = FocusNode();
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
|
@ -77,16 +73,7 @@ class _HomeViewState extends State<HomeView> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopScope(
|
||||
canPop: !_searchActive, // don't pop when we just want
|
||||
// to deactivate searchfield
|
||||
onPopInvoked: (b) {
|
||||
if (b) return;
|
||||
_searchActive = false;
|
||||
_filter = "";
|
||||
setState(() {});
|
||||
},
|
||||
child: Scaffold(
|
||||
return Scaffold(
|
||||
drawer: makeDrawer(context, 1),
|
||||
floatingActionButton: SpeedDial(
|
||||
icon: Icons.add,
|
||||
|
@ -128,8 +115,7 @@ class _HomeViewState extends State<HomeView> {
|
|||
label: AppLocalizations.of(context).addCamera,
|
||||
onTap: () async {
|
||||
final picker = ImagePicker();
|
||||
final media =
|
||||
await picker.pickImage(source: ImageSource.camera);
|
||||
final media = await picker.pickImage(source: ImageSource.camera);
|
||||
logger.i(media?.name);
|
||||
},
|
||||
),
|
||||
|
@ -143,24 +129,9 @@ class _HomeViewState extends State<HomeView> {
|
|||
],
|
||||
),
|
||||
appBar: AppBar(
|
||||
title: AnimatedCrossFade(
|
||||
duration: const Duration(milliseconds: 500),
|
||||
crossFadeState: _searchActive
|
||||
? CrossFadeState.showFirst
|
||||
: CrossFadeState.showSecond,
|
||||
firstChild: PlatformField(
|
||||
inputBorder: InputBorder.none,
|
||||
focusNode: searchFocus,
|
||||
onChanged: (e) {
|
||||
_filter = e;
|
||||
setState(() {});
|
||||
},
|
||||
labelText: AppLocalizations.of(context).searchLabel,
|
||||
),
|
||||
secondChild: DropdownButton<int>(
|
||||
value: (selectedWallet == null)
|
||||
? -1
|
||||
: wallets.indexOf(selectedWallet!),
|
||||
title: DropdownButton<int>(
|
||||
value:
|
||||
(selectedWallet == null) ? -1 : wallets.indexOf(selectedWallet!),
|
||||
items: [
|
||||
...wallets.map(
|
||||
(e) => DropdownMenuItem(
|
||||
|
@ -193,17 +164,7 @@ class _HomeViewState extends State<HomeView> {
|
|||
setState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
if (!_searchActive)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_searchActive = true;
|
||||
setState(() {});
|
||||
},
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
if (!_searchActive)
|
||||
PopupMenuButton(
|
||||
itemBuilder: (context) => [
|
||||
AppLocalizations.of(context).settings,
|
||||
|
@ -261,18 +222,13 @@ class _HomeViewState extends State<HomeView> {
|
|||
),
|
||||
],
|
||||
)
|
||||
: Overlay(
|
||||
initialEntries: [
|
||||
OverlayEntry(
|
||||
builder: (context) => Column(
|
||||
: Column(
|
||||
children: [
|
||||
Text(
|
||||
NumberFormat.compactCurrency(
|
||||
locale: locale,
|
||||
symbol: selectedWallet!.currency.symbol,
|
||||
).format(
|
||||
selectedWallet!.calculateCurrentBalance(),
|
||||
),
|
||||
).format(selectedWallet!.calculateCurrentBalance()),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 22,
|
||||
|
@ -326,11 +282,9 @@ class _HomeViewState extends State<HomeView> {
|
|||
),
|
||||
text: NumberFormat.compactCurrency(
|
||||
locale: locale,
|
||||
symbol:
|
||||
selectedWallet!.currency.symbol,
|
||||
symbol: selectedWallet!.currency.symbol,
|
||||
).format(
|
||||
selectedWallet!
|
||||
.calculateMonthStatus(
|
||||
selectedWallet!.calculateMonthStatus(
|
||||
DateTime.now().month,
|
||||
DateTime.now().year,
|
||||
),
|
||||
|
@ -349,53 +303,35 @@ class _HomeViewState extends State<HomeView> {
|
|||
Expanded(
|
||||
child: GroupedListView(
|
||||
groupHeaderBuilder: (element) => Text(
|
||||
DateFormat.yMMMM(locale)
|
||||
.format(element.date),
|
||||
DateFormat.yMMMM(locale).format(element.date),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
elements: selectedWallet!.entries
|
||||
.where((element) =>
|
||||
element.data.name.contains(_filter))
|
||||
.toList(),
|
||||
itemComparator: (a, b) =>
|
||||
b.date.compareTo(a.date),
|
||||
elements: selectedWallet!.entries,
|
||||
itemComparator: (a, b) => b.date.compareTo(a.date),
|
||||
groupBy: (e) =>
|
||||
DateFormat.yMMMM(locale).format(e.date),
|
||||
groupComparator: (a, b) {
|
||||
// TODO: better sorting algorithm lol
|
||||
final yearA =
|
||||
RegExp(r'\d+').firstMatch(a);
|
||||
final yearA = RegExp(r'\d+').firstMatch(a);
|
||||
if (yearA == null) return 0;
|
||||
final yearB =
|
||||
RegExp(r'\d+').firstMatch(b);
|
||||
final yearB = RegExp(r'\d+').firstMatch(b);
|
||||
if (yearB == null) return 0;
|
||||
final compareYears =
|
||||
int.parse(yearB.group(0)!).compareTo(
|
||||
int.parse(yearA.group(0)!),
|
||||
);
|
||||
if (compareYears != 0) {
|
||||
return compareYears;
|
||||
}
|
||||
final compareYears = int.parse(yearB.group(0)!)
|
||||
.compareTo(int.parse(yearA.group(0)!));
|
||||
if (compareYears != 0) return compareYears;
|
||||
final months = List<String>.generate(
|
||||
12,
|
||||
(index) =>
|
||||
DateFormat.MMMM(locale).format(
|
||||
(index) => DateFormat.MMMM(locale).format(
|
||||
DateTime(2023, index + 1),
|
||||
),
|
||||
);
|
||||
final monthA =
|
||||
RegExp('[^0-9 ]+').firstMatch(a);
|
||||
final monthA = RegExp('[^0-9 ]+').firstMatch(a);
|
||||
if (monthA == null) return 0;
|
||||
final monthB =
|
||||
RegExp('[^0-9 ]+').firstMatch(b);
|
||||
final monthB = RegExp('[^0-9 ]+').firstMatch(b);
|
||||
if (monthB == null) return 0;
|
||||
return months
|
||||
.indexOf(monthB.group(0)!)
|
||||
.compareTo(
|
||||
return months.indexOf(monthB.group(0)!).compareTo(
|
||||
months.indexOf(monthA.group(0)!),
|
||||
);
|
||||
},
|
||||
|
@ -408,8 +344,7 @@ class _HomeViewState extends State<HomeView> {
|
|||
Navigator.of(context)
|
||||
.push<WalletSingleEntry>(
|
||||
MaterialPageRoute(
|
||||
builder: (c) =>
|
||||
CreateSingleEntryView(
|
||||
builder: (c) => CreateSingleEntryView(
|
||||
w: selectedWallet!,
|
||||
editEntry: element,
|
||||
),
|
||||
|
@ -417,9 +352,7 @@ class _HomeViewState extends State<HomeView> {
|
|||
)
|
||||
.then(
|
||||
(editedEntry) {
|
||||
if (editedEntry == null) {
|
||||
return;
|
||||
}
|
||||
if (editedEntry == null) return;
|
||||
selectedWallet!.entries
|
||||
.remove(element);
|
||||
selectedWallet!.entries
|
||||
|
@ -431,48 +364,40 @@ class _HomeViewState extends State<HomeView> {
|
|||
},
|
||||
);
|
||||
},
|
||||
backgroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary,
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.secondary,
|
||||
foregroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSecondary,
|
||||
icon: Icons.edit,
|
||||
),
|
||||
SlidableAction(
|
||||
backgroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.error,
|
||||
foregroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onError,
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.error,
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.onError,
|
||||
icon: Icons.delete,
|
||||
onPressed: (c) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (cx) => PlatformDialog(
|
||||
title: AppLocalizations.of(
|
||||
context,
|
||||
).sureDialog,
|
||||
title: AppLocalizations.of(context)
|
||||
.sureDialog,
|
||||
content: Text(
|
||||
AppLocalizations.of(context)
|
||||
.deleteSure,
|
||||
),
|
||||
actions: [
|
||||
PlatformButton(
|
||||
text: AppLocalizations.of(
|
||||
context,
|
||||
).yes,
|
||||
text: AppLocalizations.of(context)
|
||||
.yes,
|
||||
onPressed: () {
|
||||
selectedWallet?.entries
|
||||
.removeWhere(
|
||||
(e) =>
|
||||
e.id ==
|
||||
element.id,
|
||||
(e) => e.id == element.id,
|
||||
);
|
||||
|
||||
WalletManager
|
||||
.saveWallet(
|
||||
WalletManager.saveWallet(
|
||||
selectedWallet!,
|
||||
);
|
||||
Navigator.of(cx).pop();
|
||||
|
@ -480,9 +405,8 @@ class _HomeViewState extends State<HomeView> {
|
|||
},
|
||||
),
|
||||
PlatformButton(
|
||||
text: AppLocalizations.of(
|
||||
context,
|
||||
).no,
|
||||
text: AppLocalizations.of(context)
|
||||
.no,
|
||||
onPressed: () {
|
||||
Navigator.of(cx).pop();
|
||||
},
|
||||
|
@ -497,8 +421,7 @@ class _HomeViewState extends State<HomeView> {
|
|||
child: ListTile(
|
||||
leading: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(16),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
color: element.category.color,
|
||||
),
|
||||
child: Padding(
|
||||
|
@ -516,8 +439,8 @@ class _HomeViewState extends State<HomeView> {
|
|||
children: [
|
||||
TextSpan(
|
||||
text: NumberFormat.currency(
|
||||
symbol: selectedWallet!
|
||||
.currency.symbol,
|
||||
symbol:
|
||||
selectedWallet!.currency.symbol,
|
||||
).format(element.data.amount),
|
||||
style: TextStyle(
|
||||
color: (element.type ==
|
||||
|
@ -525,10 +448,8 @@ class _HomeViewState extends State<HomeView> {
|
|||
? (MediaQuery.of(context)
|
||||
.platformBrightness ==
|
||||
Brightness.dark)
|
||||
? Colors
|
||||
.green.shade300
|
||||
: Colors.green
|
||||
.harmonizeWith(
|
||||
? Colors.green.shade300
|
||||
: Colors.green.harmonizeWith(
|
||||
Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
|
@ -537,8 +458,7 @@ class _HomeViewState extends State<HomeView> {
|
|||
.platformBrightness ==
|
||||
Brightness.dark)
|
||||
? Colors.red.shade300
|
||||
: Colors.red
|
||||
.harmonizeWith(
|
||||
: Colors.red.harmonizeWith(
|
||||
Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
|
@ -565,28 +485,6 @@ class _HomeViewState extends State<HomeView> {
|
|||
],
|
||||
),
|
||||
),
|
||||
OverlayEntry(
|
||||
builder: (context) => SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (!_searchActive) return;
|
||||
if (!searchFocus.hasFocus) {
|
||||
_searchActive = false;
|
||||
_filter = "";
|
||||
setState(() {});
|
||||
return;
|
||||
}
|
||||
searchFocus.unfocus();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
name: prasule
|
||||
description: Open-source private expense tracker
|
||||
|
||||
version: 1.0.0-alpha+5
|
||||
version: 1.0.0-alpha+4
|
||||
|
||||
environment:
|
||||
sdk: '>=3.1.0-262.2.beta <4.0.0'
|
||||
|
|
Loading…
Reference in a new issue