Commit bb9dd258 authored by Wilko Manger's avatar Wilko Manger

Show all errors occuring while syncing

parent 672b89c4
......@@ -34,6 +34,8 @@ class ErrorBannerState extends State<ErrorBanner>
AnimationController _controller;
Animation<double> _animation;
var isConnectionError = false;
@override
void initState() {
super.initState();
......@@ -59,17 +61,49 @@ class ErrorBannerState extends State<ErrorBanner>
stream: syncBloc.stream,
builder: (BuildContext context, AsyncSnapshot<SyncState> snapshot) {
final state = snapshot.data;
if (state != null
&& !state.succeeded
&& (state.exception is http.ClientException
|| state.exception is SocketException)
) {
final hasSucceeded = state != null && state.succeeded;
if (!hasSucceeded) {
_controller.forward();
} else if (state != null
&& state.succeeded) {
} else {
_controller.animateBack(0);
}
Widget icon = Icon(Icons.cloud_off);
Widget text = Text(l(context).connectionLost);
if (state != null &&
(state.exception is SocketException
|| state.exception is http.ClientException)) {
isConnectionError = true;
} else if (state != null) {
isConnectionError = false;
}
if (state != null && !isConnectionError) {
// TODO: Make error messages less complex for end users,
// but keep it like this for now (before 1.0).
icon = Icon(Icons.bug_report);
text = RichText(
text: TextSpan(
style: DefaultTextStyle.of(context).style,
children: [
TextSpan(
text: '${l(context).anErrorHasOccurred}\n'
),
TextSpan(
text: state.exception.toString(),
style: TextStyle(
fontFamily: 'monospace',
fontWeight: FontWeight.bold
)
),
TextSpan(text: '\n${l(context).thisErrorHasBeenReported}')
]
)
);
}
return SizeTransition(
sizeFactor: _animation,
child: Container(
......@@ -87,11 +121,11 @@ class ErrorBannerState extends State<ErrorBanner>
child: Row(
children: <Widget>[
CircleAvatar(
child: Icon(Icons.cloud_off),
child: icon,
),
SizedBox(width: 16),
Flexible(
child: Text(l(context).connectionLost)
child: text
)
],
),
......
......@@ -52,6 +52,10 @@ class Strings {
'Connection failed. '
'Check your internet connection';
final anErrorHasOccurred = 'An error has occurred:';
final thisErrorHasBeenReported
= 'This error has been reported. Please restart Pattle.';
final youDeletedThisMessage = 'You deleted this message';
List<TextSpan> hasDeletedThisMessage(TextSpan name)
=> [name, TextSpan(text: ' deleted this message')];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment