mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Add user profile route
This commit is contained in:
		@@ -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(
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								lib/ui/widgets/copy_icon.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lib/ui/widgets/copy_icon.dart
									
									
									
									
									
										Normal 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}));
 | 
			
		||||
      },
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user