@@ -63,8 +63,7 @@ class MessagePageScaffold extends RenderObjectWidget {
63
63
}
64
64
65
65
@override
66
- void updateRenderObject (
67
- BuildContext context, RenderMessagePageScaffold renderObject) {
66
+ void updateRenderObject (BuildContext context, RenderMessagePageScaffold renderObject) {
68
67
renderObject
69
68
..bottomSheetMinimumTopGap = bottomSheetMinimumTopGap
70
69
..bottomSheetMinimumHeight = bottomSheetMinimumHeight;
@@ -76,8 +75,7 @@ class MessagePageScaffold extends RenderObjectWidget {
76
75
}
77
76
78
77
/// Builder that builds the content subtree within a [MessagePageScaffold] .
79
- typedef MessagePageScaffoldContentBuilder = Widget Function (
80
- BuildContext context, double bottomSpacing);
78
+ typedef MessagePageScaffoldContentBuilder = Widget Function (BuildContext context, double bottomSpacing);
81
79
82
80
/// Height sizing policy for a bottom sheet within a [MessagePageScaffold] .
83
81
enum BottomSheetMode {
@@ -104,8 +102,7 @@ enum BottomSheetMode {
104
102
/// Controller for a [MessagePageScaffold] .
105
103
class MessagePageController with ChangeNotifier {
106
104
MessagePageSheetHeightPolicy get sheetHeightPolicy => _sheetHeightPolicy;
107
- MessagePageSheetHeightPolicy _sheetHeightPolicy =
108
- MessagePageSheetHeightPolicy .minimumHeight;
105
+ MessagePageSheetHeightPolicy _sheetHeightPolicy = MessagePageSheetHeightPolicy .minimumHeight;
109
106
set sheetHeightPolicy (MessagePageSheetHeightPolicy policy) {
110
107
if (policy == _sheetHeightPolicy) {
111
108
return ;
@@ -116,12 +113,12 @@ class MessagePageController with ChangeNotifier {
116
113
}
117
114
118
115
bool get isPreview =>
119
- _collapsedMode == MessagePageSheetCollapsedMode .preview &&
116
+ _collapsedMode == MessagePageSheetCollapsedMode .preview && //
120
117
! isSliding &&
121
118
! isDragging;
122
119
123
120
bool get isIntrinsic =>
124
- _collapsedMode == MessagePageSheetCollapsedMode .intrinsic &&
121
+ _collapsedMode == MessagePageSheetCollapsedMode .intrinsic && //
125
122
! isSliding &&
126
123
! isDragging;
127
124
@@ -137,12 +134,12 @@ class MessagePageController with ChangeNotifier {
137
134
}
138
135
139
136
bool get isCollapsed =>
140
- _desiredSheetMode == MessagePageSheetMode .collapsed &&
137
+ _desiredSheetMode == MessagePageSheetMode .collapsed && //
141
138
! isSliding &&
142
139
! isDragging;
143
140
144
141
bool get isExpanded =>
145
- _desiredSheetMode == MessagePageSheetMode .expanded &&
142
+ _desiredSheetMode == MessagePageSheetMode .expanded && //
146
143
! isSliding &&
147
144
! isDragging;
148
145
@@ -304,8 +301,7 @@ class MessagePageElement extends RenderObjectElement {
304
301
MessagePageScaffold get widget => super .widget as MessagePageScaffold ;
305
302
306
303
@override
307
- RenderMessagePageScaffold get renderObject =>
308
- super .renderObject as RenderMessagePageScaffold ;
304
+ RenderMessagePageScaffold get renderObject => super .renderObject as RenderMessagePageScaffold ;
309
305
310
306
@override
311
307
void mount (Element ? parent, Object ? newSlot) {
@@ -320,8 +316,7 @@ class MessagePageElement extends RenderObjectElement {
320
316
_contentSlot,
321
317
);
322
318
323
- _bottomSheet =
324
- inflateWidget (widget.bottomSheetBuilder (this ), _bottomSheetSlot);
319
+ _bottomSheet = inflateWidget (widget.bottomSheetBuilder (this ), _bottomSheetSlot);
325
320
}
326
321
327
322
@override
@@ -368,13 +363,11 @@ class MessagePageElement extends RenderObjectElement {
368
363
//
369
364
// We don't rebuild our content widget because we only want content to
370
365
// build during layout.
371
- updateChild (
372
- _bottomSheet, widget.bottomSheetBuilder (this ), _bottomSheetSlot);
366
+ updateChild (_bottomSheet, widget.bottomSheetBuilder (this ), _bottomSheetSlot);
373
367
}
374
368
375
369
void buildContent (double bottomSpacing) {
376
- messagePageElementLog
377
- .info ('ContentLayersElement ($hashCode ) - (re)building layers' );
370
+ messagePageElementLog.info ('ContentLayersElement ($hashCode ) - (re)building layers' );
378
371
379
372
owner! .buildScope (this , () {
380
373
if (_content == null ) {
@@ -396,11 +389,8 @@ class MessagePageElement extends RenderObjectElement {
396
389
void update (MessagePageScaffold newWidget) {
397
390
super .update (newWidget);
398
391
399
- _content =
400
- updateChild (_content, widget.contentBuilder (this , 0 ), _contentSlot) ??
401
- _content;
402
- _bottomSheet = updateChild (
403
- _bottomSheet, widget.bottomSheetBuilder (this ), _bottomSheetSlot);
392
+ _content = updateChild (_content, widget.contentBuilder (this , 0 ), _contentSlot) ?? _content;
393
+ _bottomSheet = updateChild (_bottomSheet, widget.bottomSheetBuilder (this ), _bottomSheetSlot);
404
394
}
405
395
406
396
@override
@@ -619,8 +609,7 @@ class RenderMessagePageScaffold extends RenderBox {
619
609
_currentDesiredGlobalTopY = _controller.desiredGlobalTopY;
620
610
621
611
final pageGlobalBottom = localToGlobal (Offset (0 , size.height)).dy;
622
- _desiredDragHeight = pageGlobalBottom -
623
- max (_currentDesiredGlobalTopY! , _bottomSheetMinimumTopGap);
612
+ _desiredDragHeight = pageGlobalBottom - max (_currentDesiredGlobalTopY! , _bottomSheetMinimumTopGap);
624
613
_expandedHeight = size.height - _bottomSheetMinimumTopGap;
625
614
626
615
_velocityTracker.addPosition (
@@ -649,8 +638,7 @@ class RenderMessagePageScaffold extends RenderBox {
649
638
_isExpandingOrCollapsing = true ;
650
639
_velocityStopwatch.stop ();
651
640
652
- final velocity =
653
- _velocityTracker.getVelocityEstimate ()? .pixelsPerSecond.dy ?? 0 ;
641
+ final velocity = _velocityTracker.getVelocityEstimate ()? .pixelsPerSecond.dy ?? 0 ;
654
642
655
643
_startBottomSheetHeightSimulation (velocity: velocity);
656
644
}
@@ -669,8 +657,7 @@ class RenderMessagePageScaffold extends RenderBox {
669
657
? velocity < 0
670
658
? MessagePageSheetMode .expanded
671
659
: MessagePageSheetMode .collapsed
672
- : (_expandedHeight - _desiredDragHeight! ).abs () <
673
- (_desiredDragHeight! - minimizedHeight).abs ()
660
+ : (_expandedHeight - _desiredDragHeight! ).abs () < (_desiredDragHeight! - minimizedHeight).abs ()
674
661
? MessagePageSheetMode .expanded
675
662
: MessagePageSheetMode .collapsed;
676
663
@@ -698,10 +685,7 @@ class RenderMessagePageScaffold extends RenderBox {
698
685
699
686
final startHeight = _bottomSheet! .size.height;
700
687
_simulationGoalMode = _controller.desiredSheetMode;
701
- _simulationGoalHeight =
702
- _simulationGoalMode! == MessagePageSheetMode .expanded
703
- ? _expandedHeight
704
- : minimizedHeight;
688
+ _simulationGoalHeight = _simulationGoalMode! == MessagePageSheetMode .expanded ? _expandedHeight : minimizedHeight;
705
689
706
690
messagePageLayoutLog.info ('Creating expand/collapse simulation:' );
707
691
messagePageLayoutLog.info (
@@ -856,8 +840,7 @@ class RenderMessagePageScaffold extends RenderBox {
856
840
childDiagnostics.add (_content! .toDiagnosticsNode (name: 'content' ));
857
841
}
858
842
if (_bottomSheet != null ) {
859
- childDiagnostics
860
- .add (_bottomSheet! .toDiagnosticsNode (name: 'message_editor' ));
843
+ childDiagnostics.add (_bottomSheet! .toDiagnosticsNode (name: 'message_editor' ));
861
844
}
862
845
863
846
return childDiagnostics;
@@ -907,8 +890,8 @@ class RenderMessagePageScaffold extends RenderBox {
907
890
void performLayout () {
908
891
messagePageLayoutLog.info ('---------- LAYOUT -------------' );
909
892
messagePageLayoutLog.info ('Laying out RenderChatScaffold' );
910
- messagePageLayoutLog. info (
911
- 'Sheet mode: ${_controller .desiredSheetMode }, collapsed mode: ${_controller .collapsedMode }' );
893
+ messagePageLayoutLog
894
+ . info ( 'Sheet mode: ${_controller .desiredSheetMode }, collapsed mode: ${_controller .collapsedMode }' );
912
895
if (_content == null ) {
913
896
size = Size .zero;
914
897
_bottomSheetNeedsLayout = false ;
@@ -927,9 +910,7 @@ class RenderMessagePageScaffold extends RenderBox {
927
910
// sheet, bounded within its min/max height.
928
911
_overrideSheetMode = BottomSheetMode .preview;
929
912
930
- _previewHeight = _bottomSheet!
931
- .computeDryLayout (constraints.copyWith (minHeight: 0 ))
932
- .height;
913
+ _previewHeight = _bottomSheet! .computeDryLayout (constraints.copyWith (minHeight: 0 )).height;
933
914
934
915
_overrideSheetMode = null ;
935
916
messagePageLayoutLog.info (
@@ -982,7 +963,8 @@ class RenderMessagePageScaffold extends RenderBox {
982
963
983
964
_bottomSheet! .layout (
984
965
bottomSheetConstraints.copyWith (
985
- minHeight: _animatedHeight - 1 ,
966
+ minHeight: max (_animatedHeight - 1 , 0 ),
967
+ // ^ prevent a layout boundary
986
968
maxHeight: _animatedHeight,
987
969
),
988
970
parentUsesSize: true ,
@@ -992,13 +974,13 @@ class RenderMessagePageScaffold extends RenderBox {
992
974
messagePageLayoutLog.info (
993
975
' - drag height: $_desiredDragHeight , minimized height: $minimizedHeight ' ,
994
976
);
995
- final strictHeight =
996
- _desiredDragHeight! .clamp (minimizedHeight, _bottomSheetMaximumHeight);
977
+ final strictHeight = _desiredDragHeight! .clamp (minimizedHeight, _bottomSheetMaximumHeight);
997
978
998
979
messagePageLayoutLog.info (' - bounded drag height: $strictHeight ' );
999
980
_bottomSheet! .layout (
1000
981
bottomSheetConstraints.copyWith (
1001
- minHeight: strictHeight - 1 ,
982
+ minHeight: max (strictHeight - 1 , 0 ),
983
+ // ^ prevent layout boundary
1002
984
maxHeight: strictHeight,
1003
985
),
1004
986
parentUsesSize: true ,
@@ -1011,27 +993,24 @@ class RenderMessagePageScaffold extends RenderBox {
1011
993
1012
994
_bottomSheet! .layout (
1013
995
bottomSheetConstraints.copyWith (
1014
- minHeight: _expandedHeight - 1 ,
996
+ minHeight: max ( _expandedHeight - 1 , 0 ) ,
1015
997
// ^ Prevent a layout boundary.
1016
998
maxHeight: _expandedHeight,
1017
999
),
1018
1000
parentUsesSize: true ,
1019
1001
);
1020
1002
} else {
1021
1003
messagePageLayoutLog.info ('>>>>>>>> Minimized' );
1022
- messagePageLayoutLog.info (
1023
- 'Running standard editor layout with constraints: $bottomSheetConstraints ' );
1004
+ messagePageLayoutLog.info ('Running standard editor layout with constraints: $bottomSheetConstraints ' );
1024
1005
_bottomSheet! .layout (
1025
1006
bottomSheetConstraints,
1026
1007
parentUsesSize: true ,
1027
1008
);
1028
1009
}
1029
1010
1030
- (_bottomSheet! .parentData! as BoxParentData ).offset =
1031
- Offset (0 , size.height - _bottomSheet! .size.height);
1011
+ (_bottomSheet! .parentData! as BoxParentData ).offset = Offset (0 , size.height - _bottomSheet! .size.height);
1032
1012
_bottomSheetNeedsLayout = false ;
1033
- messagePageLayoutLog
1034
- .info ('Bottom sheet height: ${_bottomSheet !.size .height }' );
1013
+ messagePageLayoutLog.info ('Bottom sheet height: ${_bottomSheet !.size .height }' );
1035
1014
1036
1015
// Now that we know the size of the message editor, build the content based
1037
1016
// on the bottom spacing needed to push above the editor.
@@ -1051,11 +1030,9 @@ class RenderMessagePageScaffold extends RenderBox {
1051
1030
}
1052
1031
1053
1032
double _calculateBoundedIntrinsicHeight (BoxConstraints constraints) {
1054
- messagePageLayoutLog.info (
1055
- 'Running dry layout on bottom sheet content to find the intrinsic height...' );
1033
+ messagePageLayoutLog.info ('Running dry layout on bottom sheet content to find the intrinsic height...' );
1056
1034
messagePageLayoutLog.info (' - Bottom sheet constraints: $constraints ' );
1057
- messagePageLayoutLog
1058
- .info (' - Controller desired sheet mode: ${_controller .collapsedMode }' );
1035
+ messagePageLayoutLog.info (' - Controller desired sheet mode: ${_controller .collapsedMode }' );
1059
1036
_overrideSheetMode = BottomSheetMode .intrinsic;
1060
1037
messagePageLayoutLog.info (' - Override sheet mode: $_overrideSheetMode ' );
1061
1038
@@ -1066,8 +1043,7 @@ class RenderMessagePageScaffold extends RenderBox {
1066
1043
.height;
1067
1044
1068
1045
_overrideSheetMode = null ;
1069
- messagePageLayoutLog
1070
- .info (" - Child's self-chosen height is: $bottomSheetHeight " );
1046
+ messagePageLayoutLog.info (" - Child's self-chosen height is: $bottomSheetHeight " );
1071
1047
messagePageLayoutLog.info (
1072
1048
" - Clamping child's height within [$_bottomSheetMinimumHeight , $_bottomSheetMaximumHeight ]" ,
1073
1049
);
@@ -1146,8 +1122,7 @@ class RenderMessagePageScaffold extends RenderBox {
1146
1122
}
1147
1123
}
1148
1124
1149
- bool _isChatScaffoldSlot (Object slot) =>
1150
- slot == _contentSlot || slot == _bottomSheetSlot;
1125
+ bool _isChatScaffoldSlot (Object slot) => slot == _contentSlot || slot == _bottomSheetSlot;
1151
1126
1152
1127
const _contentSlot = 'content' ;
1153
1128
const _bottomSheetSlot = 'bottom_sheet' ;
@@ -1235,8 +1210,7 @@ class RenderMessageEditorHeight extends RenderBox
1235
1210
messageEditorHeightLog.info (' - Constraints: $constraints ' );
1236
1211
1237
1212
final ancestorChatScaffold = _findAncestorMessagePageScaffold ();
1238
- messageEditorHeightLog
1239
- .info (' - Ancestor chat scaffold: $ancestorChatScaffold ' );
1213
+ messageEditorHeightLog.info (' - Ancestor chat scaffold: $ancestorChatScaffold ' );
1240
1214
1241
1215
final heightMode = ancestorChatScaffold? .bottomSheetMode;
1242
1216
if (heightMode == null ) {
@@ -1253,17 +1227,15 @@ class RenderMessageEditorHeight extends RenderBox
1253
1227
switch (heightMode) {
1254
1228
case BottomSheetMode .preview:
1255
1229
// Preview mode imposes a specific height on the bottom sheet.
1256
- messageEditorHeightLog
1257
- .info (' - Desired bottom sheet preview height: $_previewHeight ' );
1230
+ messageEditorHeightLog.info (' - Desired bottom sheet preview height: $_previewHeight ' );
1258
1231
1259
1232
// We want to be a specific height. Get as close as we can.
1260
1233
final constrainedHeight = constraints.constrainDimensions (
1261
1234
double .infinity,
1262
1235
_previewHeight,
1263
1236
);
1264
1237
1265
- messageEditorHeightLog.info (
1266
- ' - Constrained bottom sheet preview height: $constrainedHeight ' );
1238
+ messageEditorHeightLog.info (' - Constrained bottom sheet preview height: $constrainedHeight ' );
1267
1239
return constrainedHeight;
1268
1240
case BottomSheetMode .dragging:
1269
1241
case BottomSheetMode .settling:
@@ -1283,8 +1255,7 @@ class RenderMessageEditorHeight extends RenderBox
1283
1255
messageEditorHeightLog.info (' - Constraints: $constraints ' );
1284
1256
1285
1257
final ancestorChatScaffold = _findAncestorMessagePageScaffold ();
1286
- messageEditorHeightLog
1287
- .info (' - Ancestor chat scaffold: $ancestorChatScaffold ' );
1258
+ messageEditorHeightLog.info (' - Ancestor chat scaffold: $ancestorChatScaffold ' );
1288
1259
1289
1260
final heightMode = ancestorChatScaffold? .bottomSheetMode;
1290
1261
if (heightMode == null ) {
@@ -1303,8 +1274,7 @@ class RenderMessageEditorHeight extends RenderBox
1303
1274
switch (heightMode) {
1304
1275
case BottomSheetMode .preview:
1305
1276
// Preview mode imposes a specific height on the bottom sheet.
1306
- messageEditorHeightLog
1307
- .info (' - Forcing bottom sheet to preview height: $_previewHeight ' );
1277
+ messageEditorHeightLog.info (' - Forcing bottom sheet to preview height: $_previewHeight ' );
1308
1278
1309
1279
// We want to be a specific height. Get as close as we can.
1310
1280
size = constraints.constrainDimensions (
@@ -1316,7 +1286,8 @@ class RenderMessageEditorHeight extends RenderBox
1316
1286
);
1317
1287
child? .layout (
1318
1288
constraints.copyWith (
1319
- minHeight: size.height - 1 ,
1289
+ minHeight: max (size.height - 1 , 0 ),
1290
+ // ^ prevent layout boundary
1320
1291
maxHeight: size.height,
1321
1292
),
1322
1293
parentUsesSize: true ,
@@ -1331,11 +1302,9 @@ class RenderMessageEditorHeight extends RenderBox
1331
1302
case BottomSheetMode .expanded:
1332
1303
// Whether dragging, animating, or fully expanded, these conditions
1333
1304
// want to stipulate exactly how tall the bottom sheet should be.
1334
- messageEditorHeightLog
1335
- .info (' - Mode $heightMode - Filling available height' );
1305
+ messageEditorHeightLog.info (' - Mode $heightMode - Filling available height' );
1336
1306
if (! constraints.hasBoundedHeight) {
1337
- messageEditorHeightLog
1338
- .info (' - No bounded height was provided. Deferring to child' );
1307
+ messageEditorHeightLog.info (' - No bounded height was provided. Deferring to child' );
1339
1308
size = _doIntrinsicLayout (constraints);
1340
1309
messageEditorHeightLog.info (' - Our reported size: $size ' );
1341
1310
return ;
@@ -1348,7 +1317,7 @@ class RenderMessageEditorHeight extends RenderBox
1348
1317
size = constraints.biggest;
1349
1318
child? .layout (
1350
1319
constraints.copyWith (
1351
- minHeight: size.height - 1 ,
1320
+ minHeight: max ( size.height - 1 , 0 ) ,
1352
1321
// ^ Prevent a layout boundary.
1353
1322
maxHeight: size.height,
1354
1323
),
@@ -1369,8 +1338,7 @@ class RenderMessageEditorHeight extends RenderBox
1369
1338
BoxConstraints constraints, {
1370
1339
bool doDryLayout = false ,
1371
1340
}) {
1372
- messageEditorHeightLog
1373
- .info (' - Measuring child intrinsic height. Constraints: $constraints ' );
1341
+ messageEditorHeightLog.info (' - Measuring child intrinsic height. Constraints: $constraints ' );
1374
1342
1375
1343
final child = this .child;
1376
1344
if (child == null ) {
@@ -1391,8 +1359,7 @@ class RenderMessageEditorHeight extends RenderBox
1391
1359
intrinsicSize = child.size;
1392
1360
}
1393
1361
1394
- messageEditorHeightLog
1395
- .info (' - Child intrinsic height: ${intrinsicSize .height }' );
1362
+ messageEditorHeightLog.info (' - Child intrinsic height: ${intrinsicSize .height }' );
1396
1363
return constraints.constrain (intrinsicSize);
1397
1364
}
1398
1365
0 commit comments