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
|
|
|
|
2023-06-11 16:04:31 +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';
|
2023-06-11 16:04:31 +00:00
|
|
|
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({
|
2023-10-28 11:03:16 +00:00
|
|
|
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,
|
2023-10-28 11:03:16 +00:00
|
|
|
});
|
2022-04-15 09:42:59 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-08-04 12:09:36 +00:00
|
|
|
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(
|
2023-06-11 16:04:31 +00:00
|
|
|
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),
|
2024-08-04 12:09:36 +00:00
|
|
|
backgroundColor:
|
|
|
|
isMobileMode ? null : theme.colorScheme.surface.withOpacity(0.8),
|
2023-06-11 16:04:31 +00:00
|
|
|
bottomNavigationBar: isMobileMode
|
|
|
|
? Material(
|
2023-07-23 05:42:27 +00:00
|
|
|
elevation: 4,
|
2024-08-04 12:09:36 +00:00
|
|
|
shadowColor: theme.colorScheme.onSurface,
|
2024-08-28 06:43:21 +00:00
|
|
|
child: const SafeArea(
|
|
|
|
child: _PrivacyButtons(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
),
|
2023-06-11 16:04:31 +00:00
|
|
|
),
|
|
|
|
)
|
|
|
|
: 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'),
|
|
|
|
),
|
2022-08-28 09:39:33 +00:00
|
|
|
),
|
2023-06-11 16:04:31 +00:00
|
|
|
child: Column(
|
|
|
|
children: [
|
2023-07-22 11:00:27 +00:00
|
|
|
const SizedBox(height: 16),
|
2023-06-11 16:04:31 +00:00
|
|
|
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,
|
2023-06-11 16:04:31 +00:00
|
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
|
|
clipBehavior: Clip.hardEdge,
|
2024-08-04 12:09:36 +00:00
|
|
|
elevation: theme.appBarTheme.scrolledUnderElevation ?? 4,
|
|
|
|
shadowColor: theme.appBarTheme.shadowColor,
|
2023-06-11 16:04:31 +00:00
|
|
|
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,
|
|
|
|
),
|
2023-06-11 16:04:31 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
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),
|
2023-06-11 16:04:31 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2023-06-11 16:04:31 +00:00
|
|
|
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,
|
|
|
|
),
|
2023-06-11 16:04:31 +00:00
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => launchUrlString(AppConfig.privacyUrl),
|
2023-12-24 12:46:29 +00:00
|
|
|
child: Text(
|
|
|
|
L10n.of(context)!.privacy,
|
|
|
|
style: shadowTextStyle,
|
|
|
|
),
|
2023-06-11 16:04:31 +00:00
|
|
|
),
|
|
|
|
],
|
2022-04-15 09:42:59 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|