diff --git a/CHANGELOG.md b/CHANGELOG.md index e67a2ee..27e5fe0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.0.5 +- add clear button +- make text selectable +- remove copy content on long press +## 1.0.4 +- add copy content on long press ## 1.0.3 - fixed theme ## 1.0.2 diff --git a/lib/src/utils/ansi_parser.dart b/lib/src/utils/ansi_parser.dart index bac028d..abb64e7 100644 --- a/lib/src/utils/ansi_parser.dart +++ b/lib/src/utils/ansi_parser.dart @@ -1,6 +1,4 @@ -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; class AnsiParser { static const TEXT = 0, BRACKET = 1, CODE = 2; @@ -123,11 +121,6 @@ class AnsiParser { style: TextStyle( color: foreground, backgroundColor: background, - ), - recognizer: LongPressGestureRecognizer() - ..onLongPress = () { - Clipboard.setData(ClipboardData(text: text)); - // Toast.toast("Copy to paste board"); - }); + )); } } diff --git a/lib/src/utils/log_console_manager.dart b/lib/src/utils/log_console_manager.dart index aa3803a..4365f85 100644 --- a/lib/src/utils/log_console_manager.dart +++ b/lib/src/utils/log_console_manager.dart @@ -35,6 +35,11 @@ class LogConsoleManager extends ChangeNotifier { notifyListeners(); } + void clearLogs() { + _buffer.clear(); + notifyListeners(); + } + void addLog(OutputEvent event) { final text = event.lines.join('\n'); _ansiParser.parse(text); diff --git a/lib/src/widgets/log_console_app_bar.dart b/lib/src/widgets/log_console_app_bar.dart index 0f367f4..5184ddc 100644 --- a/lib/src/widgets/log_console_app_bar.dart +++ b/lib/src/widgets/log_console_app_bar.dart @@ -7,6 +7,7 @@ class LogConsoleAppBar extends StatelessWidget { this.showCloseButton = true, required this.onIncreaseFontSize, required this.onDecreaseFontSize, + required this.onClearLogs, required this.theme, }); @@ -14,6 +15,7 @@ class LogConsoleAppBar extends StatelessWidget { final VoidCallback onDecreaseFontSize; final VoidCallback onIncreaseFontSize; + final VoidCallback onClearLogs; final LogConsoleTheme theme; @override @@ -41,6 +43,10 @@ class LogConsoleAppBar extends StatelessWidget { icon: Icon(Icons.remove), onPressed: onDecreaseFontSize, ), + IconButton( + icon: Icon(Icons.clear_all), + onPressed: onClearLogs, + ), if (showCloseButton) IconButton( icon: Icon(Icons.close), diff --git a/lib/src/widgets/log_console_content.dart b/lib/src/widgets/log_console_content.dart index 62bfc46..104b133 100644 --- a/lib/src/widgets/log_console_content.dart +++ b/lib/src/widgets/log_console_content.dart @@ -52,7 +52,7 @@ class _LogConsoleContentState extends State { child: ListView.builder( key: PageStorageKey('LogConsoleContent'), controller: widget.scrollController, - itemBuilder: (context, index) => Text.rich( + itemBuilder: (context, index) => SelectableText.rich( widget.logConsoleManager.logs[index].span, key: ValueKey(widget.logConsoleManager.logs[index].id), style: diff --git a/lib/src/widgets/log_console_widget.dart b/lib/src/widgets/log_console_widget.dart index 4d23598..d9ba12c 100644 --- a/lib/src/widgets/log_console_widget.dart +++ b/lib/src/widgets/log_console_widget.dart @@ -84,6 +84,9 @@ class _LogConsoleWidgetState extends State { _logFontSize++; }); }, + onClearLogs: () { + widget.logConsoleManager.clearLogs(); + } ), Expanded( child: LogConsoleContent( diff --git a/pubspec.yaml b/pubspec.yaml index f6d635e..11c5e75 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: logger_flutter_plus description: Flutter extension for logger. Please go there for documentation. -version: 1.0.4 +version: 1.0.5 homepage: https://github.com/Oliinyk-Volodymyr/logger_flutter_plus