-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
babylonia_terminal_launcher/lib/models/error_reporter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_highlight/flutter_highlight.dart'; | ||
import 'package:flutter_highlight/themes/vs.dart'; | ||
import 'package:flutter_highlight/themes/vs2015.dart'; | ||
import 'package:yaru/icons.dart'; | ||
import 'package:yaru/widgets.dart'; | ||
|
||
import './../messages/error.pb.dart'; | ||
|
||
class ErrorReporter { | ||
static Future listenAllRustError( | ||
GlobalKey<NavigatorState> navigatorState) async { | ||
final stream = ReportError.rustSignalStream; | ||
await for (final rustSignal in stream) { | ||
final context = navigatorState.currentState!.overlay!.context; | ||
await showDialog<void>( | ||
context: context, | ||
builder: (context) => AlertDialog( | ||
titlePadding: EdgeInsets.zero, | ||
title: YaruDialogTitleBar( | ||
title: const Text('Error'), | ||
isClosable: true, | ||
leading: Center( | ||
child: YaruIconButton( | ||
icon: const Icon(YaruIcons.copy), | ||
tooltip: 'Copy', | ||
onPressed: () async { | ||
Clipboard.setData( | ||
ClipboardData(text: rustSignal.message.errorMessage), | ||
); | ||
}, | ||
), | ||
), | ||
), | ||
contentPadding: EdgeInsets.zero, | ||
content: SizedBox( | ||
height: 400, | ||
width: 700, | ||
child: HighlightView( | ||
rustSignal.message.errorMessage, | ||
language: '', | ||
theme: Theme.of(context).brightness == Brightness.dark | ||
? vs2015Theme | ||
: vsTheme, | ||
padding: const EdgeInsets.all(12), | ||
textStyle: const TextStyle( | ||
fontSize: 16, | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
syntax = "proto3"; | ||
package error; | ||
|
||
// [RINF:RUST-SIGNAL] | ||
message ReportError { | ||
string errorMessage = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters