Added a parameter to skip the "client.isLogged()" check on the MatrixState in the OnePageCard.

This commit is contained in:
Drews Clausen 2021-12-07 00:25:03 +01:00
parent 5fc10f4571
commit 5221a07cc7
2 changed files with 10 additions and 1 deletions

View File

@ -10,7 +10,14 @@ import 'package:fluffychat/widgets/matrix.dart';
class OnePageCard extends StatelessWidget { class OnePageCard extends StatelessWidget {
final Widget child; final Widget child;
const OnePageCard({Key? key, required this.child}) : super(key: key); /// 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);
static const int alpha = 12; static const int alpha = 12;
static num breakpoint = FluffyThemes.columnWidth * 2; static num breakpoint = FluffyThemes.columnWidth * 2;
@ -19,6 +26,7 @@ class OnePageCard extends StatelessWidget {
final horizontalPadding = final horizontalPadding =
max<double>((MediaQuery.of(context).size.width - 600) / 2, 24); max<double>((MediaQuery.of(context).size.width - 600) / 2, 24);
return MediaQuery.of(context).size.width <= breakpoint || return MediaQuery.of(context).size.width <= breakpoint ||
forceBackgroundless ||
Matrix.of(context).client.isLogged() Matrix.of(context).client.isLogged()
? child ? child
: Container( : Container(

View File

@ -30,6 +30,7 @@ class _LockScreenState extends State<LockScreen> {
supportedLocales: L10n.supportedLocales, supportedLocales: L10n.supportedLocales,
home: Builder( home: Builder(
builder: (context) => OnePageCard( builder: (context) => OnePageCard(
forceBackgroundless: true,
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
automaticallyImplyLeading: false, automaticallyImplyLeading: false,