1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Add user profile route

This commit is contained in:
2021-04-26 09:33:54 +02:00
parent 5ab21bd63e
commit f92846cb76
8 changed files with 278 additions and 39 deletions

View File

@ -28,12 +28,24 @@ class AsyncScreenWidget extends StatefulWidget {
/// Specify whether old data can be kept or not while updating this widget
final bool showOldDataWhileUpdating;
/// Widget to use while we are refreshing
///
/// This widget is optional
final Widget loadingWidget;
/// Widget to use in case of error
///
/// This widget is optional
final Widget errorWidget;
const AsyncScreenWidget({
Key key,
@required this.onReload,
@required this.onBuild,
@required this.errorMessage,
this.showOldDataWhileUpdating = false,
this.loadingWidget,
this.errorWidget,
}) : assert(onReload != null),
assert(onBuild != null),
assert(errorMessage != null),
@ -59,16 +71,17 @@ class AsyncScreenWidgetState extends SafeState<AsyncScreenWidget> {
Widget build(BuildContext context) {
// In case of error
if (error)
return buildErrorCard(widget.errorMessage, actions: [
MaterialButton(
textColor: Colors.white,
onPressed: () => refresh(),
child: Text(tr("Try again").toUpperCase()),
)
]);
return widget.errorWidget ??
buildErrorCard(widget.errorMessage, actions: [
MaterialButton(
textColor: Colors.white,
onPressed: () => refresh(),
child: Text(tr("Try again").toUpperCase()),
)
]);
// Show loading states
if (!ready) return buildCenteredProgressBar();
if (!ready) return widget.loadingWidget ?? buildCenteredProgressBar();
// The widget is ready, show it
return RefreshIndicator(

View File

@ -0,0 +1,25 @@
import 'package:clipboard/clipboard.dart';
import 'package:comunic/utils/intl_utils.dart';
import 'package:comunic/utils/ui_utils.dart';
import 'package:flutter/material.dart';
/// Icon used to copy content in clipboard
///
/// @author Pierre Hubert
class CopyIcon extends StatelessWidget {
final String value;
const CopyIcon(this.value) : assert(value != null);
@override
Widget build(BuildContext context) {
return IconButton(
icon: Icon(Icons.content_copy),
onPressed: () {
FlutterClipboard.copy(value);
snack(context, tr("'%c%' was copied to clipboard", args: {"c": value}));
},
);
}
}