Compare commits

..

No commits in common. "1556b9bd1e28b5790ae02e8682cfc81ace273388" and "71444af7b0bf1cfaef322ecd83b9252efc8374c0" have entirely different histories.

6 changed files with 31 additions and 71 deletions

View file

@ -9,8 +9,6 @@
- Make search case-insensitive - Make search case-insensitive
- Added titles above graphs - Added titles above graphs
- Some extra optimization for iOS - Some extra optimization for iOS
- Fix starting balance not saving
- Fix overlay disabling tappig on edit/delete buttons on home view
# 1.0.0-alpha+5 # 1.0.0-alpha+5
- Add tests - Add tests
- Add searching through entries to homepage - Add searching through entries to homepage

View file

@ -113,6 +113,5 @@
"search":"Prohledat", "search":"Prohledat",
"expensesPerYear":"Měsíční výdaje v roce {year}", "expensesPerYear":"Měsíční výdaje v roce {year}",
"expensesPerMonth":"Denní výdaje během měsíce {monthYear}", "expensesPerMonth":"Denní výdaje během měsíce {monthYear}",
"expensesPerCategory":"Total expenses per category", "expensesPerCategory":"Total expenses per category"
"date":"Datum"
} }

View file

@ -247,6 +247,5 @@
} }
} }
}, },
"expensesPerCategory":"Total expenses per category", "expensesPerCategory":"Total expenses per category"
"date":"Date"
} }

View file

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:intl/intl.dart';
import 'package:prasule/api/category.dart'; import 'package:prasule/api/category.dart';
import 'package:prasule/api/entry_data.dart'; import 'package:prasule/api/entry_data.dart';
import 'package:prasule/api/wallet.dart'; import 'package:prasule/api/wallet.dart';
@ -14,12 +13,7 @@ import 'package:prasule/util/show_message.dart';
/// Used when user wants to add new entry /// Used when user wants to add new entry
class CreateSingleEntryView extends StatefulWidget { class CreateSingleEntryView extends StatefulWidget {
/// Used when user wants to add new entry /// Used when user wants to add new entry
const CreateSingleEntryView({ const CreateSingleEntryView({required this.w, super.key, this.editEntry});
required this.w,
super.key,
this.editEntry,
required this.locale,
});
/// The wallet, where the entry will be saved to /// The wallet, where the entry will be saved to
final Wallet w; final Wallet w;
@ -29,8 +23,6 @@ class CreateSingleEntryView extends StatefulWidget {
/// Is null unless we are editing an existing entry /// Is null unless we are editing an existing entry
final WalletSingleEntry? editEntry; final WalletSingleEntry? editEntry;
final String locale;
@override @override
State createState() => _CreateSingleEntryViewState(); State createState() => _CreateSingleEntryViewState();
} }
@ -192,33 +184,6 @@ class _CreateSingleEntryViewState extends State<CreateSingleEntryView> {
}, },
), ),
), ),
const SizedBox(
height: 20,
),
Text(AppLocalizations.of(context).date),
PlatformButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
Theme.of(context).colorScheme.primary,
),
foregroundColor: MaterialStateProperty.all(
Theme.of(context).colorScheme.onPrimary,
),
),
text: DateFormat.yMMMMd(widget.locale).format(newEntry.date),
onPressed: () async {
final date = await showDatePicker(
initialDate: newEntry.date,
context: context,
firstDate: DateTime.now()
.subtract(const Duration(days: 20 * 365)),
lastDate: DateTime.now().add(const Duration(days: 365)),
);
if (date == null) return;
newEntry.date = date;
setState(() {});
},
),
const SizedBox( const SizedBox(
height: 15, height: 15,
), ),

View file

