Skip to content

Commit 31a6a91

Browse files
committed
✨ Add backdrop widget in the picker.
1 parent 6ddbfa4 commit 31a6a91

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

lib/src/widget/asset_picker.dart

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,41 @@ class AssetPicker extends StatelessWidget {
454454
);
455455
}
456456

457+
/// A backdrop widget behind the [pathEntityListWidget].
458+
/// 在 [pathEntityListWidget] 后面的遮罩层
459+
///
460+
/// While the picker is switching path, this will displayed.
461+
/// If the user tapped on it, it'll collapse the list widget.
462+
///
463+
/// 当选择器正在选择路径时,它会出现。用户点击它时,列表会折叠收起。
464+
Widget get pathEntityListBackdrop {
465+
return Selector<AssetPickerProvider, bool>(
466+
selector: (BuildContext _, AssetPickerProvider provider) =>
467+
provider.isSwitchingPath,
468+
builder: (BuildContext _, bool isSwitchingPath, Widget __) {
469+
return IgnorePointer(
470+
ignoring: !isSwitchingPath,
471+
child: GestureDetector(
472+
onTap: () {
473+
_.read<AssetPickerProvider>().isSwitchingPath = false;
474+
},
475+
child: AnimatedOpacity(
476+
duration: switchingPathDuration,
477+
opacity: isSwitchingPath ? 1.0 : 0.0,
478+
child: Container(color: Colors.black.withOpacity(0.75)),
479+
),
480+
),
481+
);
482+
},
483+
);
484+
}
485+
457486
/// List widget for path entities.
458487
/// 路径选择列表组件
459488
Widget get pathEntityListWidget {
460489
final double appBarHeight = kToolbarHeight + Screens.topSafeHeight;
461490
final double maxHeight =
462-
isAppleOS ? Screens.height - appBarHeight : Screens.height * 0.75;
491+
isAppleOS ? Screens.height - appBarHeight : Screens.height * 0.825;
463492
return Selector<AssetPickerProvider, bool>(
464493
selector: (BuildContext _, AssetPickerProvider provider) =>
465494
provider.isSwitchingPath,
@@ -1273,6 +1302,7 @@ class AssetPicker extends StatelessWidget {
12731302
],
12741303
),
12751304
),
1305+
pathEntityListBackdrop,
12761306
pathEntityListWidget,
12771307
],
12781308
)

0 commit comments

Comments
 (0)