Files
wehub-resource-sync bb087aad19
CI / format (push) Failing after 2s
CI / packaging (push) Failing after 0s
CI / test (push) Failing after 3s
chore: import upstream snapshot with attribution
2026-07-13 11:58:56 +08:00

77 lines
2.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:localsend_app/util/ui/nav_bar_padding.dart';
import 'package:localsend_app/widget/responsive_builder.dart';
class ResponsiveListView extends StatelessWidget {
static const defaultMaxWidth = 600.0;
final double maxWidth;
final ScrollController? controller;
final EdgeInsets padding;
final EdgeInsets desktopPadding;
final List<Widget>? children;
final Widget? child;
const ResponsiveListView.single({
this.maxWidth = defaultMaxWidth,
this.controller,
required this.padding,
EdgeInsets? tabletPadding,
required Widget this.child,
super.key,
}) : desktopPadding = tabletPadding ?? const EdgeInsets.symmetric(horizontal: 10, vertical: 30),
children = null;
const ResponsiveListView({
this.maxWidth = defaultMaxWidth,
this.controller,
required this.padding,
EdgeInsets? tabletPadding,
required List<Widget> this.children,
super.key,
}) : desktopPadding = tabletPadding ?? const EdgeInsets.symmetric(horizontal: 10, vertical: 30),
child = null;
@override
Widget build(BuildContext context) {
if (children != null) {
return SingleChildScrollView(
controller: controller,
child: Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth),
child: ResponsiveBuilder(
builder: (sizingInformation) {
final bottom = sizingInformation.isDesktop ? desktopPadding.bottom : padding.bottom;
return Padding(
padding: (sizingInformation.isDesktop ? desktopPadding : padding).copyWith(
bottom: bottom + getNavBarPadding(context),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: children!,
),
);
},
),
),
),
);
} else {
return Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth),
child: ResponsiveBuilder(
builder: (sizingInformation) {
return Padding(
padding: sizingInformation.isDesktop ? desktopPadding : padding,
child: child!,
);
},
),
),
);
}
}
}