mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-01-12 02:32:54 +01:00
chore: Redesign homepicker page
This commit is contained in:
parent
1d6c9cf5c6
commit
e402a020f6
@ -7,6 +7,7 @@ class DefaultAppBarSearchField extends StatefulWidget {
|
|||||||
final bool autofocus;
|
final bool autofocus;
|
||||||
final String prefixText;
|
final String prefixText;
|
||||||
final String hintText;
|
final String hintText;
|
||||||
|
final EdgeInsets padding;
|
||||||
|
|
||||||
const DefaultAppBarSearchField({
|
const DefaultAppBarSearchField({
|
||||||
Key key,
|
Key key,
|
||||||
@ -16,6 +17,7 @@ class DefaultAppBarSearchField extends StatefulWidget {
|
|||||||
this.autofocus = false,
|
this.autofocus = false,
|
||||||
this.prefixText,
|
this.prefixText,
|
||||||
this.hintText,
|
this.hintText,
|
||||||
|
this.padding,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -59,7 +61,7 @@ class _DefaultAppBarSearchFieldState extends State<DefaultAppBarSearchField> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
height: 40,
|
height: 40,
|
||||||
padding: EdgeInsets.only(right: 12),
|
padding: widget.padding ?? EdgeInsets.only(right: 12),
|
||||||
child: Material(
|
child: Material(
|
||||||
color: Theme.of(context).secondaryHeaderColor,
|
color: Theme.of(context).secondaryHeaderColor,
|
||||||
borderRadius: BorderRadius.circular(32),
|
borderRadius: BorderRadius.circular(32),
|
||||||
|
@ -3,6 +3,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
|
||||||
class SentrySwitchListTile extends StatefulWidget {
|
class SentrySwitchListTile extends StatefulWidget {
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
const SentrySwitchListTile({Key key, this.label}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_SentrySwitchListTileState createState() => _SentrySwitchListTileState();
|
_SentrySwitchListTileState createState() => _SentrySwitchListTileState();
|
||||||
}
|
}
|
||||||
@ -17,7 +21,7 @@ class _SentrySwitchListTileState extends State<SentrySwitchListTile> {
|
|||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
_enabled = snapshot.data ?? false;
|
_enabled = snapshot.data ?? false;
|
||||||
return SwitchListTile(
|
return SwitchListTile(
|
||||||
title: Text(L10n.of(context).sendBugReports),
|
title: Text(widget.label ?? L10n.of(context).sendBugReports),
|
||||||
value: _enabled,
|
value: _enabled,
|
||||||
onChanged: (b) =>
|
onChanged: (b) =>
|
||||||
SentryController.toggleSentryAction(context, b).then(
|
SentryController.toggleSentryAction(context, b).then(
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fluffychat/components/sentry_switch_list_tile.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info/package_info.dart';
|
||||||
@ -51,8 +52,9 @@ abstract class PlatformInfos {
|
|||||||
child: Text(AppConfig.emojiFontName),
|
child: Text(AppConfig.emojiFontName),
|
||||||
onPressed: () => launch(AppConfig.emojiFontUrl),
|
onPressed: () => launch(AppConfig.emojiFontUrl),
|
||||||
),
|
),
|
||||||
|
SentrySwitchListTile(label: L10n.of(context).sendBugReports),
|
||||||
],
|
],
|
||||||
applicationIcon: Image.asset('assets/logo.png', width: 100, height: 100),
|
applicationIcon: Image.asset('assets/logo.png', width: 64, height: 64),
|
||||||
applicationName: AppConfig.applicationName,
|
applicationName: AppConfig.applicationName,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
|
||||||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:fluffychat/components/default_app_bar_search_field.dart';
|
||||||
import 'package:fluffychat/components/matrix.dart';
|
import 'package:fluffychat/components/matrix.dart';
|
||||||
import 'package:fluffychat/app_config.dart';
|
import 'package:fluffychat/app_config.dart';
|
||||||
import 'package:fluffychat/components/sentry_switch_list_tile.dart';
|
|
||||||
import 'package:fluffychat/utils/platform_infos.dart';
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
import 'package:flushbar/flushbar_helper.dart';
|
import 'package:flushbar/flushbar_helper.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
@ -20,17 +19,19 @@ class HomeserverPicker extends StatefulWidget {
|
|||||||
class _HomeserverPickerState extends State<HomeserverPicker> {
|
class _HomeserverPickerState extends State<HomeserverPicker> {
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
String _domain = AppConfig.defaultHomeserver;
|
String _domain = AppConfig.defaultHomeserver;
|
||||||
|
final TextEditingController _controller =
|
||||||
|
TextEditingController(text: AppConfig.defaultHomeserver);
|
||||||
|
|
||||||
void _checkHomeserverAction(BuildContext context) async {
|
void _checkHomeserverAction(BuildContext context) async {
|
||||||
var homeserver = _domain;
|
|
||||||
|
|
||||||
if (!homeserver.startsWith('https://')) {
|
|
||||||
homeserver = 'https://$homeserver';
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() => _isLoading = true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (_domain.isEmpty) throw L10n.of(context).changeTheHomeserver;
|
||||||
|
var homeserver = _domain;
|
||||||
|
|
||||||
|
if (!homeserver.startsWith('https://')) {
|
||||||
|
homeserver = 'https://$homeserver';
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() => _isLoading = true);
|
||||||
await Matrix.of(context).client.checkHomeserver(homeserver);
|
await Matrix.of(context).client.checkHomeserver(homeserver);
|
||||||
final loginTypes = await Matrix.of(context).client.requestLoginTypes();
|
final loginTypes = await Matrix.of(context).client.requestLoginTypes();
|
||||||
if (loginTypes.flows
|
if (loginTypes.flows
|
||||||
@ -41,10 +42,12 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
|||||||
.any((flow) => flow.type == AuthenticationTypes.sso)) {
|
.any((flow) => flow.type == AuthenticationTypes.sso)) {
|
||||||
await AdaptivePageLayout.of(context).pushNamed('/sso');
|
await AdaptivePageLayout.of(context).pushNamed('/sso');
|
||||||
}
|
}
|
||||||
|
} on String catch (e) {
|
||||||
|
// ignore: unawaited_futures
|
||||||
|
FlushbarHelper.createError(message: e).show(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore: unawaited_futures
|
// ignore: unawaited_futures
|
||||||
FlushbarHelper.createError(
|
FlushbarHelper.createError(
|
||||||
title: L10n.of(context).noConnectionToTheServer,
|
|
||||||
message: (e as Object).toLocalizedString(context))
|
message: (e as Object).toLocalizedString(context))
|
||||||
.show(context);
|
.show(context);
|
||||||
} finally {
|
} finally {
|
||||||
@ -54,29 +57,23 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _changeHomeserverAction(BuildContext context) async {
|
|
||||||
final input = await showTextInputDialog(
|
|
||||||
context: context,
|
|
||||||
title: L10n.of(context).changeTheHomeserver,
|
|
||||||
textFields: [
|
|
||||||
DialogTextField(
|
|
||||||
keyboardType: TextInputType.url,
|
|
||||||
prefixText: 'https://',
|
|
||||||
hintText: AppConfig.defaultHomeserver,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
if (input?.single?.isNotEmpty ?? false) {
|
|
||||||
setState(() => _domain = input.single);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final padding = EdgeInsets.symmetric(
|
final padding = EdgeInsets.symmetric(
|
||||||
horizontal: max((MediaQuery.of(context).size.width - 600) / 2, 0),
|
horizontal: max((MediaQuery.of(context).size.width - 600) / 2, 0),
|
||||||
);
|
);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: DefaultAppBarSearchField(
|
||||||
|
prefixText: 'https://',
|
||||||
|
hintText: L10n.of(context).enterYourHomeserver,
|
||||||
|
searchController: _controller,
|
||||||
|
suffix: Icon(Icons.edit_outlined),
|
||||||
|
padding: padding,
|
||||||
|
onChanged: (s) => _domain = s,
|
||||||
|
),
|
||||||
|
elevation: 0,
|
||||||
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: padding,
|
padding: padding,
|
||||||
@ -97,63 +94,6 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: Material(
|
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
elevation: 2,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
SizedBox(height: 8),
|
|
||||||
Text(
|
|
||||||
L10n.of(context).youWillBeConnectedTo(_domain),
|
|
||||||
style: TextStyle(fontSize: 16),
|
|
||||||
),
|
|
||||||
FlatButton(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: Text(
|
|
||||||
L10n.of(context).changeTheHomeserver,
|
|
||||||
style: TextStyle(
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.blue,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () => _changeHomeserverAction(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Wrap(
|
|
||||||
alignment: WrapAlignment.center,
|
|
||||||
children: [
|
|
||||||
FlatButton(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: Text(
|
|
||||||
L10n.of(context).privacy,
|
|
||||||
style: TextStyle(
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
color: Colors.blueGrey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () => PlatformInfos.showDialog(context),
|
|
||||||
),
|
|
||||||
FlatButton(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: Text(
|
|
||||||
L10n.of(context).about,
|
|
||||||
style: TextStyle(
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
color: Colors.blueGrey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () => PlatformInfos.showDialog(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -186,7 +126,33 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SentrySwitchListTile(),
|
Wrap(
|
||||||
|
alignment: WrapAlignment.center,
|
||||||
|
children: [
|
||||||
|
FlatButton(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
child: Text(
|
||||||
|
L10n.of(context).privacy,
|
||||||
|
style: TextStyle(
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
color: Colors.blueGrey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () => PlatformInfos.showDialog(context),
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
child: Text(
|
||||||
|
L10n.of(context).about,
|
||||||
|
style: TextStyle(
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
color: Colors.blueGrey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () => PlatformInfos.showDialog(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user