Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting rid of containers #147432

Merged
merged 44 commits into from May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2df9506
get rid of containers!
nate-thegrate Mar 29, 2024
88ef5c7
fix analysis problems
nate-thegrate Mar 31, 2024
5b3fe23
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate Apr 23, 2024
2eb9b4d
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate Apr 23, 2024
f5868fb
more container refactoring!
nate-thegrate Apr 23, 2024
49c3c2d
Merge branch 'master' into no-more-containers
nate-thegrate Apr 26, 2024
5130eb8
revert `DecoratedBox` changes
nate-thegrate Apr 26, 2024
8c2e67e
update CupertinoListTile & relevant test
nate-thegrate Apr 26, 2024
8a0baa9
fix CupertinoContextMenu test
nate-thegrate Apr 26, 2024
532a819
revert data_table.dart for now
nate-thegrate Apr 26, 2024
9fd914f
update card_theme_test.dart
nate-thegrate Apr 26, 2024
50fcc9b
fix stepper_test.dart
nate-thegrate Apr 26, 2024
4087e62
improve drawer.dart and relevant test
nate-thegrate Apr 27, 2024
1943456
fix card_test.dart
nate-thegrate Apr 27, 2024
a97d690
update dropdown_menu.dart and relevant test
nate-thegrate Apr 27, 2024
feeeaa9
fix popup_menu_test
nate-thegrate Apr 27, 2024
90614d8
remove redundant import
nate-thegrate Apr 27, 2024
571da17
more semantics!
nate-thegrate Apr 27, 2024
b52f2ca
pushed to the wrong branch 😑
nate-thegrate Apr 27, 2024
7bed677
fix context_menu_test.dart
nate-thegrate Apr 27, 2024
79a76d5
list_section tweak
nate-thegrate Apr 27, 2024
2986d4d
reverting `CupertinoListTile` & `CupertinoListSection` for now
nate-thegrate Apr 27, 2024
8130456
Merge branch 'master' into no-more-containers
nate-thegrate Apr 27, 2024
99c2c1b
fix drawer_theme_test.dart
nate-thegrate Apr 27, 2024
5c8c311
fix navigation_drawer.dart and the relevant test
nate-thegrate Apr 27, 2024
101c33f
fix progress_indicator_test.dart
nate-thegrate Apr 27, 2024
d3bf5be
update autocomplete.dart & relevant test
nate-thegrate Apr 27, 2024
202fdfb
revert autocomplete changes for now
nate-thegrate Apr 27, 2024
defbf62
update popup_menu.dart & relevant test
nate-thegrate Apr 27, 2024
eba16f4
update "Material2 - PopupMenuItem default padding"
nate-thegrate Apr 27, 2024
4875fef
revert cupertino changes (since the PR is pretty huge)
nate-thegrate Apr 27, 2024
20197d8
factor out `LimitedBox` objects
nate-thegrate Apr 28, 2024
67eb7f5
re-implement `LimitedBox` for drawer, tabs, expansion_panel
nate-thegrate Apr 28, 2024
7314e0a
clean up constraints
nate-thegrate Apr 29, 2024
6c2ce6b
update tests
nate-thegrate Apr 29, 2024
5f55cf3
Merge branch 'master' into no-more-containers
nate-thegrate Apr 29, 2024
e7217f6
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate May 2, 2024
a152a4c
re-implement `cupertino/` stuff
nate-thegrate May 7, 2024
73bdeba
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate May 7, 2024
722f7dd
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate May 7, 2024
0dfb13d
keep cupertino & material `a-d`, revert others
nate-thegrate May 7, 2024
5a76fd4
improve date_picker.dart
nate-thegrate May 7, 2024
503d9f6
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate May 7, 2024
5ac446b
Merge branch 'master' into no-more-containers
nate-thegrate May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 18 additions & 25 deletions packages/flutter/lib/src/cupertino/context_menu_action.dart
Expand Up @@ -120,33 +120,26 @@ class _CupertinoContextMenuActionState extends State<CupertinoContextMenuAction>
),
child: Semantics(
button: true,
child: Container(
decoration: BoxDecoration(
color: _isPressed
child: ColoredBox(
color: _isPressed
? CupertinoDynamicColor.resolve(_kBackgroundColorPressed, context)
: CupertinoDynamicColor.resolve(_kBackgroundColor, context),
),
padding: const EdgeInsets.only(
top: 8,
bottom: 8,
left: 15.5,
right: 17.5,
),
child: DefaultTextStyle(
style: _textStyle,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(
child: widget.child,
),
if (widget.trailingIcon != null)
Icon(
widget.trailingIcon,
color: _textStyle.color,
size: 21.0,
),
],
child: Padding(
padding: const EdgeInsets.fromLTRB(15.5, 8.0, 17.5, 8.0),
child: DefaultTextStyle(
style: _textStyle,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(child: widget.child),
if (widget.trailingIcon != null)
Icon(
widget.trailingIcon,
color: _textStyle.color,
size: 21.0,
),
],
),
),
),
),
Expand Down
176 changes: 98 additions & 78 deletions packages/flutter/lib/src/cupertino/date_picker.dart
Expand Up @@ -1050,43 +1050,43 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
final List<Widget> pickers = <Widget>[];
double totalColumnWidths = 4 * _kDatePickerPadSize;

