57 lines
1.6 KiB
Dart
57 lines
1.6 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:please_pay_me/theme/theme.dart';
|
|
|
|
/// Puts a use-case on the iOS grouped background so inset-grouped cards and
|
|
/// separators read the way they do inside the app.
|
|
class IosPreview extends StatelessWidget {
|
|
const IosPreview({
|
|
super.key,
|
|
required this.child,
|
|
this.padding = const EdgeInsets.symmetric(vertical: AppSpacing.s5),
|
|
this.maxWidth = 420,
|
|
this.stretch = false,
|
|
});
|
|
|
|
/// Preview for controls that should not be stretched (buttons, chips).
|
|
const IosPreview.centered({super.key, required this.child})
|
|
: padding = const EdgeInsets.all(AppSpacing.s5),
|
|
maxWidth = 420,
|
|
stretch = false;
|
|
|
|
final Widget child;
|
|
final EdgeInsetsGeometry padding;
|
|
final double maxWidth;
|
|
final bool stretch;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ColoredBox(
|
|
color: AppColors.of(context, AppColors.groupedBackground),
|
|
child: Center(
|
|
child: SingleChildScrollView(
|
|
padding: padding,
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(maxWidth: maxWidth),
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
stretch ? CrossAxisAlignment.stretch : CrossAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [child],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Full-screen preview (screens already bring their own scaffold).
|
|
class IosScreenPreview extends StatelessWidget {
|
|
const IosScreenPreview({super.key, required this.child});
|
|
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => child;
|
|
}
|