1
1
import 'package:flutter/material.dart' ;
2
2
import 'package:flutter/services.dart' ;
3
+ import 'package:flutter_gen/gen_l10n/zulip_localizations.dart' ;
3
4
import 'package:share_plus/share_plus.dart' ;
4
5
5
6
import '../api/exception.dart' ;
@@ -43,18 +44,19 @@ abstract class MessageActionSheetMenuItemButton extends StatelessWidget {
43
44
}) : assert (messageListContext.findAncestorWidgetOfExactType <MessageListPage >() != null );
44
45
45
46
IconData get icon;
46
- String get label;
47
+ String label ( ZulipLocalizations zulipLocalizations) ;
47
48
void Function (BuildContext ) get onPressed;
48
49
49
50
final Message message;
50
51
final BuildContext messageListContext;
51
52
52
53
@override
53
54
Widget build (BuildContext context) {
55
+ final zulipLocalizations = ZulipLocalizations .of (context);
54
56
return MenuItemButton (
55
57
leadingIcon: Icon (icon),
56
58
onPressed: () => onPressed (context),
57
- child: Text (label));
59
+ child: Text (label (zulipLocalizations) ));
58
60
}
59
61
}
60
62
@@ -67,7 +69,10 @@ class ShareButton extends MessageActionSheetMenuItemButton {
67
69
68
70
@override get icon => Icons .adaptive.share;
69
71
70
- @override get label => 'Share' ;
72
+ @override
73
+ String label (ZulipLocalizations zulipLocalizations) {
74
+ return zulipLocalizations.actionSheetOptionShare;
75
+ }
71
76
72
77
@override get onPressed => (BuildContext context) async {
73
78
// Close the message action sheet; we're about to show the share
@@ -104,13 +109,14 @@ Future<String?> fetchRawContentWithFeedback({
104
109
// - If request(s) take(s) a long time, show snackbar with cancel
105
110
// button, like "Still working on quote-and-reply…".
106
111
// On final failure or success, auto-dismiss the snackbar.
112
+ final zulipLocalizations = ZulipLocalizations .of (context);
107
113
try {
108
114
fetchedMessage = await getMessageCompat (PerAccountStoreWidget .of (context).connection,
109
115
messageId: messageId,
110
116
applyMarkdown: false ,
111
117
);
112
118
if (fetchedMessage == null ) {
113
- errorMessage = 'That message does not seem to exist.' ;
119
+ errorMessage = zulipLocalizations.errorMessageDoesNotSeemToExist ;
114
120
}
115
121
} catch (e) {
116
122
switch (e) {
@@ -119,7 +125,7 @@ Future<String?> fetchRawContentWithFeedback({
119
125
// TODO specific messages for common errors, like network errors
120
126
// (support with reusable code)
121
127
default :
122
- errorMessage = 'Could not fetch message source.' ;
128
+ errorMessage = zulipLocalizations.errorCouldNotFetchMessageSource ;
123
129
}
124
130
}
125
131
@@ -146,12 +152,16 @@ class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
146
152
147
153
@override get icon => Icons .format_quote_outlined;
148
154
149
- @override get label => 'Quote and reply' ;
155
+ @override
156
+ String label (ZulipLocalizations zulipLocalizations) {
157
+ return zulipLocalizations.actionSheetOptionQuoteAndReply;
158
+ }
150
159
151
160
@override get onPressed => (BuildContext bottomSheetContext) async {
152
161
// Close the message action sheet. We'll show the request progress
153
162
// in the compose-box content input with a "[Quoting…]" placeholder.
154
163
Navigator .of (bottomSheetContext).pop ();
164
+ final zulipLocalizations = ZulipLocalizations .of (messageListContext);
155
165
156
166
// This will be null only if the compose box disappeared after the
157
167
// message action sheet opened, and before "Quote and reply" was pressed.
@@ -174,7 +184,7 @@ class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
174
184
final rawContent = await fetchRawContentWithFeedback (
175
185
context: messageListContext,
176
186
messageId: message.id,
177
- errorDialogTitle: 'Quotation failed' ,
187
+ errorDialogTitle: zulipLocalizations.errorQuotationFailed ,
178
188
);
179
189
180
190
if (! messageListContext.mounted) return ;
@@ -203,26 +213,30 @@ class CopyButton extends MessageActionSheetMenuItemButton {
203
213
204
214
@override get icon => Icons .copy;
205
215
206
- @override get label => 'Copy message text' ;
216
+ @override
217
+ String label (ZulipLocalizations zulipLocalizations) {
218
+ return zulipLocalizations.actionSheetOptionCopy;
219
+ }
207
220
208
221
@override get onPressed => (BuildContext context) async {
209
222
// Close the message action sheet. We won't be showing request progress,
210
223
// but hopefully it won't take long at all, and
211
224
// fetchRawContentWithFeedback has a TODO for giving feedback if it does.
212
225
Navigator .of (context).pop ();
226
+ final zulipLocalizations = ZulipLocalizations .of (messageListContext);
213
227
214
228
final rawContent = await fetchRawContentWithFeedback (
215
229
context: messageListContext,
216
230
messageId: message.id,
217
- errorDialogTitle: 'Copying failed' ,
231
+ errorDialogTitle: zulipLocalizations.errorCopyingFailed ,
218
232
);
219
233
220
234
if (rawContent == null ) return ;
221
235
222
236
if (! messageListContext.mounted) return ;
223
237
224
- // TODO(i18n)
225
- copyWithPopup (context : context, successContent: const Text ('Message copied' ),
238
+ copyWithPopup (context : context,
239
+ successContent: Text (zulipLocalizations.successMessageCopied ),
226
240
data: ClipboardData (text: rawContent));
227
241
};
228
242
}
0 commit comments