Lucas.Xu 412f34c72a
feat: add ... button in mobile toolbar (#3970)
* feat: add ... button in mobile toolbar

* fix: the title state should be reset when canceling

* fix: reset hover status after picking emoji

* fix: some emojis missing on linux and android

* fix: unable to press enter key to rename page
2023-11-22 10:49:22 +08:00

43 lines
1.1 KiB
Dart

import 'dart:io';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
// used to prevent loading font from google fonts every time
List<String>? _cachedFallbackFontFamily;
// Some emojis are not supported by the default font on Android or Linux, fallback to noto color emoji
class EmojiText extends StatelessWidget {
const EmojiText({
super.key,
required this.emoji,
required this.fontSize,
this.textAlign,
});
final String emoji;
final double fontSize;
final TextAlign? textAlign;
@override
Widget build(BuildContext context) {
_loadFallbackFontFamily();
return FlowyText(
emoji,
fontSize: fontSize,
textAlign: textAlign,
fallbackFontFamily: _cachedFallbackFontFamily,
);
}
void _loadFallbackFontFamily() {
if (Platform.isLinux || Platform.isAndroid) {
final notoColorEmoji = GoogleFonts.notoColorEmoji().fontFamily;
if (notoColorEmoji != null) {
_cachedFallbackFontFamily = [notoColorEmoji];
}
}
}
}