mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 06:15:10 +00:00
chore: Follow up nicer max width pages
This commit is contained in:
parent
d71d633cce
commit
b20cee34d4
2 changed files with 33 additions and 36 deletions
|
@ -716,9 +716,10 @@ class ChatListController extends State<ChatList>
|
|||
isDestructiveAction: true,
|
||||
);
|
||||
if (confirmed == OkCancelResult.cancel) return;
|
||||
if (!mounted) {
|
||||
if (!mounted) return;
|
||||
|
||||
await showFutureLoadingDialog(context: context, future: room.leave);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
|
||||
class MaxWidthBody extends StatelessWidget {
|
||||
final Widget? child;
|
||||
final Widget child;
|
||||
final double maxWidth;
|
||||
final bool withFrame;
|
||||
final bool withScrolling;
|
||||
final EdgeInsets? innerPadding;
|
||||
|
||||
const MaxWidthBody({
|
||||
this.child,
|
||||
required this.child,
|
||||
this.maxWidth = 600,
|
||||
this.withFrame = true,
|
||||
this.withScrolling = true,
|
||||
this.innerPadding,
|
||||
super.key,
|
||||
|
@ -24,36 +21,35 @@ class MaxWidthBody extends StatelessWidget {
|
|||
return SafeArea(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final paddingVal = max(0, (constraints.maxWidth - maxWidth) / 2);
|
||||
final hasPadding = paddingVal > 0;
|
||||
final padding = EdgeInsets.symmetric(
|
||||
vertical: hasPadding ? 32 : 0,
|
||||
horizontal: max(0, (constraints.maxWidth - maxWidth) / 2),
|
||||
);
|
||||
final childWithPadding = Padding(
|
||||
padding: padding,
|
||||
child: withFrame && hasPadding
|
||||
? Material(
|
||||
elevation:
|
||||
Theme.of(context).appBarTheme.scrolledUnderElevation ??
|
||||
const desiredWidth = FluffyThemes.columnWidth * 1.5;
|
||||
final body = constraints.maxWidth <= desiredWidth
|
||||
? child
|
||||
: Container(
|
||||
alignment: Alignment.topCenter,
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: FluffyThemes.columnWidth * 1.5,
|
||||
),
|
||||
child: Material(
|
||||
elevation: Theme.of(context)
|
||||
.appBarTheme
|
||||
.scrolledUnderElevation ??
|
||||
4,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||
borderRadius:
|
||||
BorderRadius.circular(AppConfig.borderRadius),
|
||||
shadowColor: Theme.of(context).appBarTheme.shadowColor,
|
||||
child: child,
|
||||
)
|
||||
: child,
|
||||
),
|
||||
),
|
||||
);
|
||||
if (!withScrolling) {
|
||||
return Padding(
|
||||
padding: innerPadding ?? EdgeInsets.zero,
|
||||
child: childWithPadding,
|
||||
);
|
||||
}
|
||||
if (!withScrolling) return body;
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: innerPadding,
|
||||
physics: const ScrollPhysics(),
|
||||
child: childWithPadding,
|
||||
child: body,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue