mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 13:05:11 +00:00
feat: Add registration buttons for servers with public registration url
This commit is contained in:
parent
04a96237fd
commit
4a6a77336c
1 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
import 'package:fluffychat/widgets/layouts/login_scaffold.dart';
|
import 'package:fluffychat/widgets/layouts/login_scaffold.dart';
|
||||||
|
@ -19,6 +21,12 @@ class HomeserverPickerView extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final identityProviders = controller.identityProviders;
|
final identityProviders = controller.identityProviders;
|
||||||
final errorText = controller.error;
|
final errorText = controller.error;
|
||||||
|
final publicHomeserver = controller.cachedHomeservers?.singleWhereOrNull(
|
||||||
|
(homeserver) =>
|
||||||
|
homeserver.name ==
|
||||||
|
controller.homeserverController.text.trim().toLowerCase(),
|
||||||
|
);
|
||||||
|
final regLink = publicHomeserver?.regLink;
|
||||||
return LoginScaffold(
|
return LoginScaffold(
|
||||||
enforceMobileMode: Matrix.of(context).client.isLogged(),
|
enforceMobileMode: Matrix.of(context).client.isLogged(),
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
@ -132,6 +140,12 @@ class HomeserverPickerView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
if (regLink != null)
|
||||||
|
_LoginButton(
|
||||||
|
onPressed: () => launchUrlString(regLink),
|
||||||
|
icon: const Icon(Icons.open_in_new),
|
||||||
|
label: L10n.of(context)!.register,
|
||||||
|
),
|
||||||
if (controller.supportsPasswordLogin)
|
if (controller.supportsPasswordLogin)
|
||||||
_LoginButton(
|
_LoginButton(
|
||||||
onPressed: controller.login,
|
onPressed: controller.login,
|
||||||
|
|
Loading…
Reference in a new issue