@ -117,10 +117,7 @@ class _HomeViewState extends State<HomeView> {
onTap: () async { onTap: () async {
final sw = await Navigator.of(context).push<Wallet>( final sw = await Navigator.of(context).push<Wallet>(
MaterialPageRoute( MaterialPageRoute(
builder: (c) => CreateSingleEntryView( builder: (c) => CreateSingleEntryView(w: selectedWallet!),
w: selectedWallet!,
locale: locale,
),
), ),
); );
if (sw != null) { if (sw != null) {
@ -422,7 +419,6 @@ class _HomeViewState extends State<HomeView> {
MaterialPageRoute( MaterialPageRoute(
builder: (c) => builder: (c) =>
CreateSingleEntryView( CreateSingleEntryView(
locale: locale,
w: selectedWallet!, w: selectedWallet!,
editEntry: element, editEntry: element,
), ),
@ -581,25 +577,24 @@ class _HomeViewState extends State<HomeView> {
], ],
), ),
), ),
if (_searchActive) OverlayEntry(
OverlayEntry( builder: (context) => SizedBox(
builder: (context) => SizedBox( width: MediaQuery.of(context).size.width,
width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height,
height: MediaQuery.of(context).size.height, child: GestureDetector(
child: GestureDetector( onTap: () {
onTap: () { if (!_searchActive) return;
if (!_searchActive) return; if (!searchFocus.hasFocus) {
if (!searchFocus.hasFocus) { _searchActive = false;
_searchActive = false; _filter = "";
_filter = ""; setState(() {});
setState(() {}); return;
return; }
} searchFocus.unfocus();
searchFocus.unfocus(); },
},
),
), ),
), ),
),
], ],
), ),
), ),
@ -715,7 +710,6 @@ class _HomeViewState extends State<HomeView> {
await Navigator.of(context).push<WalletSingleEntry>( await Navigator.of(context).push<WalletSingleEntry>(
platformRoute<WalletSingleEntry>( platformRoute<WalletSingleEntry>(
(c) => CreateSingleEntryView( (c) => CreateSingleEntryView(
locale: locale,
w: selectedWallet!, w: selectedWallet!,
editEntry: WalletSingleEntry( editEntry: WalletSingleEntry(
data: EntryData( data: EntryData(

View file

@ -51,7 +51,7 @@ class _SetupViewState extends State<SetupView> {
); );
List<WalletCategory> categories = <WalletCategory>[]; List<WalletCategory> categories = <WalletCategory>[];
String name = ""; String name = "";
final _balanceController = TextEditingController(text: "0.0"); double balance = 0;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
@ -155,10 +155,10 @@ class _SetupViewState extends State<SetupView> {
return; return;
} }
final wallet = Wallet( final wallet = Wallet(
name: name, name: name,
currency: _selectedCurrency, currency: _selectedCurrency,
categories: categories, categories: categories,
starterBalance: double.parse(_balanceController.text)); );
await WalletManager.saveWallet(wallet); await WalletManager.saveWallet(wallet);
if (widget.newWallet && context.mounted) { if (widget.newWallet && context.mounted) {
@ -267,7 +267,7 @@ class _SetupViewState extends State<SetupView> {
keyboardType: const TextInputType.numberWithOptions( keyboardType: const TextInputType.numberWithOptions(
decimal: true, decimal: true,
), ),
controller: _balanceController, controller: TextEditingController(text: "0.0"),
inputFormatters: [ inputFormatters: [
FilteringTextInputFormatter.allow( FilteringTextInputFormatter.allow(
RegExp(r'\d+[\.,]{0,1}\d{0,}'), RegExp(r'\d+[\.,]{0,1}\d{0,}'),
@ -277,6 +277,11 @@ class _SetupViewState extends State<SetupView> {
padding: const EdgeInsets.only(right: 4), padding: const EdgeInsets.only(right: 4),
child: Text(_selectedCurrency.symbol), child: Text(_selectedCurrency.symbol),
), ),
onChanged: (t) {
final b = double.tryParse(t);
if (b == null) return;
balance = b;
},
), ),
), ),
], ],