feat(app): 集成贴纸选择到编辑器 — 底部面板 + 自动放置
This commit is contained in:
@@ -24,6 +24,7 @@ import '../widgets/draggable_element.dart';
|
|||||||
import '../widgets/editor_toolbar.dart';
|
import '../widgets/editor_toolbar.dart';
|
||||||
import '../widgets/text_input_overlay.dart';
|
import '../widgets/text_input_overlay.dart';
|
||||||
import '../widgets/image_picker_handler.dart';
|
import '../widgets/image_picker_handler.dart';
|
||||||
|
import '../widgets/sticker_picker_sheet.dart';
|
||||||
|
|
||||||
/// 手账编辑器页面
|
/// 手账编辑器页面
|
||||||
class EditorPage extends StatelessWidget {
|
class EditorPage extends StatelessWidget {
|
||||||
@@ -269,6 +270,46 @@ class _EditorStack extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _EditorStackState extends State<_EditorStack> {
|
class _EditorStackState extends State<_EditorStack> {
|
||||||
|
EditorTool? _lastTool;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant _EditorStack oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
final currentTool = widget.state.activeTool;
|
||||||
|
|
||||||
|
// 贴纸工具刚被激活时弹出底部面板(防止重复弹窗)
|
||||||
|
if (currentTool == EditorTool.sticker && _lastTool != EditorTool.sticker) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) _showStickerPicker();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_lastTool = currentTool;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 显示贴纸选择底部面板
|
||||||
|
void _showStickerPicker() {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (_) => StickerPickerSheet(
|
||||||
|
onStickerSelected: (emoji) {
|
||||||
|
final center = Offset(
|
||||||
|
MediaQuery.of(context).size.width / 2 - 24,
|
||||||
|
MediaQuery.of(context).size.height / 3,
|
||||||
|
);
|
||||||
|
context.read<EditorBloc>().add(ElementAdded(
|
||||||
|
JournalElement.createSticker(
|
||||||
|
journalId: widget.journalId ?? '',
|
||||||
|
emoji: emoji,
|
||||||
|
position: center,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
context.read<EditorBloc>().add(ToolChanged(EditorTool.select));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final state = widget.state;
|
final state = widget.state;
|
||||||
|
|||||||
Reference in New Issue
Block a user