loading state and error handling refactor
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
import 'package:async/async.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../api/errors/error_mapper.dart';
|
||||
import '../../../api/marianumcloud/autocomplete/autocompleteApi.dart';
|
||||
import '../../../api/marianumcloud/autocomplete/autocompleteResponse.dart';
|
||||
import '../../../model/endpoint_data.dart';
|
||||
import '../../../widget/app_progress_indicator.dart';
|
||||
import '../../../widget/placeholder_view.dart';
|
||||
|
||||
class JoinChat extends SearchDelegate<String> {
|
||||
@@ -16,17 +18,9 @@ class JoinChat extends SearchDelegate<String> {
|
||||
future: future!.value,
|
||||
builder: (context, snapshot) {
|
||||
if(snapshot.connectionState != ConnectionState.done) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: const Center(
|
||||
child: SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Center(child: AppProgressIndicator.medium()),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
@@ -76,10 +70,13 @@ class JoinChat extends SearchDelegate<String> {
|
||||
}
|
||||
);
|
||||
} else if(snapshot.hasError) {
|
||||
return const PlaceholderView(icon: Icons.search_off, text: 'Ein fehler ist aufgetreten. Bist du mit dem Internet verbunden?');
|
||||
return PlaceholderView(
|
||||
icon: Icons.search_off,
|
||||
text: errorToUserMessage(snapshot.error),
|
||||
);
|
||||
}
|
||||
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
return const Center(child: AppProgressIndicator.large());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user