mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Can update a conversation message
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// User interface utilities
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
/// Build centered progress bar
|
||||
Widget buildCenteredProgressBar() {
|
||||
@ -52,17 +55,66 @@ Widget buildErrorCard(String message, {List<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,
|
||||
);
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
/// Show simple snack
|
||||
void showSimpleSnack(BuildContext context, String message) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
}
|
||||
|
||||
/// Show an alert dialog to ask the user to enter a string
|
||||
Future<String> askUserString({
|
||||
@required BuildContext context,
|
||||
@required String title,
|
||||
@required String message,
|
||||
@required String defaultValue,
|
||||
@required String hint,
|
||||
}) async {
|
||||
assert(context != null);
|
||||
assert(title != null);
|
||||
assert(message != null);
|
||||
assert(defaultValue != null);
|
||||
assert(hint != null);
|
||||
|
||||
TextEditingController controller = TextEditingController(text: defaultValue);
|
||||
|
||||
final confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (c) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: Column(
|
||||
children: <Widget>[
|
||||
Text(message),
|
||||
TextField(
|
||||
controller: controller,
|
||||
maxLines: null,
|
||||
maxLength: 200,
|
||||
keyboardType: TextInputType.text,
|
||||
decoration: InputDecoration(
|
||||
labelText: hint,
|
||||
alignLabelWithHint: true,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(tr("Cancel").toUpperCase()),
|
||||
onPressed: () => Navigator.pop(c, false),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(tr("OK")),
|
||||
onPressed: () => Navigator.pop(c, true),
|
||||
),
|
||||
],
|
||||
));
|
||||
|
||||
if (confirm == null || !confirm) return null;
|
||||
|
||||
return controller.text;
|
||||
}
|
||||
|
Reference in New Issue
Block a user