-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support custom image icon on mobile
- Loading branch information
Showing
21 changed files
with
204 additions
and
33 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
frontend/appflowy_flutter/integration_test/mobile/document/icon_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,65 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:appflowy/mobile/presentation/base/view_page/app_bar_buttons.dart'; | ||
import 'package:appflowy/mobile/presentation/presentation.dart'; | ||
import 'package:appflowy/plugins/document/presentation/editor_plugins/header/emoji_icon_widget.dart'; | ||
import 'package:appflowy/plugins/document/presentation/editor_plugins/page_style/_page_style_icon.dart'; | ||
import 'package:appflowy/shared/icon_emoji_picker/flowy_icon_emoji_picker.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:path/path.dart' as p; | ||
import 'package:path_provider/path_provider.dart'; | ||
|
||
import '../../shared/emoji.dart'; | ||
import '../../shared/util.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('document title:', () { | ||
testWidgets('update page custom icon in title bar', (tester) async { | ||
await tester.launchInAnonymousMode(); | ||
|
||
/// prepare local image | ||
final imagePath = await rootBundle.load('assets/test/images/sample.jpeg'); | ||
final tempDirectory = await getTemporaryDirectory(); | ||
final localImagePath = p.join(tempDirectory.path, 'sample.jpeg'); | ||
final imageFile = File(localImagePath) | ||
..writeAsBytesSync(imagePath.buffer.asUint8List()); | ||
final iconData = EmojiIconData.custom(imageFile.path); | ||
|
||
/// create an empty page | ||
await tester | ||
.tapButton(find.byKey(BottomNavigationBarItemType.add.valueKey)); | ||
|
||
/// show Page style page | ||
await tester.tapButton(find.byType(MobileViewPageLayoutButton)); | ||
final pageStyleIcon = find.byType(PageStyleIcon); | ||
final iconInPageStyleIcon = find.descendant( | ||
of: pageStyleIcon, | ||
matching: find.byType(RawEmojiIconWidget), | ||
); | ||
expect(iconInPageStyleIcon, findsNothing); | ||
|
||
/// show icon picker | ||
await tester.tapButton(pageStyleIcon); | ||
|
||
/// upload custom icon | ||
await tester.pickImage(iconData); | ||
|
||
/// check result | ||
final documentPage = find.byType(MobileDocumentScreen); | ||
final rawEmojiIconWidget = find | ||
.descendant( | ||
of: documentPage, | ||
matching: find.byType(RawEmojiIconWidget), | ||
) | ||
.evaluate() | ||
.first | ||
.widget as RawEmojiIconWidget; | ||
final iconDataInWidget = rawEmojiIconWidget.emoji; | ||
expect(iconDataInWidget.type, FlowyIconType.custom); | ||
}); | ||
}); | ||
} |
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
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
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
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
Oops, something went wrong.