Skip to content

Commit

Permalink
Merge pull request #1915 from matthiasn/feat/add_category_filter_in_l…
Browse files Browse the repository at this point in the history
…ogbook_tab

feat: add category filter in Logbook tab
  • Loading branch information
matthiasn authored Jan 23, 2025
2 parents 881783d + 6c2d747 commit 890e6f2
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 64 deletions.
2 changes: 2 additions & 0 deletions lib/blocs/journal/journal_page_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ class JournalPageCubit extends Cubit<JournalPageState> {
starredStatuses: starredEntriesOnly ? [true] : [true, false],
privateStatuses: privateEntriesOnly ? [true] : [true, false],
flaggedStatuses: flaggedEntriesOnly ? [1] : [1, 0],
categoryIds:
_selectedCategoryIds.isNotEmpty ? _selectedCategoryIds : null,
limit: _pageSize,
offset: pageKey,
);
Expand Down
13 changes: 13 additions & 0 deletions lib/database/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class JournalDb extends _$JournalDb {
required List<bool> privateStatuses,
required List<int> flaggedStatuses,
required List<String>? ids,
Set<String>? categoryIds,
int limit = 500,
int offset = 0,
}) async {
Expand All @@ -259,6 +260,7 @@ class JournalDb extends _$JournalDb {
starredStatuses: starredStatuses,
privateStatuses: privateStatuses,
flaggedStatuses: flaggedStatuses,
categoryIds: categoryIds?.toList(),
ids: ids,
limit: limit,
offset: offset,
Expand Down Expand Up @@ -299,6 +301,7 @@ class JournalDb extends _$JournalDb {
required List<bool> privateStatuses,
required List<int> flaggedStatuses,
required List<String>? ids,
required List<String>? categoryIds,
int limit = 500,
int offset = 0,
}) {
Expand All @@ -312,6 +315,16 @@ class JournalDb extends _$JournalDb {
limit,
offset,
);
} else if (categoryIds != null) {
return filteredJournalByCategories(
types,
starredStatuses,
privateStatuses,
flaggedStatuses,
categoryIds,
limit,
offset,
);
} else {
return filteredJournal(
types,
Expand Down
13 changes: 13 additions & 0 deletions lib/database/database.drift
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ SELECT * FROM journal
LIMIT :limit
OFFSET :offset;

filteredJournalByCategories:
SELECT * FROM journal
WHERE type IN :types
AND deleted = false
AND private IN (0, (SELECT status FROM config_flags WHERE name = 'private'))
AND starred IN :starredStatuses
AND private IN :privateStatuses
AND flag IN :flaggedStatuses
AND category IN :categories
ORDER BY date_from DESC
LIMIT :limit
OFFSET :offset;

filteredJournalIds:
SELECT id FROM journal
WHERE type IN :types
Expand Down
39 changes: 39 additions & 0 deletions lib/database/database.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 20 additions & 7 deletions lib/features/journal/ui/widgets/journal_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,27 @@ class JournalCardTitle extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
item is JournalEvent
? dfShort.format(item.meta.dateFrom)
: dfShorter.format(item.meta.dateFrom),
style: monospaceTextStyle,
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
item is JournalEvent
? dfShort.format(item.meta.dateFrom)
: dfShorter.format(item.meta.dateFrom),
style: monospaceTextStyle,
),
if (item is! ChecklistItem &&
item is! Checklist &&
item is! HabitCompletionEntry &&
item is! MeasurementEntry &&
item is! WorkoutEntry &&
item is! QuantitativeEntry &&
item is! SurveyEntry) ...[
const SizedBox(width: 20),
CategoryColorIcon(item.meta.categoryId),
],
],
),
if (item is Task)
CategoryColorIcon((item as Task).meta.categoryId),
if (item is Task) TaskStatusWidget(item as Task),
Row(
children: [
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
"syncAssistantStatusSuccess": "Account is successfully configured.",
"syncAssistantStatusTesting": "Testing IMAP connection...",
"syncAssistantStatusValid": "Account is valid.",
"taskCategoryLabel": "Task category:",
"taskCategoryLabel": "Category:",
"taskCategoryUnassignedLabel": "unassigned",
"taskCategoryAllLabel": "all",
"taskDueLabel": "Task due:",
Expand Down
10 changes: 8 additions & 2 deletions lib/widgets/app_bar/journal_sliver_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:lotti/themes/theme.dart';
import 'package:lotti/utils/modals.dart';
import 'package:lotti/widgets/search/entry_type_filter.dart';
import 'package:lotti/widgets/search/search_widget.dart';
import 'package:lotti/widgets/search/task_category_filter.dart';
import 'package:lotti/widgets/search/task_filter_icon.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

Expand Down Expand Up @@ -40,8 +41,10 @@ class JournalSliverAppBar extends StatelessWidget {
onChanged: cubit.setSearchString,
),
),
if (showTasks) const TaskFilterIcon(),
if (!showTasks) const JournalFilterIcon(),
if (showTasks)
const TaskFilterIcon()
else
const JournalFilterIcon(),
],
),
],
Expand Down Expand Up @@ -136,10 +139,13 @@ class JournalFilterIcon extends StatelessWidget {
);
},
builder: (_) => const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
JournalFilter(),
SizedBox(height: 10),
EntryTypeFilter(),
SizedBox(height: 10),
TaskCategoryFilter(),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: lotti
description: Achieve your goals and keep your data private with Lotti.
publish_to: 'none'
version: 0.9.560+2842
version: 0.9.561+2843

