fix: allow changing date on entries
This commit is contained in:
parent
ae07720854
commit
1556b9bd1e
4 changed files with 46 additions and 4 deletions
|
@ -113,5 +113,6 @@
|
||||||
"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"
|
||||||
}
|
}
|
|
@ -247,5 +247,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expensesPerCategory":"Total expenses per category"
|
"expensesPerCategory":"Total expenses per category",
|
||||||
|
"date":"Date"
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
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';
|
||||||
|
@ -13,7 +14,12 @@ 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({required this.w, super.key, this.editEntry});
|
const CreateSingleEntryView({
|
||||||
|
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;
|
||||||
|
@ -23,6 +29,8 @@ 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();
|
||||||
}
|
}
|
||||||
|
@ -184,6 +192,33 @@ 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,
|
||||||
),
|
),
|
||||||
|
|
|
@ -117,7 +117,10 @@ 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(w: selectedWallet!),
|
builder: (c) => CreateSingleEntryView(
|
||||||
|
w: selectedWallet!,
|
||||||
|
locale: locale,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (sw != null) {
|
if (sw != null) {
|
||||||
|
@ -419,6 +422,7 @@ class _HomeViewState extends State<HomeView> {
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (c) =>
|
builder: (c) =>
|
||||||
CreateSingleEntryView(
|
CreateSingleEntryView(
|
||||||
|
locale: locale,
|
||||||
w: selectedWallet!,
|
w: selectedWallet!,
|
||||||
editEntry: element,
|
editEntry: element,
|
||||||
),
|
),
|
||||||
|
@ -711,6 +715,7 @@ 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(
|
||||||
|
|
Loading…
Reference in a new issue