1.0.0 release #31

Merged
hernik merged 31 commits from dev into main 2024-02-10 16:27:33 +01:00
6 changed files with 81 additions and 10 deletions
Showing only changes of commit 943bf15aab - Show all commits

View file

@ -4,6 +4,9 @@
- Placeholder text is now inserted into the field in setup, instead of showing as label - Placeholder text is now inserted into the field in setup, instead of showing as label
- Show version text in about dialog - Show version text in about dialog
- Added tessdata license text into about dialog - Added tessdata license text into about dialog
- Added sorting by oldest
- Moved search into three-dot menu
- Make search case-insensitive
# 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

@ -106,5 +106,9 @@
"exportCompleted":"Export dokončen", "exportCompleted":"Export dokončen",
"importCompleted":"Import dokončen", "importCompleted":"Import dokončen",
"setup":"Prvotní nastavení", "setup":"Prvotní nastavení",
"sourceCode":"Zdrojový kód" "sourceCode":"Zdrojový kód",
"sortNewest":"Nejnovější první",
"sortOldest":"Nejstarší první",
"sort":"Seřadit",
"search":"Prohledat"
} }

View file

@ -222,5 +222,9 @@
"exportCompleted":"Export completed", "exportCompleted":"Export completed",
"importCompleted":"Import completed", "importCompleted":"Import completed",
"setup":"Setup", "setup":"Setup",
"sourceCode":"Source code" "sourceCode":"Source code",
"sortNewest":"Newest first",
"sortOldest":"Oldest first",
"sort":"Sort",
"search":"Search"
} }

58
lib/util/sorting.dart Normal file
View file

@ -0,0 +1,58 @@
import 'package:grouped_list/grouped_list.dart';
import 'package:intl/intl.dart';
/// Sorts [GroupedListView]'s group by newest group
int groupSortNewest(String a, String b, String locale) {
// TODO: better sorting algorithm lol
final yearA = RegExp(r'\d+').firstMatch(a);
if (yearA == null) return 0;
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 months = List<String>.generate(
12,
(index) => DateFormat.MMMM(locale).format(
DateTime(2023, index + 1),
),
);
final monthA = RegExp('[^0-9 ]+').firstMatch(a);
if (monthA == null) return 0;
final monthB = RegExp('[^0-9 ]+').firstMatch(b);
if (monthB == null) return 0;
return months.indexOf(monthB.group(0)!).compareTo(
months.indexOf(monthA.group(0)!),
);
}
/// Sorts [GroupedListView]'s group by oldest group
int groupSortOldest(String a, String b, String locale) {
// TODO: better sorting algorithm lol
final yearA = RegExp(r'\d+').firstMatch(a);
if (yearA == null) return 0;
final yearB = RegExp(r'\d+').firstMatch(b);
if (yearB == null) return 0;
final compareYears = int.parse(yearA.group(0)!).compareTo(
int.parse(yearB.group(0)!),
);
if (compareYears != 0) {
return compareYears;
}
final months = List<String>.generate(
12,
(index) => DateFormat.MMMM(locale).format(
DateTime(2023, index + 1),
),
);
final monthA = RegExp('[^0-9 ]+').firstMatch(a);
if (monthA == null) return 0;
final monthB = RegExp('[^0-9 ]+').firstMatch(b);
if (monthB == null) return 0;
return months.indexOf(monthA.group(0)!).compareTo(
months.indexOf(monthB.group(0)!),
);
}

View file

@ -197,13 +197,6 @@ class _HomeViewState extends State<HomeView> {
actions: _searchActive actions: _searchActive
? [] ? []
: [ : [
IconButton(
onPressed: () {
_searchActive = true;
setState(() {});
},
icon: const Icon(Icons.search),
),
PopupMenuButton( PopupMenuButton(
tooltip: AppLocalizations.of(context).sort, tooltip: AppLocalizations.of(context).sort,
icon: const Icon(Icons.sort_rounded), icon: const Icon(Icons.sort_rounded),
@ -232,6 +225,7 @@ class _HomeViewState extends State<HomeView> {
PopupMenuButton( PopupMenuButton(
itemBuilder: (context) => [ itemBuilder: (context) => [
AppLocalizations.of(context).settings, AppLocalizations.of(context).settings,
AppLocalizations.of(context).search,
AppLocalizations.of(context).about, AppLocalizations.of(context).about,
] ]
.map((e) => PopupMenuItem(value: e, child: Text(e))) .map((e) => PopupMenuItem(value: e, child: Text(e)))
@ -251,6 +245,12 @@ class _HomeViewState extends State<HomeView> {
}); });
} else if (value == AppLocalizations.of(context).about) { } else if (value == AppLocalizations.of(context).about) {
showAbout(context); showAbout(context);
} else if (value == AppLocalizations.of(context).search) {
_searchActive = !_searchActive;
if (!_searchActive) {
_filter = "";
}
setState(() {});
} }
}, },
), ),
@ -384,7 +384,8 @@ class _HomeViewState extends State<HomeView> {
elements: selectedWallet!.entries elements: selectedWallet!.entries
.where( .where(
(element) => element.data.name (element) => element.data.name
.contains(_filter), .toLowerCase()
.contains(_filter.toLowerCase()),
) )
.toList(), .toList(),
itemComparator: (a, b) => itemComparator: (a, b) =>

View file

@ -57,6 +57,7 @@ class _SetupViewState extends State<SetupView> {
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
if (categories.isEmpty) { if (categories.isEmpty) {
name = AppLocalizations.of(context).setupNamePlaceholder;
categories = [ categories = [
WalletCategory( WalletCategory(
name: AppLocalizations.of(context).noCategory, name: AppLocalizations.of(context).noCategory,