Skip to content

Commit 97cb29c

Browse files
committed
feat: add emojis without downloading 8.92MB font by using twemoji
1 parent 32a7a3f commit 97cb29c

File tree

6 files changed

+75
-2
lines changed

6 files changed

+75
-2
lines changed

client/lib/src/annotation/pages/annotate_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:banananator/src/annotation/bounding_box_widget.dart';
88
import 'package:banananator/src/annotation/pages/missing_data_page.dart';
99
import 'package:banananator/src/routes.dart';
1010
import 'package:banananator/src/utilities/error_alert_dialog.dart';
11+
import 'package:banananator/src/widgets/app_bar_title.dart';
1112
import 'package:flutter/material.dart';
1213
import 'package:get_it/get_it.dart';
1314
import 'package:go_router/go_router.dart';
@@ -181,7 +182,7 @@ class _AnnotatePageState extends State<AnnotatePage> {
181182

182183
return Scaffold(
183184
appBar: AppBar(
184-
title: const Text("Banananator"),
185+
title: const AppBarTitle(),
185186
leading: IconButton(
186187
icon: const Icon(Icons.arrow_circle_left_outlined),
187188
onPressed: () => context.go(Routes.root),

client/lib/src/home/home_page.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import 'package:banananator/src/home/annotations_jobs_sliver.dart';
1010
import 'package:banananator/src/routes.dart';
1111
import 'package:banananator/src/utilities/error_alert_dialog.dart';
1212
import 'package:banananator/src/home/annotations_sliver.dart';
13+
import 'package:banananator/src/widgets/app_bar_title.dart';
1314
import 'package:file_picker/file_picker.dart';
1415
import 'package:flutter/material.dart';
1516
import 'package:flutter_hooks/flutter_hooks.dart';
1617
import 'package:get_it/get_it.dart';
1718
import 'package:go_router/go_router.dart';
19+
import 'package:twemoji/twemoji.dart';
1820

1921
class HomePage extends HookWidget {
2022
HomePage({super.key});
@@ -124,7 +126,7 @@ class HomePage extends HookWidget {
124126

125127
return Scaffold(
126128
appBar: AppBar(
127-
title: const Text("Banananator"),
129+
title: const AppBarTitle(),
128130
actions: [
129131
IconButton(icon: const Icon(Icons.refresh), onPressed: fetchData),
130132
IconButton(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:twemoji/twemoji.dart';
3+
4+
class AppBarTitle extends StatelessWidget {
5+
const AppBarTitle({super.key});
6+
7+
@override
8+
Widget build(BuildContext context) {
9+
return RichText(
10+
text: TwemojiTextSpan(
11+
text: 'Banananator 🍌📸',
12+
style: Theme.of(context).textTheme.headline6!.apply(color: Colors.white),
13+
),
14+
);
15+
}
16+
17+
}

client/pubspec.lock

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ packages:
221221
url: "https://pub.dartlang.org"
222222
source: hosted
223223
version: "2.0.7"
224+
flutter_svg:
225+
dependency: transitive
226+
description:
227+
name: flutter_svg
228+
url: "https://pub.dartlang.org"
229+
source: hosted
230+
version: "1.1.6"
224231
flutter_test:
225232
dependency: "direct dev"
226233
description: flutter
@@ -413,6 +420,20 @@ packages:
413420
url: "https://pub.dartlang.org"
414421
source: hosted
415422
version: "1.8.2"
423+
path_drawing:
424+
dependency: transitive
425+
description:
426+
name: path_drawing
427+
url: "https://pub.dartlang.org"
428+
source: hosted
429+
version: "1.0.1"
430+
path_parsing:
431+
dependency: transitive
432+
description:
433+
name: path_parsing
434+
url: "https://pub.dartlang.org"
435+
source: hosted
436+
version: "1.0.1"
416437
path_provider:
417438
dependency: "direct main"
418439
description:
@@ -462,6 +483,13 @@ packages:
462483
url: "https://pub.dartlang.org"
463484
source: hosted
464485
version: "2.1.3"
486+
petitparser:
487+
dependency: transitive
488+
description:
489+
name: petitparser
490+
url: "https://pub.dartlang.org"
491+
source: hosted
492+
version: "5.1.0"
465493
platform:
466494
dependency: transitive
467495
description:
@@ -607,6 +635,13 @@ packages:
607635
url: "https://pub.dartlang.org"
608636
source: hosted
609637
version: "1.0.0"
638+
twemoji:
639+
dependency: "direct main"
640+
description:
641+
name: twemoji
642+
url: "https://pub.dartlang.org"
643+
source: hosted
644+
version: "0.4.3"
610645
typed_data:
611646
dependency: transitive
612647
description:
@@ -670,6 +705,13 @@ packages:
670705
url: "https://pub.dartlang.org"
671706
source: hosted
672707
version: "0.2.0+2"
708+
xml:
709+
dependency: transitive
710+
description:
711+
name: xml
712+
url: "https://pub.dartlang.org"
713+
source: hosted
714+
version: "6.1.0"
673715
yaml:
674716
dependency: transitive
675717
description:

client/pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies:
3131
uuid: ^3.0.7
3232
file_picker: ^5.2.3
3333
window_manager: ^0.2.8
34+
twemoji: ^0.4.3
3435

3536
# For internet checks
3637
collection: ^1.0.0
@@ -51,3 +52,6 @@ flutter:
5152
assets:
5253
# Add assets from the images directory to the application.
5354
- assets/images/fruit-basket.jpg
55+
56+
twemoji:
57+
includes: '🍌📸'

client/scripts/codegen.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@
33
set -euxo pipefail
44

55
flutter pub run build_runner build --delete-conflicting-outputs
6+
# This errors with:
7+
#Unhandled exception:
8+
#FileSystemException: Directory listing failed, path = '/Users/zen/repos/banananator/client/.dart_tool/pub/bin/assets/' (OS Error: No such file or directory, errno = 2)
9+
#Instance of '_StringStackTrace'pub finished with exit code 255
10+
# Fixing this will bundle the emojis from `twemoji.includes` in `pubspec.yaml` instead
11+
# of downloading them
12+
#flutter pub run twemoji:include_emojis

0 commit comments

Comments
 (0)