Skip to content

Commit

Permalink
- add clear button (#10)
Browse files Browse the repository at this point in the history
- make text selectable
- remove copy content on long press

Co-authored-by: Kamil Kras <[email protected]>
  • Loading branch information
xVemu and Kamil Kras authored Jan 17, 2023
1 parent c15e8cb commit aa2c0c7
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 1 addition & 8 deletions lib/src/utils/ansi_parser.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
});
));
}
}
5 changes: 5 additions & 0 deletions lib/src/utils/log_console_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions lib/src/widgets/log_console_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ class LogConsoleAppBar extends StatelessWidget {
this.showCloseButton = true,
required this.onIncreaseFontSize,
required this.onDecreaseFontSize,
required this.onClearLogs,
required this.theme,
});

final bool showCloseButton;

final VoidCallback onDecreaseFontSize;
final VoidCallback onIncreaseFontSize;
final VoidCallback onClearLogs;
final LogConsoleTheme theme;

@override
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/log_console_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _LogConsoleContentState extends State<LogConsoleContent> {
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:
Expand Down
3 changes: 3 additions & 0 deletions lib/src/widgets/log_console_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class _LogConsoleWidgetState extends State<LogConsoleWidget> {
_logFontSize++;
});
},
onClearLogs: () {
widget.logConsoleManager.clearLogs();
}
),
Expanded(
child: LogConsoleContent(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit aa2c0c7

Please sign in to comment.