chore: hide Log and PlatformExtension (#886)
This commit is contained in:
parent
14ea32a06c
commit
72512df842
7 changed files with 236 additions and 253 deletions
|
|
@ -20,6 +20,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:printing/printing.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
import 'package:universal_platform/universal_platform.dart';
|
||||
|
||||
enum ExportFileType {
|
||||
documentJson,
|
||||
|
|
@ -60,7 +61,7 @@ class _HomePageState extends State<HomePage> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_jsonString = PlatformExtension.isDesktopOrWeb
|
||||
_jsonString = UniversalPlatform.isDesktopOrWeb
|
||||
? rootBundle.loadString('assets/example.json')
|
||||
: rootBundle.loadString('assets/mobile_example.json');
|
||||
|
||||
|
|
@ -91,7 +92,7 @@ class _HomePageState extends State<HomePage> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
extendBodyBehindAppBar: PlatformExtension.isDesktopOrWeb,
|
||||
extendBodyBehindAppBar: UniversalPlatform.isDesktopOrWeb,
|
||||
drawer: _buildDrawer(context),
|
||||
appBar: AppBar(
|
||||
backgroundColor: const Color.fromARGB(255, 134, 46, 247),
|
||||
|
|
@ -123,7 +124,7 @@ class _HomePageState extends State<HomePage> {
|
|||
// AppFlowy Editor Demo
|
||||
_buildSeparator(context, 'AppFlowy Editor Demo'),
|
||||
_buildListTile(context, 'With Example.json', () {
|
||||
final jsonString = PlatformExtension.isDesktopOrWeb
|
||||
final jsonString = UniversalPlatform.isDesktopOrWeb
|
||||
? rootBundle.loadString('assets/example.json')
|
||||
: rootBundle.loadString('assets/mobile_example.json');
|
||||
_loadEditor(context, jsonString);
|
||||
|
|
@ -358,7 +359,7 @@ class _HomePageState extends State<HomePage> {
|
|||
)
|
||||
..setAttribute('download', 'document.${fileType.extension}')
|
||||
..click();
|
||||
} else if (PlatformExtension.isMobile) {
|
||||
} else if (UniversalPlatform.isMobile) {
|
||||
final appStorageDirectory = await getApplicationDocumentsDirectory();
|
||||
|
||||
final path = File(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:universal_platform/universal_platform.dart';
|
||||
|
||||
class CollabSelectionEditor extends StatefulWidget {
|
||||
const CollabSelectionEditor({super.key});
|
||||
|
|
@ -54,7 +55,7 @@ class _CollabSelectionEditorState extends State<CollabSelectionEditor> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
|
||||
future = PlatformExtension.isDesktopOrWeb
|
||||
future = UniversalPlatform.isDesktopOrWeb
|
||||
? rootBundle.loadString('assets/example.json')
|
||||
: rootBundle.loadString('assets/mobile_example.json').then((value) {
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:flutter/gestures.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:universal_platform/universal_platform.dart';
|
||||
|
||||
class CustomizeThemeForEditor extends StatefulWidget {
|
||||
const CustomizeThemeForEditor({super.key});
|
||||
|
|
@ -21,7 +22,7 @@ class _CustomizeThemeForEditorState extends State<CustomizeThemeForEditor> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
|
||||
final jsonString = PlatformExtension.isDesktopOrWeb
|
||||
final jsonString = UniversalPlatform.isDesktopOrWeb
|
||||
? rootBundle.loadString('assets/example.json')
|
||||
: rootBundle.loadString('assets/mobile_example.json');
|
||||
editorState = jsonString.then((value) {
|
||||
|
|
@ -152,7 +153,7 @@ class _CustomizeThemeForEditorState extends State<CustomizeThemeForEditor> {
|
|||
/// custom the text style
|
||||
EditorStyle customizeEditorStyle() {
|
||||
return EditorStyle(
|
||||
padding: PlatformExtension.isDesktopOrWeb
|
||||
padding: UniversalPlatform.isDesktopOrWeb
|
||||
? const EdgeInsets.only(left: 200, right: 200)
|
||||
: const EdgeInsets.symmetric(horizontal: 20),
|
||||
cursorColor: Colors.green,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ class _DesktopEditorState extends State<DesktopEditor> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(PlatformExtension.isDesktopOrWeb);
|
||||
return FloatingToolbar(
|
||||
items: [
|
||||
paragraphItem,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:example/pages/desktop_editor.dart';
|
||||
import 'package:example/pages/mobile_editor.dart';
|
||||
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:universal_platform/universal_platform.dart';
|
||||
|
||||
class Editor extends StatefulWidget {
|
||||
const Editor({
|
||||
|
|
@ -97,7 +96,7 @@ class _EditorState extends State<Editor> {
|
|||
|
||||
editorState.logConfiguration
|
||||
..handler = debugPrint
|
||||
..level = LogLevel.off;
|
||||
..level = AppFlowyEditorLogLevel.off;
|
||||
|
||||
editorState.transactionStream.listen((event) {
|
||||
if (event.$1 == TransactionTime.after) {
|
||||
|
|
@ -111,12 +110,12 @@ class _EditorState extends State<Editor> {
|
|||
registerWordCounter();
|
||||
}
|
||||
|
||||
if (PlatformExtension.isDesktopOrWeb) {
|
||||
if (UniversalPlatform.isDesktopOrWeb) {
|
||||
return DesktopEditor(
|
||||
editorState: editorState!,
|
||||
textDirection: widget.textDirection,
|
||||
);
|
||||
} else if (PlatformExtension.isMobile) {
|
||||
} else if (UniversalPlatform.isMobile) {
|
||||
return MobileEditor(editorState: editorState!);
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +133,7 @@ class _EditorState extends State<Editor> {
|
|||
color: Colors.black.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: const Radius.circular(8),
|
||||
bottomLeft: PlatformExtension.isMobile
|
||||
bottomLeft: UniversalPlatform.isMobile
|
||||
? const Radius.circular(8)
|
||||
: Radius.zero,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:universal_platform/universal_platform.dart';
|
||||
|
||||
class FocusExampleForEditor extends StatefulWidget {
|
||||
const FocusExampleForEditor({super.key});
|
||||
|
|
@ -18,7 +19,7 @@ class _FocusExampleForEditorState extends State<FocusExampleForEditor> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
|
||||
final jsonString = PlatformExtension.isDesktopOrWeb
|
||||
final jsonString = UniversalPlatform.isDesktopOrWeb
|
||||
? rootBundle.loadString('assets/example.json')
|
||||
: rootBundle.loadString('assets/mobile_example.json');
|
||||
editorState = jsonString.then((value) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ class _MobileEditorState extends State<MobileEditor> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(PlatformExtension.isMobile);
|
||||
return MobileToolbarV2(
|
||||
toolbarHeight: 48.0,
|
||||
toolbarItems: [
|
||||
|
|
|
|||
Loading…
Reference in a new issue