forked from AppFlowy-IO/AppFlowy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
710 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
frontend/appflowy_flutter/integration_test/emoji_shortcut_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'dart:io'; | ||
import 'package:appflowy/workspace/presentation/settings/widgets/emoji_picker/emoji_picker.dart'; | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
import 'package:appflowy_editor/src/editor/editor_component/service/editor.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
|
||
import 'util/keyboard.dart'; | ||
import 'util/util.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
// May be better to move this to an existing test but unsure what it fits with | ||
group('Keyboard shortcuts related to emojis', () { | ||
testWidgets('cmd/ctrl+alt+e shortcut opens the emoji picker', | ||
(tester) async { | ||
await tester.initializeAppFlowy(); | ||
await tester.tapGoButton(); | ||
|
||
final Finder editor = find.byType(AppFlowyEditor); | ||
await tester.tap(editor); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.byType(EmojiSelectionMenu), findsNothing); | ||
|
||
await FlowyTestKeyboard.simulateKeyDownEvent( | ||
[ | ||
Platform.isMacOS | ||
? LogicalKeyboardKey.meta | ||
: LogicalKeyboardKey.control, | ||
LogicalKeyboardKey.alt, | ||
LogicalKeyboardKey.keyE, | ||
], | ||
tester: tester, | ||
); | ||
|
||
expect(find.byType(EmojiSelectionMenu), findsOneWidget); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...flowy_flutter/lib/plugins/database/grid/application/filter/number_filter_editor_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:appflowy/plugins/database/application/filter/filter_listener.dart'; | ||
import 'package:appflowy/plugins/database/application/filter/filter_service.dart'; | ||
import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/filter_info.dart'; | ||
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'number_filter_editor_bloc.freezed.dart'; | ||
|
||
class NumberFilterEditorBloc | ||
extends Bloc<NumberFilterEditorEvent, NumberFilterEditorState> { | ||
NumberFilterEditorBloc({required this.filterInfo}) | ||
: _filterBackendSvc = FilterBackendService(viewId: filterInfo.viewId), | ||
_listener = FilterListener( | ||
viewId: filterInfo.viewId, | ||
filterId: filterInfo.filter.id, | ||
), | ||
super(NumberFilterEditorState.initial(filterInfo)) { | ||
_dispatch(); | ||
_startListening(); | ||
} | ||
|
||
final FilterInfo filterInfo; | ||
final FilterBackendService _filterBackendSvc; | ||
final FilterListener _listener; | ||
|
||
void _dispatch() { | ||
on<NumberFilterEditorEvent>( | ||
(event, emit) async { | ||
event.when( | ||
didReceiveFilter: (filter) { | ||
final filterInfo = state.filterInfo.copyWith(filter: filter); | ||
emit( | ||
state.copyWith( | ||
filterInfo: filterInfo, | ||
filter: filterInfo.numberFilter()!, | ||
), | ||
); | ||
}, | ||
updateCondition: (NumberFilterConditionPB condition) { | ||
_filterBackendSvc.insertNumberFilter( | ||
filterId: filterInfo.filter.id, | ||
fieldId: filterInfo.fieldInfo.id, | ||
condition: condition, | ||
content: state.filter.content, | ||
); | ||
}, | ||
updateContent: (content) { | ||
_filterBackendSvc.insertNumberFilter( | ||
filterId: filterInfo.filter.id, | ||
fieldId: filterInfo.fieldInfo.id, | ||
condition: state.filter.condition, | ||
content: content, | ||
); | ||
}, | ||
delete: () { | ||
_filterBackendSvc.deleteFilter( | ||
fieldId: filterInfo.fieldInfo.id, | ||
filterId: filterInfo.filter.id, | ||
fieldType: filterInfo.fieldInfo.fieldType, | ||
); | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
|
||
void _startListening() { | ||
_listener.start( | ||
onDeleted: () { | ||
if (!isClosed) { | ||
add(const NumberFilterEditorEvent.delete()); | ||
} | ||
}, | ||
onUpdated: (filter) { | ||
if (!isClosed) { | ||
add(NumberFilterEditorEvent.didReceiveFilter(filter)); | ||
} | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
Future<void> close() async { | ||
await _listener.stop(); | ||
return super.close(); | ||
} | ||
} | ||
|
||
@freezed | ||
class NumberFilterEditorEvent with _$NumberFilterEditorEvent { | ||
const factory NumberFilterEditorEvent.didReceiveFilter(FilterPB filter) = | ||
_DidReceiveFilter; | ||
const factory NumberFilterEditorEvent.updateCondition( | ||
NumberFilterConditionPB condition, | ||
) = _UpdateCondition; | ||
const factory NumberFilterEditorEvent.updateContent(String content) = | ||
_UpdateContent; | ||
const factory NumberFilterEditorEvent.delete() = _Delete; | ||
} | ||
|
||
@freezed | ||
class NumberFilterEditorState with _$NumberFilterEditorState { | ||
const factory NumberFilterEditorState({ | ||
required FilterInfo filterInfo, | ||
required NumberFilterPB filter, | ||
}) = _NumberFilterEditorState; | ||
|
||
factory NumberFilterEditorState.initial(FilterInfo filterInfo) { | ||
return NumberFilterEditorState( | ||
filterInfo: filterInfo, | ||
filter: filterInfo.numberFilter()!, | ||
); | ||
} | ||
} |
Oops, something went wrong.