feat: Redesign start page

This commit is contained in:
Krille Fear 2021-11-15 09:48:21 +01:00
parent 7c3fffc8a6
commit 7167d0ace6
8 changed files with 117 additions and 85 deletions

View File

@ -1277,7 +1277,7 @@
"homeserver": {} "homeserver": {}
} }
}, },
"loginWith": "Anmelden mit {brand}", "loginWith": "Anmelden mit",
"@loginWith": { "@loginWith": {
"type": "text", "type": "text",
"placeholders": { "placeholders": {

View File

@ -1309,13 +1309,7 @@
"homeserver": {} "homeserver": {}
} }
}, },
"loginWith": "Sign in with {brand}", "loginWithOneClick": "Sign in with one click",
"@loginWith": {
"type": "text",
"placeholders": {
"brand": {}
}
},
"logout": "Logout", "logout": "Logout",
"@logout": { "@logout": {
"type": "text", "type": "text",

View File

@ -97,15 +97,17 @@ abstract class FluffyThemes {
), ),
inputDecorationTheme: InputDecorationTheme( inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius)), borderRadius: BorderRadius.circular(AppConfig.borderRadius),
),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius), borderRadius: BorderRadius.circular(AppConfig.borderRadius),
borderSide: BorderSide( borderSide: BorderSide(
color: lighten(AppConfig.chatColor, .51), color: lighten(AppConfig.chatColor, .51),
width: 1,
), ),
), ),
filled: true, filled: true,
fillColor: lighten(AppConfig.chatColor, .51), fillColor: Colors.blueGrey.shade50,
), ),
appBarTheme: const AppBarTheme( appBarTheme: const AppBarTheme(
elevation: 6, elevation: 6,
@ -171,7 +173,7 @@ abstract class FluffyThemes {
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius)), borderRadius: BorderRadius.circular(AppConfig.borderRadius)),
filled: true, filled: true,
fillColor: FluffyThemes.darken(AppConfig.chatColor, 0.4), fillColor: Colors.blueGrey.shade900,
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius), borderRadius: BorderRadius.circular(AppConfig.borderRadius),
borderSide: BorderSide( borderSide: BorderSide(

View File

@ -40,7 +40,8 @@ class HomeserverPickerController extends State<HomeserverPicker> {
this.domain = domain; this.domain = domain;
_coolDown?.cancel(); _coolDown?.cancel();
if (domain.isNotEmpty) { if (domain.isNotEmpty) {
_coolDown = Timer(const Duration(seconds: 1), checkHomeserverAction); _coolDown =
Timer(const Duration(milliseconds: 500), checkHomeserverAction);
} }
} }

View File

@ -11,7 +11,6 @@ import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/default_app_bar_search_field.dart'; import 'package:fluffychat/widgets/default_app_bar_search_field.dart';
import 'package:fluffychat/widgets/fluffy_banner.dart';
import 'package:fluffychat/widgets/layouts/one_page_card.dart'; import 'package:fluffychat/widgets/layouts/one_page_card.dart';
import 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/matrix.dart';
import '../../utils/localized_exception_extension.dart'; import '../../utils/localized_exception_extension.dart';
@ -44,9 +43,10 @@ class HomeserverPickerView extends StatelessWidget {
elevation: 0, elevation: 0,
), ),
body: ListView(children: [ body: ListView(children: [
const Hero( Image.asset(
tag: 'loginBanner', Theme.of(context).brightness == Brightness.dark
child: FluffyBanner(), ? 'assets/banner_dark.png'
: 'assets/banner.png',
), ),
controller.isLoading controller.isLoading
? const Center( ? const Center(
@ -88,35 +88,34 @@ class HomeserverPickerView extends StatelessWidget {
), ),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch, children: [
if (controller.ssoLoginSupported)
Row(children: [
const Expanded(child: Divider()),
Padding(
padding: const EdgeInsets.all(12.0),
child: Text(
L10n.of(context).loginWithOneClick),
),
const Expanded(child: Divider()),
]),
Wrap(
children: [ children: [
if (controller.ssoLoginSupported) ...{ if (controller.ssoLoginSupported) ...{
for (final identityProvider for (final identityProvider
in controller.identityProviders) in controller.identityProviders)
Center( _SsoButton(
child: _LoginButton( onPressed: () =>
onPressed: () => controller controller.ssoLoginAction(
.ssoLoginAction(identityProvider.id), identityProvider.id),
icon: identityProvider.icon == null identityProvider: identityProvider,
? const Icon(Icons.web_outlined)
: CachedNetworkImage(
imageUrl: Uri.parse(
identityProvider.icon)
.getDownloadLink(
Matrix.of(context)
.getLoginClient())
.toString(),
width: 24,
height: 24,
), ),
labelText: L10n.of(context).loginWith( },
identityProvider.name ?? ].toList(),
identityProvider.brand ??
L10n.of(context).singlesignon),
), ),
), if (controller.ssoLoginSupported &&
if (controller.registrationSupported || (controller.registrationSupported ||
controller.passwordLoginSupported) controller.passwordLoginSupported))
Row(children: [ Row(children: [
const Expanded(child: Divider()), const Expanded(child: Divider()),
Padding( Padding(
@ -125,8 +124,7 @@ class HomeserverPickerView extends StatelessWidget {
), ),
const Expanded(child: Divider()), const Expanded(child: Divider()),
]), ]),
}, if (controller.passwordLoginSupported) ...[
if (controller.passwordLoginSupported)
Center( Center(
child: _LoginButton( child: _LoginButton(
onPressed: () => onPressed: () =>
@ -141,6 +139,8 @@ class HomeserverPickerView extends StatelessWidget {
labelText: L10n.of(context).login, labelText: L10n.of(context).login,
), ),
), ),
const SizedBox(height: 12),
],
if (controller.registrationSupported) if (controller.registrationSupported)
Center( Center(
child: _LoginButton( child: _LoginButton(
@ -155,19 +155,15 @@ class HomeserverPickerView extends StatelessWidget {
labelText: L10n.of(context).register, labelText: L10n.of(context).register,
), ),
), ),
] ],
.map(
(widget) => Container(
height: 64,
padding:
const EdgeInsets.only(bottom: 12),
child: widget),
)
.toList(),
), ),
); );
}), }),
Wrap( ]),
bottomNavigationBar: Material(
elevation: 6,
color: Theme.of(context).scaffoldBackgroundColor,
child: Wrap(
alignment: WrapAlignment.center, alignment: WrapAlignment.center,
children: [ children: [
TextButton( TextButton(
@ -192,7 +188,54 @@ class HomeserverPickerView extends StatelessWidget {
), ),
], ],
), ),
]), ),
),
);
}
}
class _SsoButton extends StatelessWidget {
final IdentityProvider identityProvider;
final void Function() onPressed;
const _SsoButton({
Key key,
@required this.identityProvider,
this.onPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onPressed,
borderRadius: BorderRadius.circular(7),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
identityProvider.icon == null
? const Icon(Icons.web_outlined)
: CachedNetworkImage(
imageUrl: Uri.parse(identityProvider.icon)
.getDownloadLink(Matrix.of(context).getLoginClient())
.toString(),
width: 32,
height: 32,
),
const SizedBox(height: 8),
Text(
identityProvider.name ??
identityProvider.brand ??
L10n.of(context).singlesignon,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Theme.of(context).textTheme.subtitle2.color,
),
),
],
),
), ),
); );
} }
@ -216,7 +259,9 @@ class _LoginButton extends StatelessWidget {
minimumSize: const Size(256, 56), minimumSize: const Size(256, 56),
textStyle: const TextStyle(fontWeight: FontWeight.bold), textStyle: const TextStyle(fontWeight: FontWeight.bold),
backgroundColor: Theme.of(context).backgroundColor, backgroundColor: Theme.of(context).backgroundColor,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)), shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
),
), ),
onPressed: onPressed, onPressed: onPressed,
icon: icon, icon: icon,

