mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-29 16:26:27 +00:00
63 lines
1.4 KiB
Dart
63 lines
1.4 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// User interface utilities
|
|
|
|
/// Build centered progress bar
|
|
Widget buildCenteredProgressBar() {
|
|
return Center(
|
|
child: CircularProgressIndicator(),
|
|
);
|
|
}
|
|
|
|
/// Build and return a full loading page
|
|
Widget buildLoadingPage() {
|
|
return Scaffold(
|
|
body: buildCenteredProgressBar(),
|
|
);
|
|
}
|
|
|
|
/// Build and return an error card
|
|
Widget buildErrorCard(String message, {List<Widget> actions}) {
|
|
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,
|
|
),
|
|
),
|
|
Row(
|
|
children: actions == null ? <Widget>[] : actions,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 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,
|
|
);
|
|
|
|
}));
|
|
}
|