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