You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.7 KiB
87 lines
2.7 KiB
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
|
|
import 'package:flutter/foundation.dart' as foundation;
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import '../config/emoji_config.dart';
|
|
import '../generated/assets.dart';
|
|
|
|
/// 表情选择面板
|
|
class FontEmojiPanel extends StatefulWidget {
|
|
final Function(String emoji) onEmojiSelected;
|
|
final bool isVisible;
|
|
|
|
const FontEmojiPanel({
|
|
super.key,
|
|
required this.onEmojiSelected,
|
|
required this.isVisible,
|
|
});
|
|
|
|
@override
|
|
State<FontEmojiPanel> createState() => _FontEmojiPanelState();
|
|
}
|
|
|
|
class _FontEmojiPanelState extends State<FontEmojiPanel> {
|
|
|
|
|
|
|
|
final _controller = TextEditingController();
|
|
final _scrollController = ScrollController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (!widget.isVisible) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
|
|
final hasRecent = EmojiConfig.hasRecentEmojis();
|
|
final List<EmojiItem> recentEmojis = hasRecent ? EmojiConfig.getRecentEmojis() : [];
|
|
|
|
return AnimatedContainer(
|
|
duration: const Duration(milliseconds: 200),
|
|
height: widget.isVisible ? 320.h : 0,
|
|
color: Colors.white,
|
|
child: EmojiPicker(
|
|
onEmojiSelected: (Category? category, Emoji emoji) {
|
|
print(category);
|
|
print(emoji.emoji);
|
|
widget.onEmojiSelected(emoji.emoji);
|
|
setState(() {
|
|
|
|
});
|
|
},
|
|
onBackspacePressed: () {
|
|
// Do something when the user taps the backspace button (optional)
|
|
// Set it to null to hide the Backspace-Button
|
|
},
|
|
textEditingController: _controller,
|
|
scrollController: _scrollController,
|
|
config: Config(
|
|
locale: const Locale("zh"),
|
|
height: widget.isVisible ? 320.h : 0,
|
|
checkPlatformCompatibility: true,
|
|
viewOrderConfig: const ViewOrderConfig(),
|
|
emojiViewConfig: EmojiViewConfig(
|
|
// Issue: https://github.com/flutter/flutter/issues/28894
|
|
emojiSizeMax: 28 *
|
|
(foundation.defaultTargetPlatform ==
|
|
TargetPlatform.iOS
|
|
? 1.2
|
|
: 1.0),
|
|
noRecents: Text(
|
|
'暂无最近使用',
|
|
style: TextStyle(fontSize: 20, color: Colors.black26),
|
|
textAlign: TextAlign.center,
|
|
)
|
|
),
|
|
skinToneConfig: const SkinToneConfig(),
|
|
categoryViewConfig: const CategoryViewConfig(),
|
|
bottomActionBarConfig: const BottomActionBarConfig(
|
|
enabled: false
|
|
),
|
|
searchViewConfig: const SearchViewConfig(),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
}
|