fluffychat/lib/widgets/layouts/login_scaffold.dart

148 lines
4.4 KiB
Dart
Raw Permalink Normal View History

2023-12-25 17:36:04 +00:00
import 'dart:ui';
2022-04-15 09:42:59 +00:00
import 'package:flutter/material.dart';
2022-10-16 10:37:38 +00:00
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:url_launcher/url_launcher_string.dart';
2022-10-16 10:37:38 +00:00
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/utils/platform_infos.dart';
2022-04-15 09:42:59 +00:00
class LoginScaffold extends StatelessWidget {
final Widget body;
final AppBar? appBar;
2023-09-22 06:26:43 +00:00
final bool enforceMobileMode;
2022-04-15 09:42:59 +00:00
const LoginScaffold({
super.key,
2022-04-15 09:42:59 +00:00
required this.body,
this.appBar,
2023-09-22 06:26:43 +00:00
this.enforceMobileMode = false,
});
2022-04-15 09:42:59 +00:00
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
2023-09-22 06:26:43 +00:00
final isMobileMode =
enforceMobileMode || !FluffyThemes.isColumnMode(context);
2022-11-04 10:17:22 +00:00
final scaffold = Scaffold(
key: const Key('LoginScaffold'),
2022-11-04 10:17:22 +00:00
appBar: appBar == null
? null
: AppBar(
titleSpacing: appBar?.titleSpacing,
automaticallyImplyLeading:
appBar?.automaticallyImplyLeading ?? true,
centerTitle: appBar?.centerTitle,
title: appBar?.title,
leading: appBar?.leading,
actions: appBar?.actions,
backgroundColor: isMobileMode ? null : Colors.transparent,
),
2024-08-28 06:43:21 +00:00
body: SafeArea(child: body),
backgroundColor:
isMobileMode ? null : theme.colorScheme.surface.withOpacity(0.8),
bottomNavigationBar: isMobileMode
? Material(
2023-07-23 05:42:27 +00:00
elevation: 4,
shadowColor: theme.colorScheme.onSurface,
2024-08-28 06:43:21 +00:00
child: const SafeArea(
child: _PrivacyButtons(
mainAxisAlignment: MainAxisAlignment.center,
),
),
)
: null,
2022-11-04 10:17:22 +00:00
);
if (isMobileMode) return scaffold;
2022-10-16 10:37:38 +00:00
return Container(
2023-12-24 12:46:29 +00:00
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('assets/login_wallpaper.png'),
),
),
child: Column(
children: [
2023-07-22 11:00:27 +00:00
const SizedBox(height: 16),
Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Material(
2023-12-24 12:46:29 +00:00
color: Colors.transparent,
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
clipBehavior: Clip.hardEdge,
elevation: theme.appBarTheme.scrolledUnderElevation ?? 4,
shadowColor: theme.appBarTheme.shadowColor,
child: ConstrainedBox(
constraints: isMobileMode
? const BoxConstraints()
2024-08-17 10:16:55 +00:00
: const BoxConstraints(maxWidth: 480, maxHeight: 640),
2023-12-25 17:36:04 +00:00
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 10.0,
sigmaY: 10.0,
),
child: scaffold,
),
),
),
),
2022-12-29 19:38:13 +00:00
),
2022-04-15 09:42:59 +00:00
),
2023-12-24 12:46:29 +00:00
const _PrivacyButtons(mainAxisAlignment: MainAxisAlignment.center),
],
),
);
}
}
class _PrivacyButtons extends StatelessWidget {
final MainAxisAlignment mainAxisAlignment;
const _PrivacyButtons({required this.mainAxisAlignment});
@override
Widget build(BuildContext context) {
2023-12-24 12:46:29 +00:00
final shadowTextStyle = FluffyThemes.isColumnMode(context)
? const TextStyle(
color: Colors.white,
shadows: [
Shadow(
offset: Offset(0.0, 0.0),
blurRadius: 3,
color: Colors.black,
),
],
)
: null;
return SizedBox(
height: 64,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: mainAxisAlignment,
children: [
TextButton(
onPressed: () => PlatformInfos.showDialog(context),
2023-12-24 12:46:29 +00:00
child: Text(
L10n.of(context)!.about,
style: shadowTextStyle,
),
),
TextButton(
onPressed: () => launchUrlString(AppConfig.privacyUrl),
2023-12-24 12:46:29 +00:00
child: Text(
L10n.of(context)!.privacy,
style: shadowTextStyle,
),
),
],
2022-04-15 09:42:59 +00:00
),
),
);
}
}