for (int i = 0; i < columnWidths.length; i++) {
for (final (int i, double width) in columnWidths.indexed) {
final (bool firstColumn, bool lastColumn) = (i == 0, i == columnWidths.length - 1);
double offAxisFraction = 0.0;
Widget selectionOverlay = _centerSelectionOverlay;
if (i == 0) {
if (firstColumn) {
offAxisFraction = -_kMaximumOffAxisFraction * textDirectionFactor;
selectionOverlay = _startSelectionOverlay;
} else if (i >= 2 || columnWidths.length == 2) {
offAxisFraction = _kMaximumOffAxisFraction * textDirectionFactor;
}

EdgeInsets padding = const EdgeInsets.only(right: _kDatePickerPadSize);
if (i == columnWidths.length - 1) {
if (lastColumn) {
padding = padding.flipped;
selectionOverlay = _endSelectionOverlay;
}
if (textDirectionFactor == -1) {
padding = padding.flipped;
}

totalColumnWidths += columnWidths[i] + (2 * _kDatePickerPadSize);
totalColumnWidths += width + (2 * _kDatePickerPadSize);

pickers.add(LayoutId(
id: i,
child: pickerBuilders[i](
offAxisFraction,
(BuildContext context, Widget? child) {
return Container(
alignment: i == columnWidths.length - 1
? alignCenterLeft
: alignCenterRight,
late final Widget constrained = ConstrainedBox(
constraints: BoxConstraints(maxWidth: width + _kDatePickerPadSize),
child: child,
);

return Padding(
padding: padding,
child: Container(
alignment: i == columnWidths.length - 1 ? alignCenterLeft : alignCenterRight,
width: i == 0 || i == columnWidths.length - 1
? null
: columnWidths[i] + _kDatePickerPadSize,
child: child,
child: Align(
alignment: lastColumn ? alignCenterLeft : alignCenterRight,
child: firstColumn || lastColumn ? constrained : child,
),
);
},
Expand Down Expand Up @@ -1453,7 +1453,8 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> {
final List<Widget> pickers = <Widget>[];
double totalColumnWidths = 4 * _kDatePickerPadSize;

for (int i = 0; i < columnWidths.length; i++) {
for (final (int i, double width) in columnWidths.indexed) {
final (bool firstColumn, bool lastColumn) = (i == 0, i == columnWidths.length - 1);
final double offAxisFraction = (i - 1) * 0.3 * textDirectionFactor;

EdgeInsets padding = const EdgeInsets.only(right: _kDatePickerPadSize);
Expand All @@ -1462,28 +1463,30 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> {
}

Widget selectionOverlay = _centerSelectionOverlay;
if (i == 0) {
if (firstColumn) {
selectionOverlay = _startSelectionOverlay;
} else if (i == columnWidths.length - 1) {
selectionOverlay = _endSelectionOverlay;
}

totalColumnWidths += columnWidths[i] + (2 * _kDatePickerPadSize);
totalColumnWidths += width + (2 * _kDatePickerPadSize);

pickers.add(LayoutId(
id: i,
child: pickerBuilders[i](
offAxisFraction,
(BuildContext context, Widget? child) {
return Container(
alignment: i == columnWidths.length - 1
? alignCenterLeft
: alignCenterRight,
padding: i == 0 ? null : padding,
child: Container(
alignment: i == 0 ? alignCenterLeft : alignCenterRight,
width: columnWidths[i] + _kDatePickerPadSize,
child: child,
return Padding(
padding: firstColumn ? EdgeInsets.zero : padding,
child: Align(
alignment: lastColumn ? alignCenterLeft : alignCenterRight,
child: SizedBox(
width: width + _kDatePickerPadSize,
child: Align(
alignment: firstColumn ? alignCenterLeft : alignCenterRight,
child: child,
),
),
),
);
},
Expand Down Expand Up @@ -1763,33 +1766,39 @@ class _CupertinoDatePickerMonthYearState extends State<CupertinoDatePicker> {
final List<Widget> pickers = <Widget>[];
double totalColumnWidths = 3 * _kDatePickerPadSize;

for (int i = 0; i < columnWidths.length; i++) {
final (bool first, bool last) = (i == 0, i == columnWidths.length - 1);
final double offAxisFraction = textDirectionFactor * (first ? -0.3 : 0.5);
for (final (int i, double width) in columnWidths.indexed) {
final (bool firstColumn, bool lastColumn) = (i == 0, i == columnWidths.length - 1);
final double offAxisFraction = textDirectionFactor * (firstColumn ? -0.3 : 0.5);

totalColumnWidths += columnWidths[i] + (2 * _kDatePickerPadSize);
totalColumnWidths += width + (2 * _kDatePickerPadSize);

pickers.add(LayoutId(
id: i,
child: pickerBuilders[i](
offAxisFraction,
(BuildContext context, Widget? child) {
return Container(
alignment: last ? alignCenterLeft : alignCenterRight,
padding: switch (textDirectionFactor) {
_ when first => null,
-1 => const EdgeInsets.only(left: _kDatePickerPadSize),
_ => const EdgeInsets.only(right: _kDatePickerPadSize),
},
child: Container(
alignment: first ? alignCenterLeft : alignCenterRight,
width: columnWidths[i] + _kDatePickerPadSize,
child: child,
final Widget contents = Align(
alignment: lastColumn ? alignCenterLeft : alignCenterRight,
child: SizedBox(
width: width + _kDatePickerPadSize,
child: Align(
alignment: firstColumn ? alignCenterLeft : alignCenterRight,
child: child,
),
),
);
if (firstColumn) {
return contents;
}

const EdgeInsets padding = EdgeInsets.only(right: _kDatePickerPadSize);
return Padding(
padding: textDirectionFactor == -1 ? padding.flipped : padding,
child: contents,
);
},
switch (last) {
_ when first => _startSelectionOverlay,
switch (lastColumn) {
_ when firstColumn => _startSelectionOverlay,
false => _centerSelectionOverlay,
true => _endSelectionOverlay,
},
Expand Down Expand Up @@ -2127,22 +2136,24 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
);

return IgnorePointer(
child: Container(
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
child: Padding(
padding: padding.resolve(textDirection),
child: SizedBox(
height: numberLabelHeight,
child: Baseline(
baseline: numberLabelBaseline,
baselineType: TextBaseline.alphabetic,
child: Text(
text,
style: const TextStyle(
fontSize: _kTimerPickerLabelFontSize,
fontWeight: FontWeight.w600,
child: Align(
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
child: SizedBox(
height: numberLabelHeight,
child: Baseline(
baseline: numberLabelBaseline,
baselineType: TextBaseline.alphabetic,
child: Text(
text,
style: const TextStyle(
fontSize: _kTimerPickerLabelFontSize,
fontWeight: FontWeight.w600,
),
maxLines: 1,
softWrap: false,
),
maxLines: 1,
softWrap: false,
),
),
),
Expand All @@ -2153,14 +2164,20 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
// The picker has to be wider than its content, since the separators
// are part of the picker.
Widget _buildPickerNumberLabel(String text, EdgeInsetsDirectional padding) {
return Container(
return SizedBox(
width: _kTimerPickerColumnIntrinsicWidth + padding.horizontal,
padding: padding.resolve(textDirection),
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
child: Container(
width: numberLabelWidth,
alignment: AlignmentDirectional.centerEnd.resolve(textDirection),
child: Text(text, softWrap: false, maxLines: 1, overflow: TextOverflow.visible),
child: Padding(
padding: padding.resolve(textDirection),
child: Align(
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
child: SizedBox(
width: numberLabelWidth,
child: Align(
alignment: AlignmentDirectional.centerEnd.resolve(textDirection),
child: Text(text, softWrap: false, maxLines: 1, overflow: TextOverflow.visible),
),
),
),
),
);
}
Expand Down Expand Up @@ -2508,28 +2525,31 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
),
];
}

Widget contents = SizedBox(
width: totalWidth,
height: _kPickerHeight,
child: DefaultTextStyle(
style: _textStyleFrom(context),
child: Row(children: columns.map((Widget child) => Expanded(child: child)).toList(growable: false)),
),
);
final Color? color = CupertinoDynamicColor.maybeResolve(widget.backgroundColor, context);
if (color != null) {
contents = ColoredBox(color: color, child: contents);
}

final CupertinoThemeData themeData = CupertinoTheme.of(context);
// The native iOS picker's text scaling is fixed, so we will also fix it
// as well in our picker.

// Text scaling is fixed to match the native iOS date picker.
return MediaQuery.withNoTextScaling(
child: CupertinoTheme(
data: themeData.copyWith(
textTheme: themeData.textTheme.copyWith(
pickerTextStyle: _textStyleFrom(context, _kTimerPickerMagnification),
),
),
child: Align(
alignment: widget.alignment,
child: Container(
color: CupertinoDynamicColor.maybeResolve(widget.backgroundColor, context),
width: totalWidth,
height: _kPickerHeight,
child: DefaultTextStyle(
style: _textStyleFrom(context),
child: Row(children: columns.map((Widget child) => Expanded(child: child)).toList(growable: false)),
),
),
),
child: Align(alignment: widget.alignment, child: contents),
),
);
},
Expand Down