fluffychat/lib/pages/views/homeserver_picker_view.dart

110 lines
3.6 KiB
Dart
Raw Normal View History

import '../homeserver_picker.dart';
2021-05-22 08:53:52 +02:00
import 'package:fluffychat/widgets/default_app_bar_search_field.dart';
import 'package:fluffychat/widgets/fluffy_banner.dart';
2021-04-09 16:29:48 +02:00
import 'package:fluffychat/config/app_config.dart';
2021-05-22 08:53:52 +02:00
import 'package:fluffychat/widgets/layouts/one_page_card.dart';
2021-04-09 16:28:26 +02:00
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
2021-05-22 09:13:47 +02:00
class HomeserverPickerView extends StatelessWidget {
2021-04-09 16:28:26 +02:00
final HomeserverPickerController controller;
2021-05-22 09:13:47 +02:00
const HomeserverPickerView(this.controller, {Key key}) : super(key: key);
2021-04-09 16:28:26 +02:00
@override
Widget build(BuildContext context) {
return OnePageCard(
child: Scaffold(
appBar: AppBar(
titleSpacing: 8,
title: DefaultAppBarSearchField(
prefixText: 'https://',
hintText: L10n.of(context).enterYourHomeserver,
searchController: controller.homeserverController,
suffix: Icon(Icons.edit_outlined),
padding: EdgeInsets.zero,
onChanged: (s) => controller.domain = s,
readOnly: !AppConfig.allowOtherHomeservers,
2021-05-01 07:40:12 +02:00
onSubmit: (_) => controller.checkHomeserverAction(),
unfocusOnClear: false,
2021-04-09 16:28:26 +02:00
),
elevation: 0,
),
body: SafeArea(
child: ListView(
children: [
Hero(
tag: 'loginBanner',
child: FluffyBanner(),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
AppConfig.applicationWelcomeMessage ??
L10n.of(context).welcomeText,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
),
),
),
],
),
),
bottomNavigationBar: Column(
mainAxisSize: MainAxisSize.min,
children: [
Hero(
tag: 'loginButton',
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 12),
child: ElevatedButton(
onPressed: controller.isLoading
? null
: controller.checkHomeserverAction,
child: controller.isLoading
? LinearProgressIndicator()
: Text(
2021-05-29 09:56:52 +02:00
L10n.of(context).connect,
2021-04-09 16:28:26 +02:00
style: TextStyle(color: Colors.white, fontSize: 16),
),
),
),
),
Wrap(
alignment: WrapAlignment.center,
children: [
TextButton(
onPressed: () => launch(AppConfig.privacyUrl),
child: Text(
L10n.of(context).privacy,
style: TextStyle(
decoration: TextDecoration.underline,
color: Colors.blueGrey,
),
),
),
TextButton(
onPressed: () => PlatformInfos.showDialog(context),
child: Text(
L10n.of(context).about,
style: TextStyle(
decoration: TextDecoration.underline,
color: Colors.blueGrey,
),
),
),
],
),
],
),
),
);
}
}