refactor: Move widgets to lib
This commit is contained in:
parent
3a200a98d8
commit
c8827ae1b2
86 changed files with 136 additions and 136 deletions
14
lib/widgets/layouts/loading_view.dart
Normal file
14
lib/widgets/layouts/loading_view.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoadingView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (Matrix.of(context).loginState != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) =>
|
||||
AdaptivePageLayout.of(context).pushNamedAndRemoveAllOthers('/'));
|
||||
}
|
||||
return Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
}
|
||||
38
lib/widgets/layouts/max_width_body.dart
Normal file
38
lib/widgets/layouts/max_width_body.dart
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MaxWidthBody extends StatelessWidget {
|
||||
final Widget child;
|
||||
final double maxWidth;
|
||||
final bool withScrolling;
|
||||
|
||||
const MaxWidthBody({
|
||||
this.child,
|
||||
this.maxWidth = 600,
|
||||
this.withScrolling = false,
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final padding = EdgeInsets.symmetric(
|
||||
horizontal: max(0, (constraints.maxWidth - maxWidth) / 2),
|
||||
);
|
||||
return withScrolling
|
||||
? SingleChildScrollView(
|
||||
physics: ScrollPhysics(),
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: child,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: padding,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
45
lib/widgets/layouts/one_page_card.dart
Normal file
45
lib/widgets/layouts/one_page_card.dart
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class OnePageCard extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const OnePageCard({Key key, this.child}) : super(key: key);
|
||||
|
||||
static const int alpha = 12;
|
||||
static const int breakpoint = 600;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width <= breakpoint ||
|
||||
MediaQuery.of(context).size.height <= breakpoint
|
||||
? child
|
||||
: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topRight,
|
||||
end: Alignment.bottomLeft,
|
||||
stops: [
|
||||
0.1,
|
||||
0.4,
|
||||
0.6,
|
||||
0.9,
|
||||
],
|
||||
colors: [
|
||||
Theme.of(context).secondaryHeaderColor.withAlpha(alpha),
|
||||
Theme.of(context).primaryColor.withAlpha(alpha),
|
||||
Theme.of(context).accentColor.withAlpha(alpha),
|
||||
Theme.of(context).backgroundColor.withAlpha(alpha),
|
||||
],
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
max((MediaQuery.of(context).size.width - 600) / 2, 12),
|
||||
vertical: max((MediaQuery.of(context).size.height - 800) / 2, 12),
|
||||
),
|
||||
child: SafeArea(child: Card(child: child)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue