Skip to content

Commit 5adcda3

Browse files
authored
[compass_app] Don't expose Dimens subclasses (#2541)
Avoid exposing the subclasses as they shouldn't be instantiated again or overridden. Also consistently use fields and getters in the declarations.
1 parent 90cd385 commit 5adcda3

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

compass_app/app/lib/ui/core/themes/dimens.dart

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import 'package:flutter/material.dart';
66

7-
sealed class Dimens {
7+
abstract final class Dimens {
88
const Dimens();
99

1010
/// General horizontal padding used to separate UI items
@@ -14,10 +14,12 @@ sealed class Dimens {
1414
static const paddingVertical = 24.0;
1515

1616
/// Horizontal padding for screen edges
17-
abstract final double paddingScreenHorizontal;
17+
double get paddingScreenHorizontal;
1818

1919
/// Vertical padding for screen edges
20-
abstract final double paddingScreenVertical;
20+
double get paddingScreenVertical;
21+
22+
double get profilePictureSize;
2123

2224
/// Horizontal symmetric padding for screen edges
2325
EdgeInsets get edgeInsetsScreenHorizontal =>
@@ -27,39 +29,37 @@ sealed class Dimens {
2729
EdgeInsets get edgeInsetsScreenSymmetric => EdgeInsets.symmetric(
2830
horizontal: paddingScreenHorizontal, vertical: paddingScreenVertical);
2931

30-
static final dimensDesktop = DimensDesktop();
31-
static final dimensMobile = DimensMobile();
32+
static final Dimens desktop = _DimensDesktop();
33+
static final Dimens mobile = _DimensMobile();
3234

3335
/// Get dimensions definition based on screen size
3436
factory Dimens.of(BuildContext context) =>
3537
switch (MediaQuery.sizeOf(context).width) {
36-
> 600 => dimensDesktop,
37-
_ => dimensMobile,
38+
> 600 => desktop,
39+
_ => mobile,
3840
};
39-
40-
abstract final double profilePictureSize;
4141
}
4242

4343
/// Mobile dimensions
44-
class DimensMobile extends Dimens {
44+
final class _DimensMobile extends Dimens {
4545
@override
46-
double paddingScreenHorizontal = Dimens.paddingHorizontal;
46+
final double paddingScreenHorizontal = Dimens.paddingHorizontal;
4747

4848
@override
49-
double paddingScreenVertical = Dimens.paddingVertical;
49+
final double paddingScreenVertical = Dimens.paddingVertical;
5050

5151
@override
52-
double get profilePictureSize => 64.0;
52+
final double profilePictureSize = 64.0;
5353
}
5454

5555
/// Desktop/Web dimensions
56-
class DimensDesktop extends Dimens {
56+
final class _DimensDesktop extends Dimens {
5757
@override
58-
double paddingScreenHorizontal = 100.0;
58+
final double paddingScreenHorizontal = 100.0;
5959

6060
@override
61-
double paddingScreenVertical = 64.0;
61+
final double paddingScreenVertical = 64.0;
6262

6363
@override
64-
double get profilePictureSize => 128.0;
64+
final double profilePictureSize = 128.0;
6565
}

compass_app/app/lib/ui/results/widgets/results_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class _AppSearchBar extends StatelessWidget {
132132
child: Padding(
133133
padding: EdgeInsets.only(
134134
top: Dimens.of(context).paddingScreenVertical,
135-
bottom: Dimens.dimensMobile.paddingScreenVertical,
135+
bottom: Dimens.mobile.paddingScreenVertical,
136136
),
137137
child: AppSearchBar(
138138
config: widget.viewModel.config,

0 commit comments

Comments
 (0)