Skip to content

Commit ff277e7

Browse files
login: Link to doc for what "server URL" is and how to find it
1 parent 68116a2 commit ff277e7

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

assets/l10n/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@
289289
"@loginServerUrlInputLabel": {
290290
"description": "Input label in login page for Zulip server URL entry."
291291
},
292+
"serverURLDocLinkLabel": "(What's this?)",
293+
"@serverURLDocLinkLabel": {
294+
"description": "Link to doc to help users understand what a server URL is and how to find theirs."
295+
},
292296
"loginHidePassword": "Hide password",
293297
"@loginHidePassword": {
294298
"description": "Icon label for button to hide password in input form."

lib/widgets/login.dart

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter/services.dart';
23
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';
34

45
import '../api/exception.dart';
56
import '../api/route/account.dart';
67
import '../api/route/realm.dart';
78
import '../api/route/users.dart';
9+
import '../model/binding.dart';
810
import '../model/store.dart';
911
import 'app.dart';
1012
import 'dialog.dart';
@@ -223,7 +225,13 @@ class _AddAccountPageState extends State<AddAccountPage> {
223225
decoration: InputDecoration(
224226
labelText: zulipLocalizations.loginServerUrlInputLabel,
225227
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))),
227235
hintText: 'your-org.zulipchat.com')),
228236
const SizedBox(height: 8),
229237
ElevatedButton(
@@ -235,6 +243,30 @@ class _AddAccountPageState extends State<AddAccountPage> {
235243
}
236244
}
237245

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+
238270
class PasswordLoginPage extends StatefulWidget {
239271
const PasswordLoginPage({super.key, required this.serverSettings});
240272

0 commit comments

Comments
 (0)