mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-20 02:59:26 +01:00
refactor: Make layouts null safe
This commit is contained in:
parent
aaf67c8f70
commit
3f10c0bae6
@ -1,3 +1,5 @@
|
|||||||
|
//@dart=2.12
|
||||||
|
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -5,7 +7,7 @@ import 'package:flutter/material.dart';
|
|||||||
class EmptyPage extends StatelessWidget {
|
class EmptyPage extends StatelessWidget {
|
||||||
final bool loading;
|
final bool loading;
|
||||||
static const double _width = 200;
|
static const double _width = 200;
|
||||||
const EmptyPage({this.loading = false, Key key}) : super(key: key);
|
const EmptyPage({this.loading = false, Key? key}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final _width = min(MediaQuery.of(context).size.width, EmptyPage._width);
|
final _width = min(MediaQuery.of(context).size.width, EmptyPage._width);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//@dart=2.12
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
@ -7,26 +9,21 @@ import 'package:fluffychat/widgets/layouts/empty_page.dart';
|
|||||||
import 'package:fluffychat/widgets/matrix.dart';
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
|
|
||||||
class LoadingView extends StatelessWidget {
|
class LoadingView extends StatelessWidget {
|
||||||
const LoadingView({Key key}) : super(key: key);
|
const LoadingView({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (Matrix.of(context)
|
WidgetsBinding.instance?.addPostFrameCallback(
|
||||||
.widget
|
(_) => VRouter.of(context).to(
|
||||||
.clients
|
Matrix.of(context)
|
||||||
.every((client) => client.loginState != null)) {
|
.widget
|
||||||
WidgetsBinding.instance.addPostFrameCallback(
|
.clients
|
||||||
(_) => VRouter.of(context).to(
|
.any((client) => client.loginState == LoginState.loggedIn)
|
||||||
Matrix.of(context)
|
? '/rooms'
|
||||||
.widget
|
: '/home',
|
||||||
.clients
|
queryParameters: VRouter.of(context).queryParameters,
|
||||||
.any((client) => client.loginState == LoginState.loggedIn)
|
),
|
||||||
? '/rooms'
|
);
|
||||||
: '/home',
|
|
||||||
queryParameters: VRouter.of(context).queryParameters,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return const EmptyPage(loading: true);
|
return const EmptyPage(loading: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
//@dart=2.12
|
||||||
|
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class MaxWidthBody extends StatelessWidget {
|
class MaxWidthBody extends StatelessWidget {
|
||||||
final Widget child;
|
final Widget? child;
|
||||||
final double maxWidth;
|
final double maxWidth;
|
||||||
final bool withScrolling;
|
final bool withScrolling;
|
||||||
|
|
||||||
@ -11,7 +13,7 @@ class MaxWidthBody extends StatelessWidget {
|
|||||||
this.child,
|
this.child,
|
||||||
this.maxWidth = 600,
|
this.maxWidth = 600,
|
||||||
this.withScrolling = false,
|
this.withScrolling = false,
|
||||||
Key key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//@dart=2.12
|
||||||
|
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -8,14 +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, this.child}) : super(key: key);
|
const OnePageCard({Key? key, required this.child}) : 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;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final horizontalPadding =
|
final horizontalPadding =
|
||||||
max((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 ||
|
||||||
Matrix.of(context).client.isLogged()
|
Matrix.of(context).client.isLogged()
|
||||||
? child
|
? child
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//@dart=2.12
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:vrouter/vrouter.dart';
|
import 'package:vrouter/vrouter.dart';
|
||||||
@ -6,15 +8,16 @@ import 'package:fluffychat/config/themes.dart';
|
|||||||
|
|
||||||
class SideViewLayout extends StatelessWidget {
|
class SideViewLayout extends StatelessWidget {
|
||||||
final Widget mainView;
|
final Widget mainView;
|
||||||
final Widget sideView;
|
final Widget? sideView;
|
||||||
|
|
||||||
const SideViewLayout({Key key, @required this.mainView, this.sideView})
|
const SideViewLayout({Key? key, required this.mainView, this.sideView})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var currentUrl = Uri.decodeFull(VRouter.of(context).url);
|
var currentUrl = Uri.decodeFull(VRouter.of(context).url);
|
||||||
if (!currentUrl.endsWith('/')) currentUrl += '/';
|
if (!currentUrl.endsWith('/')) currentUrl += '/';
|
||||||
final hideSideView = currentUrl.split('/').length == 4;
|
final hideSideView = currentUrl.split('/').length == 4;
|
||||||
|
final sideView = this.sideView;
|
||||||
return sideView == null
|
return sideView == null
|
||||||
? mainView
|
? mainView
|
||||||
: MediaQuery.of(context).size.width < FluffyThemes.columnWidth * 3.5 &&
|
: MediaQuery.of(context).size.width < FluffyThemes.columnWidth * 3.5 &&
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//@dart=2.12
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/config/themes.dart';
|
import 'package:fluffychat/config/themes.dart';
|
||||||
@ -6,9 +7,11 @@ class TwoColumnLayout extends StatelessWidget {
|
|||||||
final Widget mainView;
|
final Widget mainView;
|
||||||
final Widget sideView;
|
final Widget sideView;
|
||||||
|
|
||||||
const TwoColumnLayout(
|
const TwoColumnLayout({
|
||||||
{Key key, @required this.mainView, @required this.sideView})
|
Key? key,
|
||||||
: super(key: key);
|
required this.mainView,
|
||||||
|
required this.sideView,
|
||||||
|
}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (MediaQuery.of(context).size.width <= FluffyThemes.columnWidth * 2) {
|
if (MediaQuery.of(context).size.width <= FluffyThemes.columnWidth * 2) {
|
||||||
|
Loading…
Reference in New Issue
Block a user