Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ec138c5

Browse files
committed
Rename WindowPadding to ViewPadding
1 parent 2fdce9a commit ec138c5

File tree

11 files changed

+70
-64
lines changed

11 files changed

+70
-64
lines changed

lib/ui/fixtures/ui_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ void hooksTests() async {
534534
expectEquals(x.countryCode, y.countryCode);
535535
});
536536

537-
await test('Window padding/insets/viewPadding/systemGestureInsets', () {
537+
await test('View padding/insets/viewPadding/systemGestureInsets', () {
538538
_callHook(
539539
'_updateWindowMetrics',
540540
20,

lib/ui/platform_dispatcher.dart

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -258,25 +258,25 @@ class PlatformDispatcher {
258258
view: _views[id],
259259
devicePixelRatio: devicePixelRatio,
260260
geometry: Rect.fromLTWH(0.0, 0.0, width, height),
261-
viewPadding: WindowPadding._(
261+
viewPadding: ViewPadding._(
262262
top: viewPaddingTop,
263263
right: viewPaddingRight,
264264
bottom: viewPaddingBottom,
265265
left: viewPaddingLeft,
266266
),
267-
viewInsets: WindowPadding._(
267+
viewInsets: ViewPadding._(
268268
top: viewInsetTop,
269269
right: viewInsetRight,
270270
bottom: viewInsetBottom,
271271
left: viewInsetLeft,
272272
),
273-
padding: WindowPadding._(
273+
padding: ViewPadding._(
274274
top: math.max(0.0, viewPaddingTop - viewInsetTop),
275275
right: math.max(0.0, viewPaddingRight - viewInsetRight),
276276
bottom: math.max(0.0, viewPaddingBottom - viewInsetBottom),
277277
left: math.max(0.0, viewPaddingLeft - viewInsetLeft),
278278
),
279-
systemGestureInsets: WindowPadding._(
279+
systemGestureInsets: ViewPadding._(
280280
top: math.max(0.0, systemGestureInsetTop),
281281
right: math.max(0.0, systemGestureInsetRight),
282282
bottom: math.max(0.0, systemGestureInsetBottom),
@@ -1335,10 +1335,10 @@ class ViewConfiguration {
13351335
this.devicePixelRatio = 1.0,
13361336
this.geometry = Rect.zero,
13371337
this.visible = false,
1338-
this.viewInsets = WindowPadding.zero,
1339-
this.viewPadding = WindowPadding.zero,
1340-
this.systemGestureInsets = WindowPadding.zero,
1341-
this.padding = WindowPadding.zero,
1338+
this.viewInsets = ViewPadding.zero,
1339+
this.viewPadding = ViewPadding.zero,
1340+
this.systemGestureInsets = ViewPadding.zero,
1341+
this.padding = ViewPadding.zero,
13421342
this.gestureSettings = const GestureSettings(),
13431343
this.displayFeatures = const <DisplayFeature>[],
13441344
}) : assert(window == null || view == null),
@@ -1356,10 +1356,10 @@ class ViewConfiguration {
13561356
double? devicePixelRatio,
13571357
Rect? geometry,
13581358
bool? visible,
1359-
WindowPadding? viewInsets,
1360-
WindowPadding? viewPadding,
1361-
WindowPadding? systemGestureInsets,
1362-
WindowPadding? padding,
1359+
ViewPadding? viewInsets,
1360+
ViewPadding? viewPadding,
1361+
ViewPadding? systemGestureInsets,
1362+
ViewPadding? padding,
13631363
GestureSettings? gestureSettings,
13641364
List<DisplayFeature>? displayFeatures,
13651365
}) {
@@ -1410,53 +1410,53 @@ class ViewConfiguration {
14101410
///
14111411
/// For instance, if the view doesn't overlap the
14121412
/// [ScreenConfiguration.viewInsets] area, [viewInsets] will be
1413-
/// [WindowPadding.zero].
1413+
/// [ViewPadding.zero].
14141414
///
14151415
/// The number of physical pixels on each side of this view rectangle into
14161416
/// which the application can draw, but over which the operating system will
14171417
/// likely place system UI, such as the keyboard or system menus, that fully
14181418
/// obscures any content.
1419-
final WindowPadding viewInsets;
1419+
final ViewPadding viewInsets;
14201420

14211421
/// The view insets, as it intersects with [ScreenConfiguration.viewPadding]
14221422
/// for the screen it is on.
14231423
///
14241424
/// For instance, if the view doesn't overlap the
14251425
/// [ScreenConfiguration.viewPadding] area, [viewPadding] will be
1426-
/// [WindowPadding.zero].
1426+
/// [ViewPadding.zero].
14271427
///
14281428
/// The number of physical pixels on each side of this screen rectangle into
14291429
/// which the application can place a view, but which may be partially
14301430
/// obscured by system UI (such as the system notification area), or physical
14311431
/// intrusions in the display (e.g. overscan regions on television screens or
14321432
/// phone sensor housings).
1433-
final WindowPadding viewPadding;
1433+
final ViewPadding viewPadding;
14341434

14351435
/// The view insets, as it intersects with
14361436
/// [ScreenConfiguration.systemGestureInsets] for the screen it is on.
14371437
///
14381438
/// For instance, if the view doesn't overlap the
14391439
/// [ScreenConfiguration.systemGestureInsets] area, [systemGestureInsets] will
1440-
/// be [WindowPadding.zero].
1440+
/// be [ViewPadding.zero].
14411441
///
14421442
/// The number of physical pixels on each side of this screen rectangle into
14431443
/// which the application can place a view, but where the operating system
14441444
/// will consume input gestures for the sake of system navigation.
1445-
final WindowPadding systemGestureInsets;
1445+
final ViewPadding systemGestureInsets;
14461446

14471447
/// The view insets, as it intersects with [ScreenConfiguration.padding] for
14481448
/// the screen it is on.
14491449
///
14501450
/// For instance, if the view doesn't overlap the
14511451
/// [ScreenConfiguration.padding] area, [padding] will be
1452-
/// [WindowPadding.zero].
1452+
/// [ViewPadding.zero].
14531453
///
14541454
/// The number of physical pixels on each side of this screen rectangle into
14551455
/// which the application can place a view, but which may be partially
14561456
/// obscured by system UI (such as the system notification area), or physical
14571457
/// intrusions in the display (e.g. overscan regions on television screens or
14581458
/// phone sensor housings).
1459-
final WindowPadding padding;
1459+
final ViewPadding padding;
14601460

14611461
/// Additional configuration for touch gestures performed on this view.
14621462
///
@@ -1765,8 +1765,8 @@ enum AppLifecycleState {
17651765
/// * [MediaQuery.of], for the preferred mechanism for accessing these values.
17661766
/// * [Scaffold], which automatically applies the padding in material design
17671767
/// applications.
1768-
class WindowPadding {
1769-
const WindowPadding._({ required this.left, required this.top, required this.right, required this.bottom });
1768+
class ViewPadding {
1769+
const ViewPadding._({ required this.left, required this.top, required this.right, required this.bottom });
17701770

17711771
/// The distance from the left edge to the first unpadded pixel, in physical pixels.
17721772
final double left;
@@ -1780,15 +1780,21 @@ class WindowPadding {
17801780
/// The distance from the bottom edge to the first unpadded pixel, in physical pixels.
17811781
final double bottom;
17821782

1783-
/// A window padding that has zeros for each edge.
1784-
static const WindowPadding zero = WindowPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0);
1783+
/// A view padding that has zeros for each edge.
1784+
static const ViewPadding zero = ViewPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0);
17851785

17861786
@override
17871787
String toString() {
1788-
return 'WindowPadding(left: $left, top: $top, right: $right, bottom: $bottom)';
1788+
return 'ViewPadding(left: $left, top: $top, right: $right, bottom: $bottom)';
17891789
}
17901790
}
17911791

1792+
/// Deprecated. Will be removed in a future version of Flutter.
1793+
///
1794+
/// Use [ViewPadding] instead.
1795+
// TODO(goderbauer): deprecate this when framework has been migrated to ViewPadding.
1796+
typedef WindowPadding = ViewPadding;
1797+
17921798
/// Area of the display that may be obstructed by a hardware feature.
17931799
///
17941800
/// This is populated only on Android.

lib/ui/window.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class FlutterView {
153153
/// * [MediaQuery.of], a simpler mechanism for the same.
154154
/// * [Scaffold], which automatically applies the view insets in material
155155
/// design applications.
156-
WindowPadding get viewInsets => viewConfiguration.viewInsets;
156+
ViewPadding get viewInsets => viewConfiguration.viewInsets;
157157

158158
/// The number of physical pixels on each side of the display rectangle into
159159
/// which the view can render, but which may be partially obscured by system
@@ -179,7 +179,7 @@ class FlutterView {
179179
/// * [MediaQuery.of], a simpler mechanism for the same.
180180
/// * [Scaffold], which automatically applies the padding in material design
181181
/// applications.
182-
WindowPadding get viewPadding => viewConfiguration.viewPadding;
182+
ViewPadding get viewPadding => viewConfiguration.viewPadding;
183183

184184
/// The number of physical pixels on each side of the display rectangle into
185185
/// which the view can render, but where the operating system will consume
@@ -196,7 +196,7 @@ class FlutterView {
196196
/// * [WidgetsBindingObserver], for a mechanism at the widgets layer to
197197
/// observe when this value changes.
198198
/// * [MediaQuery.of], a simpler mechanism for the same.
199-
WindowPadding get systemGestureInsets => viewConfiguration.systemGestureInsets;
199+
ViewPadding get systemGestureInsets => viewConfiguration.systemGestureInsets;
200200

201201
/// The number of physical pixels on each side of the display rectangle into
202202
/// which the view can render, but which may be partially obscured by system
@@ -224,7 +224,7 @@ class FlutterView {
224224
/// * [MediaQuery.of], a simpler mechanism for the same.
225225
/// * [Scaffold], which automatically applies the padding in material design
226226
/// applications.
227-
WindowPadding get padding => viewConfiguration.padding;
227+
ViewPadding get padding => viewConfiguration.padding;
228228

229229
/// {@macro dart.ui.ViewConfiguration.displayFeatures}
230230
///

lib/web_ui/lib/platform_dispatcher.dart

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ class ViewConfiguration {
202202
this.devicePixelRatio = 1.0,
203203
this.geometry = Rect.zero,
204204
this.visible = false,
205-
this.viewInsets = WindowPadding.zero,
206-
this.viewPadding = WindowPadding.zero,
207-
this.systemGestureInsets = WindowPadding.zero,
208-
this.padding = WindowPadding.zero,
205+
this.viewInsets = ViewPadding.zero,
206+
this.viewPadding = ViewPadding.zero,
207+
this.systemGestureInsets = ViewPadding.zero,
208+
this.padding = ViewPadding.zero,
209209
this.gestureSettings = const GestureSettings(),
210210
this.displayFeatures = const <DisplayFeature>[],
211211
}) : assert(window == null || view == null),
@@ -222,10 +222,10 @@ class ViewConfiguration {
222222
double? devicePixelRatio,
223223
Rect? geometry,
224224
bool? visible,
225-
WindowPadding? viewInsets,
226-
WindowPadding? viewPadding,
227-
WindowPadding? systemGestureInsets,
228-
WindowPadding? padding,
225+
ViewPadding? viewInsets,
226+
ViewPadding? viewPadding,
227+
ViewPadding? systemGestureInsets,
228+
ViewPadding? padding,
229229
GestureSettings? gestureSettings,
230230
List<DisplayFeature>? displayFeatures,
231231
}) {
@@ -255,10 +255,10 @@ class ViewConfiguration {
255255
final double devicePixelRatio;
256256
final Rect geometry;
257257
final bool visible;
258-
final WindowPadding viewInsets;
259-
final WindowPadding viewPadding;
260-
final WindowPadding systemGestureInsets;
261-
final WindowPadding padding;
258+
final ViewPadding viewInsets;
259+
final ViewPadding viewPadding;
260+
final ViewPadding systemGestureInsets;
261+
final ViewPadding padding;
262262
final GestureSettings gestureSettings;
263263
final List<DisplayFeature> displayFeatures;
264264

@@ -375,23 +375,23 @@ enum AppLifecycleState {
375375
detached,
376376
}
377377

378-
abstract class WindowPadding {
379-
const factory WindowPadding._(
378+
abstract class ViewPadding {
379+
const factory ViewPadding._(
380380
{required double left,
381381
required double top,
382382
required double right,
383-
required double bottom}) = engine.WindowPadding;
383+
required double bottom}) = engine.ViewPadding;
384384

385385
double get left;
386386
double get top;
387387
double get right;
388388
double get bottom;
389389

390-
static const WindowPadding zero = WindowPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0);
390+
static const ViewPadding zero = ViewPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0);
391391

392392
@override
393393
String toString() {
394-
return 'WindowPadding(left: $left, top: $top, right: $right, bottom: $bottom)';
394+
return 'ViewPadding(left: $left, top: $top, right: $right, bottom: $bottom)';
395395
}
396396
}
397397

lib/web_ui/lib/src/engine/view_embedder/dimensions_provider/custom_element_dimensions_provider.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ class CustomElementDimensionsProvider extends DimensionsProvider {
7474
}
7575

7676
@override
77-
WindowPadding computeKeyboardInsets(
77+
ViewPadding computeKeyboardInsets(
7878
double physicalHeight,
7979
bool isEditingOnMobile,
8080
) {
81-
return const WindowPadding(
81+
return const ViewPadding(
8282
top: 0,
8383
right: 0,
8484
bottom: 0,

lib/web_ui/lib/src/engine/view_embedder/dimensions_provider/dimensions_provider.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ abstract class DimensionsProvider {
4848
/// pending DOM writes.
4949
ui.Size computePhysicalSize();
5050

51-
/// Returns the [WindowPadding] of the keyboard insets (if present).
52-
WindowPadding computeKeyboardInsets(
51+
/// Returns the [ViewPadding] of the keyboard insets (if present).
52+
ViewPadding computeKeyboardInsets(
5353
double physicalHeight,
5454
bool isEditingOnMobile,
5555
);

lib/web_ui/lib/src/engine/view_embedder/dimensions_provider/full_page_dimensions_provider.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class FullPageDimensionsProvider extends DimensionsProvider {
9898
}
9999

100100
@override
101-
WindowPadding computeKeyboardInsets(
101+
ViewPadding computeKeyboardInsets(
102102
double physicalHeight,
103103
bool isEditingOnMobile,
104104
) {
@@ -118,6 +118,6 @@ class FullPageDimensionsProvider extends DimensionsProvider {
118118
}
119119
final double bottomPadding = physicalHeight - windowInnerHeight;
120120

121-
return WindowPadding(bottom: bottomPadding, left: 0, right: 0, top: 0);
121+
return ViewPadding(bottom: bottomPadding, left: 0, right: 0, top: 0);
122122
}
123123
}

lib/web_ui/lib/src/engine/window.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
296296
}
297297

298298
@override
299-
WindowPadding get viewInsets => _viewInsets;
300-
WindowPadding _viewInsets = ui.WindowPadding.zero as WindowPadding;
299+
ViewPadding get viewInsets => _viewInsets;
300+
ViewPadding _viewInsets = ui.ViewPadding.zero as ViewPadding;
301301

302302
/// Lazily populated and cleared at the end of the frame.
303303
ui.Size? _physicalSize;
@@ -351,9 +351,9 @@ class EngineSingletonFlutterWindow extends EngineFlutterWindow {
351351
final EngineSingletonFlutterWindow window =
352352
EngineSingletonFlutterWindow(kImplicitViewId, EnginePlatformDispatcher.instance);
353353

354-
/// The Web implementation of [ui.WindowPadding].
355-
class WindowPadding implements ui.WindowPadding {
356-
const WindowPadding({
354+
/// The Web implementation of [ui.ViewPadding].
355+
class ViewPadding implements ui.ViewPadding {
356+
const ViewPadding({
357357
required this.left,
358358
required this.top,
359359
required this.right,

lib/web_ui/lib/window.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ abstract class FlutterView {
1111
double get devicePixelRatio => viewConfiguration.devicePixelRatio;
1212
Rect get physicalGeometry => viewConfiguration.geometry;
1313
Size get physicalSize => viewConfiguration.geometry.size;
14-
WindowPadding get viewInsets => viewConfiguration.viewInsets;
15-
WindowPadding get viewPadding => viewConfiguration.viewPadding;
16-
WindowPadding get systemGestureInsets => viewConfiguration.systemGestureInsets;
17-
WindowPadding get padding => viewConfiguration.padding;
14+
ViewPadding get viewInsets => viewConfiguration.viewInsets;
15+
ViewPadding get viewPadding => viewConfiguration.viewPadding;
16+
ViewPadding get systemGestureInsets => viewConfiguration.systemGestureInsets;
17+
ViewPadding get padding => viewConfiguration.padding;
1818
List<DisplayFeature> get displayFeatures => viewConfiguration.displayFeatures;
1919
void render(Scene scene) => platformDispatcher.render(scene, this);
2020
void updateSemantics(SemanticsUpdate update) => platformDispatcher.updateSemantics(update);

lib/web_ui/test/engine/view_embedder/dimensions_provider/custom_element_dimensions_provider_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void doTests() {
7979
final double physicalHeight =
8080
(domWindow.visualViewport!.height! + keyboardGap) * dpr;
8181

82-
final WindowPadding computed =
82+
final ViewPadding computed =
8383
provider.computeKeyboardInsets(physicalHeight, false);
8484

8585
expect(computed.top, 0);

0 commit comments

Comments
 (0)