Skip to content

Commit 40cb7cf

Browse files
committed
🔥 Remove Screens
1 parent 97a953a commit 40cb7cf

File tree

5 files changed

+44
-103
lines changed

5 files changed

+44
-103
lines changed

lib/src/constants/constants.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export 'colors.dart';
3535
export 'custom_scroll_physics.dart';
3636
export 'enums.dart';
3737
export 'extensions.dart';
38-
export 'screens.dart';
3938

4039
class Constants {
4140
const Constants._();

lib/src/constants/screens.dart

Lines changed: 0 additions & 64 deletions
This file was deleted.

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ abstract class AssetPickerBuilderDelegate<A, P> {
264264
},
265265
child: PlatformProgressIndicator(
266266
color: theme.iconTheme.color,
267-
size: Screens.width / gridCount / 3,
267+
size: context.mediaQuery.size.width / gridCount / 3,
268268
),
269269
),
270270
);
@@ -388,7 +388,7 @@ abstract class AssetPickerBuilderDelegate<A, P> {
388388
Widget child = Container(
389389
height: bottomActionBarHeight + context.bottomPadding,
390390
padding: const EdgeInsets.symmetric(horizontal: 20).copyWith(
391-
bottom: Screens.bottomSafeHeight,
391+
bottom: context.bottomPadding,
392392
),
393393
color: theme.primaryColor.withOpacity(isAppleOS ? 0.90 : 1.0),
394394
child: Row(children: <Widget>[
@@ -787,7 +787,7 @@ class DefaultAssetPickerBuilderDelegate
787787
// [gridCount] since every grid item is squeezed by the [itemSpacing],
788788
// and it's actual size is reduced with [itemSpacing / gridCount].
789789
final double dividedSpacing = itemSpacing / gridCount;
790-
final double topPadding = context.mediaQuery.padding.top + kToolbarHeight;
790+
final double topPadding = context.topPadding + kToolbarHeight;
791791

792792
Widget _sliverGrid(BuildContext ctx, List<AssetEntity> assets) {
793793
return SliverGrid(
@@ -860,15 +860,11 @@ class DefaultAssetPickerBuilderDelegate
860860
center: isAppleOS ? gridRevertKey : null,
861861
slivers: <Widget>[
862862
if (isAppleOS)
863-
SliverGap.v(
864-
context.mediaQuery.padding.top + kToolbarHeight,
865-
),
863+
SliverGap.v(context.topPadding + kToolbarHeight),
866864
_sliverGrid(_, assets),
867865
// Ignore the gap when the [anchor] is not equal to 1.
868866
if (isAppleOS && anchor == 1)
869-
SliverGap.v(
870-
context.mediaQuery.padding.bottom + bottomSectionHeight,
871-
),
867+
SliverGap.v(context.bottomPadding + bottomSectionHeight),
872868
if (isAppleOS)
873869
SliverToBoxAdapter(
874870
key: gridRevertKey,
@@ -1164,7 +1160,7 @@ class DefaultAssetPickerBuilderDelegate
11641160
}
11651161
return PlatformProgressIndicator(
11661162
color: theme.iconTheme.color,
1167-
size: Screens.width / gridCount / 3,
1163+
size: context.mediaQuery.size.width / gridCount / 3,
11681164
);
11691165
},
11701166
),
@@ -1198,7 +1194,7 @@ class DefaultAssetPickerBuilderDelegate
11981194
@override
11991195
Widget pathEntityListWidget(BuildContext context) {
12001196
return Positioned.fill(
1201-
top: isAppleOS ? context.mediaQuery.padding.top + kToolbarHeight : 0,
1197+
top: isAppleOS ? context.topPadding + kToolbarHeight : 0,
12021198
bottom: null,
12031199
child: Selector<DefaultAssetPickerProvider, bool>(
12041200
selector: (_, DefaultAssetPickerProvider p) => p.isSwitchingPath,
@@ -1212,7 +1208,7 @@ class DefaultAssetPickerBuilderDelegate
12121208
curve: switchingPathCurve,
12131209
opacity: !isAppleOS || isSwitchingPath ? 1.0 : 0.0,
12141210
child: Container(
1215-
height: Screens.height * 0.8,
1211+
height: context.mediaQuery.size.height * (isAppleOS ? .6 : .8),
12161212
decoration: BoxDecoration(
12171213
borderRadius: isAppleOS
12181214
? const BorderRadius.vertical(bottom: Radius.circular(10.0))
@@ -1227,23 +1223,30 @@ class DefaultAssetPickerBuilderDelegate
12271223
children: <Widget>[
12281224
ValueListenableBuilder<PermissionState>(
12291225
valueListenable: permission,
1230-
builder: (_, PermissionState ps, __) {
1226+
builder: (_, PermissionState ps, Widget? child) {
12311227
if (isPermissionLimited) {
1232-
return Padding(
1233-
padding: const EdgeInsets.symmetric(
1234-
horizontal: 20,
1235-
vertical: 12,
1236-
),
1237-
child: Text(
1238-
Constants.textDelegate.viewingLimitedAssetsTip,
1239-
style: context.themeData.textTheme.caption?.copyWith(
1240-
fontSize: 15,
1241-
),
1242-
),
1243-
);
1228+
return child!;
12441229
}
12451230
return const SizedBox.shrink();
12461231
},
1232+
child: Padding(
1233+
padding: const EdgeInsets.symmetric(
1234+
horizontal: 20,
1235+
vertical: 12,
1236+
),
1237+
child: Text.rich(
1238+
TextSpan(
1239+
children: <TextSpan>[
1240+
TextSpan(
1241+
text: Constants.textDelegate.viewingLimitedAssetsTip,
1242+
),
1243+
],
1244+
),
1245+
style: context.themeData.textTheme.caption?.copyWith(
1246+
fontSize: 15,
1247+
),
1248+
),
1249+
),
12471250
),
12481251
Expanded(
12491252
child: Selector<DefaultAssetPickerProvider, int>(
@@ -1290,7 +1293,9 @@ class DefaultAssetPickerBuilderDelegate
12901293
onTap: () => provider.isSwitchingPath = !provider.isSwitchingPath,
12911294
child: Container(
12921295
height: appBarItemHeight,
1293-
constraints: BoxConstraints(maxWidth: Screens.width * 0.5),
1296+
constraints: BoxConstraints(
1297+
maxWidth: context.mediaQuery.size.width * 0.5,
1298+
),
12941299
padding: const EdgeInsetsDirectional.only(start: 12.0, end: 6.0),
12951300
decoration: BoxDecoration(
12961301
borderRadius: BorderRadius.circular(999),
@@ -1514,7 +1519,8 @@ class DefaultAssetPickerBuilderDelegate
15141519
(DefaultAssetPickerProvider p) => p.selectedAssets,
15151520
);
15161521
final bool selected = selectedAssets.contains(asset);
1517-
final double indicatorSize = Screens.width / gridCount / 3;
1522+
final double indicatorSize =
1523+
context.mediaQuery.size.width / gridCount / 3;
15181524
final Widget innerSelector = AnimatedContainer(
15191525
duration: switchingPathDuration,
15201526
width: indicatorSize / (isAppleOS ? 1.25 : 1.5),
@@ -1562,7 +1568,7 @@ class DefaultAssetPickerBuilderDelegate
15621568
},
15631569
child: Container(
15641570
margin: EdgeInsets.all(
1565-
Screens.width / gridCount / (isAppleOS ? 12.0 : 15.0),
1571+
context.mediaQuery.size.width / gridCount / (isAppleOS ? 12 : 15),
15661572
),
15671573
width: isPreviewEnabled ? indicatorSize : null,
15681574
height: isPreviewEnabled ? indicatorSize : null,

lib/src/delegates/asset_picker_viewer_builder_delegate.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ class DefaultAssetPickerViewerBuilderDelegate
408408
Widget momentVideoBackButton(BuildContext context) {
409409
return PositionedDirectional(
410410
start: 16,
411-
top: context.mediaQuery.padding.top + 16,
411+
top: context.topPadding + 16,
412412
child: GestureDetector(
413413
onTap: Navigator.of(context).maybePop,
414414
child: Container(
@@ -436,14 +436,14 @@ class DefaultAssetPickerViewerBuilderDelegate
436436
builder: (_, bool v, __, Widget? child) => AnimatedPositionedDirectional(
437437
duration: kThemeAnimationDuration,
438438
curve: Curves.easeInOut,
439-
bottom: v ? 0 : -(Screens.bottomSafeHeight + bottomDetailHeight),
439+
bottom: v ? 0 : -(context.bottomPadding + bottomDetailHeight),
440440
start: 0,
441441
end: 0,
442-
height: Screens.bottomSafeHeight + bottomDetailHeight,
442+
height: context.bottomPadding + bottomDetailHeight,
443443
child: child!,
444444
),
445445
child: Padding(
446-
padding: EdgeInsetsDirectional.only(bottom: Screens.bottomSafeHeight),
446+
padding: EdgeInsetsDirectional.only(bottom: context.bottomPadding),
447447
child: ChangeNotifierProvider<
448448
AssetPickerViewerProvider<AssetEntity>?>.value(
449449
value: provider,
@@ -575,14 +575,14 @@ class DefaultAssetPickerViewerBuilderDelegate
575575
builder: (_, bool value, Widget? child) => AnimatedPositionedDirectional(
576576
duration: kThemeAnimationDuration,
577577
curve: Curves.easeInOut,
578-
top: value ? 0.0 : -(Screens.topSafeHeight + kToolbarHeight),
578+
top: value ? 0.0 : -(context.topPadding + kToolbarHeight),
579579
start: 0.0,
580580
end: 0.0,
581-
height: Screens.topSafeHeight + kToolbarHeight,
581+
height: context.topPadding + kToolbarHeight,
582582
child: child!,
583583
),
584584
child: Container(
585-
padding: EdgeInsetsDirectional.only(top: Screens.topSafeHeight),
585+
padding: EdgeInsetsDirectional.only(top: context.topPadding),
586586
color: themeData.canvasColor,
587587
child: Stack(
588588
fit: StackFit.expand,
@@ -822,7 +822,7 @@ class DefaultAssetPickerViewerBuilderDelegate
822822
momentVideoBackButton(context),
823823
PositionedDirectional(
824824
end: 16,
825-
bottom: context.mediaQuery.padding.bottom + 16,
825+
bottom: context.bottomPadding + 16,
826826
child: confirmButton(context),
827827
),
828828
] else ...<Widget>[

lib/src/widget/fixed_appbar.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class FixedAppBar extends StatelessWidget implements PreferredSizeWidget {
7474
double get _effectiveHeight => height ?? kToolbarHeight;
7575

7676
@override
77-
Size get preferredSize => Size(Screens.width, _effectiveHeight);
77+
Size get preferredSize => Size.fromHeight(_effectiveHeight);
7878

7979
@override
8080
Widget build(BuildContext context) {
@@ -87,7 +87,7 @@ class FixedAppBar extends StatelessWidget implements PreferredSizeWidget {
8787
}
8888

8989
Widget child = Container(
90-
width: Screens.width,
90+
width: double.maxFinite,
9191
height: (height ?? kToolbarHeight) + MediaQuery.of(context).padding.top,
9292
padding: EdgeInsetsDirectional.only(
9393
top: MediaQuery.of(context).padding.top,

0 commit comments

Comments
 (0)