mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
parent
d35742d34c
commit
3bbba2eeb4
@ -1,7 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
|
||||||
|
|
||||||
import 'package:appflowy/plugins/document/application/document_data_pb_extension.dart';
|
import 'package:appflowy/plugins/document/application/document_data_pb_extension.dart';
|
||||||
import 'package:appflowy/plugins/document/presentation/editor_plugins/migration/editor_migration.dart';
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/migration/editor_migration.dart';
|
||||||
import 'package:appflowy/startup/startup.dart';
|
import 'package:appflowy/startup/startup.dart';
|
||||||
@ -16,6 +14,7 @@ import 'package:flowy_infra_ui/style_widget/container.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
|
|
||||||
typedef ImportCallback = void Function(
|
typedef ImportCallback = void Function(
|
||||||
@ -52,7 +51,7 @@ Future<void> showImportPanel(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImportPanel extends StatelessWidget {
|
class ImportPanel extends StatefulWidget {
|
||||||
const ImportPanel({
|
const ImportPanel({
|
||||||
super.key,
|
super.key,
|
||||||
required this.parentViewId,
|
required this.parentViewId,
|
||||||
@ -62,11 +61,33 @@ class ImportPanel extends StatelessWidget {
|
|||||||
final String parentViewId;
|
final String parentViewId;
|
||||||
final ImportCallback importCallback;
|
final ImportCallback importCallback;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ImportPanel> createState() => _ImportPanelState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ImportPanelState extends State<ImportPanel> {
|
||||||
|
final flowyContainerFocusNode = FocusNode();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
flowyContainerFocusNode.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final width = MediaQuery.of(context).size.width * 0.7;
|
final width = MediaQuery.of(context).size.width * 0.7;
|
||||||
final height = width * 0.5;
|
final height = width * 0.5;
|
||||||
return FlowyContainer(
|
return KeyboardListener(
|
||||||
|
autofocus: true,
|
||||||
|
focusNode: flowyContainerFocusNode,
|
||||||
|
onKeyEvent: (event) {
|
||||||
|
if (event is KeyDownEvent &&
|
||||||
|
event.physicalKey == PhysicalKeyboardKey.escape) {
|
||||||
|
FlowyOverlay.pop(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: FlowyContainer(
|
||||||
Theme.of(context).colorScheme.surface,
|
Theme.of(context).colorScheme.surface,
|
||||||
height: height,
|
height: height,
|
||||||
width: width,
|
width: width,
|
||||||
@ -87,7 +108,7 @@ class ImportPanel extends StatelessWidget {
|
|||||||
color: Theme.of(context).colorScheme.tertiary,
|
color: Theme.of(context).colorScheme.tertiary,
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await _importFile(parentViewId, e);
|
await _importFile(widget.parentViewId, e);
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
FlowyOverlay.pop(context);
|
FlowyOverlay.pop(context);
|
||||||
}
|
}
|
||||||
@ -97,6 +118,7 @@ class ImportPanel extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +182,7 @@ class ImportPanel extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
importCallback(importType, '', null);
|
widget.importCallback(importType, '', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user