1
1
import 'package:flutter/material.dart' ;
2
+ import 'package:flutter/services.dart' ;
2
3
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart' ;
3
4
4
5
import '../api/exception.dart' ;
5
6
import '../api/route/account.dart' ;
6
7
import '../api/route/realm.dart' ;
7
8
import '../api/route/users.dart' ;
9
+ import '../model/binding.dart' ;
8
10
import '../model/store.dart' ;
9
11
import 'app.dart' ;
10
12
import 'dialog.dart' ;
@@ -223,7 +225,13 @@ class _AddAccountPageState extends State<AddAccountPage> {
223
225
decoration: InputDecoration (
224
226
labelText: zulipLocalizations.loginServerUrlInputLabel,
225
227
errorText: errorText,
226
- helperText: kLayoutPinningHelperText,
228
+ helper: InkWell (
229
+ onTap: () {
230
+ _launchUrl (context);
231
+ },
232
+ child: Text (
233
+ zulipLocalizations.serverURLDocLinkLabel,
234
+ style: const TextStyle (color: Colors .blue))),
227
235
hintText: 'your-org.zulipchat.com' )),
228
236
const SizedBox (height: 8 ),
229
237
ElevatedButton (
@@ -235,6 +243,30 @@ class _AddAccountPageState extends State<AddAccountPage> {
235
243
}
236
244
}
237
245
246
+ void _launchUrl (BuildContext context) async {
247
+ String urlString = 'https://zulip.com/help/logging-in#find-the-zulip-log-in-url' ;
248
+ Future <void > showError (BuildContext context, String ? message) {
249
+ return showErrorDialog (context: context,
250
+ title: 'Unable to open link' ,
251
+ message: [
252
+ 'Link could not be opened: $urlString ' ,
253
+ if (message != null ) message,
254
+ ].join ("\n\n " ));
255
+ }
256
+
257
+ bool launched = false ;
258
+ String ? errorMessage;
259
+ try {
260
+ launched = await ZulipBinding .instance.launchUrl (Uri .parse (urlString));
261
+ } on PlatformException catch (e) {
262
+ errorMessage = e.message;
263
+ }
264
+ if (! launched) {
265
+ if (! context.mounted) return ;
266
+ await showError (context, errorMessage);
267
+ }
268
+ }
269
+
238
270
class PasswordLoginPage extends StatefulWidget {
239
271
const PasswordLoginPage ({super .key, required this .serverSettings});
240
272
0 commit comments