mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-26 18:56:38 +00:00
update
This commit is contained in:
parent
78e5e11f0d
commit
c7d45fbf76
|
@ -36,7 +36,7 @@ class ConsoleInterceptor extends InterceptorsWrapper {
|
|||
addMessage(
|
||||
Message(
|
||||
text:
|
||||
'response-uri: ${response.request.uri}\ncode: ${response.statusCode}\ndata: ${response.data.toString()}\n',
|
||||
'response-uri: ${response.request.uri}\ncode: ${response.statusCode}\ndata: ${response.toString()}\n',
|
||||
),
|
||||
);
|
||||
return super.onResponse(response);
|
||||
|
@ -44,6 +44,14 @@ class ConsoleInterceptor extends InterceptorsWrapper {
|
|||
|
||||
@override
|
||||
Future onError(DioError err) async {
|
||||
var response = err.response;
|
||||
|
||||
addMessage(
|
||||
Message.warn(
|
||||
text:
|
||||
'response-uri: ${response?.request?.uri}\ncode: ${response?.statusCode}\ndata: ${response?.toString()}\n',
|
||||
),
|
||||
);
|
||||
return super.onError(err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,20 @@ import 'package:intl/intl.dart';
|
|||
final formater = new DateFormat('hh:mm');
|
||||
|
||||
class Message {
|
||||
Message({
|
||||
this.text,
|
||||
}) : time = DateTime.now();
|
||||
Message({this.text, this.type = MessageType.normal}) : time = DateTime.now();
|
||||
|
||||
final String text;
|
||||
final DateTime time;
|
||||
|
||||
final MessageType type;
|
||||
String get timeString => formater.format(time);
|
||||
|
||||
static Message warn({String text}) => Message(
|
||||
text: text,
|
||||
type: MessageType.warning,
|
||||
);
|
||||
}
|
||||
|
||||
enum MessageType {
|
||||
normal,
|
||||
warning,
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import 'dart:collection';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:selfprivacy/config/brand_colors.dart';
|
||||
import 'package:selfprivacy/config/get_it_config.dart';
|
||||
import 'package:selfprivacy/logic/get_it/console.dart';
|
||||
import 'package:selfprivacy/logic/models/message.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
||||
|
||||
|
@ -54,21 +56,27 @@ class _ConsoleState extends State<Console> {
|
|||
children: [
|
||||
SizedBox(height: 20),
|
||||
...UnmodifiableListView(messages
|
||||
.map((message) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: '${message.timeString}: ',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold)),
|
||||
TextSpan(text: message.text),
|
||||
],
|
||||
),
|
||||
.map((message) {
|
||||
var isError = message.type == MessageType.warning;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text:
|
||||
'${message.timeString}${isError ? '(Error)' : ''}: \n',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color:
|
||||
isError ? BrandColors.red1 : null)),
|
||||
TextSpan(text: message.text),
|
||||
],
|
||||
),
|
||||
))
|
||||
),
|
||||
);
|
||||
})
|
||||
.toList()
|
||||
.reversed),
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue