mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 03:17:00 +08:00
feat: refactor code highlighting and add scripts editor pane
- replace `flutter_highlighter` and `highlighter` with `flutter_highlight` and `highlight`. - add `flutter_code_editor` dependency. - introduce a new scripts editor pane in the REST request view.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'package:apidash_core/apidash_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:highlighter/highlighter.dart' show highlight, Node;
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:highlight/highlight.dart';
|
||||
import 'error_message.dart';
|
||||
|
||||
(String, bool) sanitize(String input) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:highlighter/highlighter.dart' show highlight;
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:apidash/utils/utils.dart';
|
||||
import 'package:highlight/highlight.dart';
|
||||
import 'button_copy.dart';
|
||||
import 'button_save_download.dart';
|
||||
import 'button_share.dart';
|
||||
|
||||
44
lib/widgets/scripts_editor_pane.dart
Normal file
44
lib/widgets/scripts_editor_pane.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:apidash/providers/settings_providers.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_code_editor/flutter_code_editor.dart';
|
||||
import 'package:flutter_highlight/themes/monokai.dart';
|
||||
import 'package:flutter_highlight/themes/xcode.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class ScriptsEditorPane extends ConsumerStatefulWidget {
|
||||
final CodeController controller;
|
||||
const ScriptsEditorPane({super.key, required this.controller});
|
||||
|
||||
@override
|
||||
ConsumerState<ScriptsEditorPane> createState() => _ScriptsEditorPaneState();
|
||||
}
|
||||
|
||||
class _ScriptsEditorPaneState extends ConsumerState<ScriptsEditorPane> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settings = ref.watch(settingsProvider);
|
||||
return CodeTheme(
|
||||
data: CodeThemeData(
|
||||
styles: settings.isDark ? monokaiTheme : xcodeTheme,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: CodeField(
|
||||
smartDashesType: SmartDashesType.enabled,
|
||||
smartQuotesType: SmartQuotesType.enabled,
|
||||
background: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||
gutterStyle: GutterStyle(
|
||||
width: 40, // TODO: Fix numbers size
|
||||
margin: 2,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
cursorColor: Theme.of(context).colorScheme.primary,
|
||||
controller: widget.controller,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: 'monospace',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user