View File

@ -80,7 +80,7 @@ abstract class ClientManager {
legacyDatabaseBuilder: FlutterMatrixHiveStore.hiveDatabaseBuilder, legacyDatabaseBuilder: FlutterMatrixHiveStore.hiveDatabaseBuilder,
supportedLoginTypes: { supportedLoginTypes: {
AuthenticationTypes.password, AuthenticationTypes.password,
if (PlatformInfos.isMobile || PlatformInfos.isWeb) //if (PlatformInfos.isMobile || PlatformInfos.isWeb)
AuthenticationTypes.sso AuthenticationTypes.sso
}, },
compute: compute, compute: compute,

View File

@ -1,12 +0,0 @@
import 'package:flutter/material.dart';
class FluffyBanner extends StatelessWidget {
const FluffyBanner({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Image.asset(Theme.of(context).brightness == Brightness.dark
? 'assets/banner_dark.png'
: 'assets/banner.png');
}
}

View File

@ -14,6 +14,8 @@ class OnePageCard extends StatelessWidget {
static num breakpoint = FluffyThemes.columnWidth * 2; static num breakpoint = FluffyThemes.columnWidth * 2;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final horizontalPadding =
max((MediaQuery.of(context).size.width - 600) / 2, 24);
return MediaQuery.of(context).size.width <= breakpoint || return MediaQuery.of(context).size.width <= breakpoint ||
Matrix.of(context).client.isLogged() Matrix.of(context).client.isLogged()
? child ? child
@ -25,13 +27,13 @@ class OnePageCard extends StatelessWidget {
), ),
), ),
child: Padding( child: Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.only(
horizontal: top: 16,
max((MediaQuery.of(context).size.width - 600) / 2, 24), left: horizontalPadding,
vertical: right: horizontalPadding,
max((MediaQuery.of(context).size.height - 800) / 2, 24), bottom: max((MediaQuery.of(context).size.height - 600) / 2, 24),
), ),
child: SafeArea(child: Card(elevation: 5, child: child)), child: SafeArea(child: Card(elevation: 16, child: child)),
), ),
); );
} }