msix_config:
display_name: LottiApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import 'package:lotti/utils/consts.dart';
import 'package:mocktail/mocktail.dart';
import 'package:path_provider/path_provider.dart';

import '../../helpers/path_provider.dart';
import '../../mocks/mocks.dart';
import '../../test_data/test_data.dart';
import '../../widget_test_utils.dart';
import '../../../../helpers/path_provider.dart';
import '../../../../mocks/mocks.dart';
import '../../../../test_data/test_data.dart';
import '../../../../widget_test_utils.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import 'package:mocktail/mocktail.dart';
import 'package:path_provider/path_provider.dart';
import 'package:visibility_detector/visibility_detector.dart';

import '../../helpers/path_provider.dart';
import '../../mocks/mocks.dart';
import '../../test_data/test_data.dart';
import '../../utils/utils.dart';
import '../../widget_test_utils.dart';
import '../../../../helpers/path_provider.dart';
import '../../../../mocks/mocks.dart';
import '../../../../test_data/test_data.dart';
import '../../../../utils/utils.dart';
import '../../../../widget_test_utils.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import 'package:lotti/services/time_service.dart';
import 'package:lotti/services/vector_clock_service.dart';
import 'package:mocktail/mocktail.dart';

import '../../../mocks/mocks.dart';
import '../../../test_data/test_data.dart';
import '../../../widget_test_utils.dart';
import '../../../../../mocks/mocks.dart';
import '../../../../../test_data/test_data.dart';
import '../../../../../widget_test_utils.dart';

