1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-30 00:36:28 +00:00
comunicmobile/lib/utils/ui_utils.dart

68 lines
1.6 KiB
Dart
Raw Normal View History

2019-04-26 09:34:24 +00:00
import 'package:cached_network_image/cached_network_image.dart';
2019-04-22 17:16:26 +00:00
import 'package:flutter/material.dart';
/// User interface utilities
2019-04-23 06:46:50 +00:00
/// Build centered progress bar
Widget buildCenteredProgressBar() {
return Center(
child: CircularProgressIndicator(),
);
}
2019-04-22 17:16:26 +00:00
/// Build and return a full loading page
Widget buildLoadingPage() {
return Scaffold(
2019-04-23 06:46:50 +00:00
body: buildCenteredProgressBar(),
2019-04-22 17:16:26 +00:00
);
}
/// Build and return an error card
2019-04-23 12:35:41 +00:00
Widget buildErrorCard(String message, {List<Widget> actions}) {
2019-04-22 17:16:26 +00:00
return Card(
elevation: 2.0,
color: Colors.red,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Icon(
Icons.error,
color: Colors.white,
),
),
Flexible(
child: Text(
message,
style: TextStyle(color: Colors.white),
maxLines: null,
),
2019-04-23 12:35:41 +00:00
),
Row(
children: actions == null ? <Widget>[] : actions,
2019-04-22 17:16:26 +00:00
)
],
),
),
);
}
2019-04-26 09:34:24 +00:00
/// Show an image with a given [url] in full screen
void showImageFullScreen(BuildContext context, String url) {
Navigator.of(context).push(MaterialPageRoute(builder: (c) {
// TODO : add better support later
return CachedNetworkImage(
imageUrl: url,
);
}));
}
/// Show simple snack
void showSimpleSnack(BuildContext context, String message) {
Scaffold.of(context).showSnackBar(SnackBar(content: Text(message)));
}