2021-04-09 14:56:23 +02:00
|
|
|
import 'dart:math';
|
|
|
|
|
2021-10-26 18:50:34 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2021-05-29 09:56:52 +02:00
|
|
|
import 'package:fluffychat/config/themes.dart';
|
2021-09-19 13:48:23 +02:00
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
2021-04-09 14:56:23 +02:00
|
|
|
|
|
|
|
class OnePageCard extends StatelessWidget {
|
|
|
|
final Widget child;
|
|
|
|
|
2021-12-07 00:25:03 +01:00
|
|
|
/// This will cause the "isLogged()" check to be skipped and force a
|
|
|
|
/// OnePageCard without login wallpaper. This can be used in situations where
|
|
|
|
/// "Matrix.of(context) is not yet available, e.g. in the LockScreen widget.
|
|
|
|
final bool forceBackgroundless;
|
|
|
|
|
|
|
|
const OnePageCard(
|
|
|
|
{Key? key, required this.child, this.forceBackgroundless = false})
|
|
|
|
: super(key: key);
|
2021-04-09 14:56:23 +02:00
|
|
|
|
2021-05-01 07:45:11 +02:00
|
|
|
static const int alpha = 12;
|
2021-05-29 09:56:52 +02:00
|
|
|
static num breakpoint = FluffyThemes.columnWidth * 2;
|
2021-04-09 14:56:23 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-11-15 09:48:21 +01:00
|
|
|
final horizontalPadding =
|
2021-11-19 20:28:17 +01:00
|
|
|
max<double>((MediaQuery.of(context).size.width - 600) / 2, 24);
|
2021-09-19 13:48:23 +02:00
|
|
|
return MediaQuery.of(context).size.width <= breakpoint ||
|
2021-12-07 00:25:03 +01:00
|
|
|
forceBackgroundless ||
|
2021-09-19 13:48:23 +02:00
|
|
|
Matrix.of(context).client.isLogged()
|
2021-04-09 15:48:50 +02:00
|
|
|
? child
|
2021-08-31 11:51:39 +02:00
|
|
|
: Container(
|
2021-10-14 18:09:30 +02:00
|
|
|
decoration: const BoxDecoration(
|
2021-08-31 11:51:39 +02:00
|
|
|
image: DecorationImage(
|
|
|
|
image: AssetImage('assets/login_wallpaper.jpg'),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Padding(
|
2021-11-15 09:48:21 +01:00
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: 16,
|
|
|
|
left: horizontalPadding,
|
|
|
|
right: horizontalPadding,
|
|
|
|
bottom: max((MediaQuery.of(context).size.height - 600) / 2, 24),
|
2021-04-09 15:48:50 +02:00
|
|
|
),
|
2021-11-15 09:48:21 +01:00
|
|
|
child: SafeArea(child: Card(elevation: 16, child: child)),
|
2021-04-09 15:48:50 +02:00
|
|
|
),
|
|
|
|
);
|
2021-04-09 14:56:23 +02:00
|
|
|
}
|
|
|
|
}
|