void main() {
group('EditorWidget', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import 'package:lotti/services/nav_service.dart';
import 'package:lotti/services/notification_service.dart';
import 'package:mocktail/mocktail.dart';

import '../../../mocks/mocks.dart';
import '../../../test_data/test_data.dart';
import '../../../widget_test_utils.dart';
import '../../../../../mocks/mocks.dart';
import '../../../../../test_data/test_data.dart';
import '../../../../../widget_test_utils.dart';

void main() {
group('DeleteIconWidget', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import 'package:lotti/services/editor_state_service.dart';
import 'package:lotti/services/tags_service.dart';
import 'package:mocktail/mocktail.dart';

import '../../../mocks/mocks.dart';
import '../../../test_data/test_data.dart';
import '../../../widget_test_utils.dart';
import '../../../../../mocks/mocks.dart';
import '../../../../../test_data/test_data.dart';
import '../../../../../widget_test_utils.dart';

void main() {
group('EntryDetailFooter', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import 'package:lotti/services/tags_service.dart';
import 'package:lotti/services/time_service.dart';
import 'package:mocktail/mocktail.dart';

import '../../../mocks/mocks.dart';
import '../../../test_data/test_data.dart';
import '../../../widget_test_utils.dart';
import '../../../../../mocks/mocks.dart';
import '../../../../../test_data/test_data.dart';
import '../../../../../widget_test_utils.dart';

void main() {
group('EntryDetailFooter', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import 'package:lotti/services/tags_service.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:mocktail/mocktail.dart';

import '../../../mocks/mocks.dart';
import '../../../test_data/test_data.dart';
import '../../../widget_test_utils.dart';
import '../../../../../mocks/mocks.dart';
import '../../../../../test_data/test_data.dart';
import '../../../../../widget_test_utils.dart';

void main() {
group('EntryDetailHeader', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import 'package:lotti/logic/health_import.dart';
import 'package:lotti/services/entities_cache_service.dart';
import 'package:mocktail/mocktail.dart';

import '../../../mocks/mocks.dart';
import '../../../test_data/test_data.dart';
import '../../../widget_test_utils.dart';
import '../../../../../mocks/mocks.dart';
import '../../../../../test_data/test_data.dart';
import '../../../../../widget_test_utils.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
import 'package:mocktail/mocktail.dart';
import 'package:path_provider/path_provider.dart';

import '../../../helpers/path_provider.dart';
import '../../../mocks/mocks.dart';
import '../../../test_data/test_data.dart';
import '../../../widget_test_utils.dart';
import '../../../../../helpers/path_provider.dart';
import '../../../../../mocks/mocks.dart';
import '../../../../../test_data/test_data.dart';
import '../../../../../widget_test_utils.dart';

void main() {
group('ShareButtonWidget', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'package:lotti/features/journal/ui/widgets/entry_details/survey_summary.d
import 'package:lotti/get_it.dart';
import 'package:mocktail/mocktail.dart';

import '../../../mocks/mocks.dart';
import '../../../widget_test_utils.dart';
import '../../../../../mocks/mocks.dart';
import '../../../../../widget_test_utils.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'package:lotti/get_it.dart';
import 'package:lotti/logic/health_import.dart';
import 'package:mocktail/mocktail.dart';

import '../../../mocks/mocks.dart';
import '../../../test_data/test_data.dart';
import '../../../widget_test_utils.dart';
import '../../../../../mocks/mocks.dart';
import '../../../../../test_data/test_data.dart';
import '../../../../../widget_test_utils.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ import 'package:lotti/features/speech/state/asr_service.dart';
import 'package:lotti/features/speech/state/player_cubit.dart';
import 'package:lotti/get_it.dart';
import 'package:lotti/services/db_notification.dart';
import 'package:lotti/services/entities_cache_service.dart';
import 'package:lotti/services/logging_service.dart';
import 'package:lotti/services/tags_service.dart';
import 'package:lotti/services/time_service.dart';
import 'package:mocktail/mocktail.dart';
import 'package:path_provider/path_provider.dart';

import '../../helpers/path_provider.dart';
import '../../mocks/mocks.dart';
import '../../test_data/test_data.dart';
import '../../utils/utils.dart';
import '../../widget_test_utils.dart';
import '../../../../helpers/path_provider.dart';
import '../../../../mocks/mocks.dart';
import '../../../../test_data/test_data.dart';
import '../../../../utils/utils.dart';
import '../../../../widget_test_utils.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand All @@ -41,6 +42,7 @@ void main() {

final mockTagsService = mockTagsServiceWithTags([]);
final mockTimeService = MockTimeService();
final mockEntitiesCacheService = MockEntitiesCacheService();

final mockUpdateNotifications = MockUpdateNotifications();
when(() => mockUpdateNotifications.updateStream).thenAnswer(
Expand All @@ -49,6 +51,7 @@ void main() {

getIt
..registerSingleton<Directory>(await getApplicationDocumentsDirectory())
..registerSingleton<EntitiesCacheService>(mockEntitiesCacheService)
..registerSingleton<UpdateNotifications>(mockUpdateNotifications)
..registerSingleton<LoggingDb>(MockLoggingDb())
..registerSingleton<LoggingService>(LoggingService())
Expand Down
Loading

0 comments on commit 890e6f2

Please sign in to comment.