Skip to content

Commit 50b033c

Browse files
committed
⚡️ Enhance path entities list widget
1 parent 37e3139 commit 50b033c

File tree

1 file changed

+53
-57
lines changed

1 file changed

+53
-57
lines changed

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -910,80 +910,76 @@ class DefaultAssetPickerBuilderDelegate
910910
/// 当选择器正在选择路径时,它会出现。用户点击它时,列表会折叠收起。
911911
@override
912912
Widget pathEntityListBackdrop(BuildContext context) {
913-
return Selector<DefaultAssetPickerProvider, bool>(
914-
selector: (_, DefaultAssetPickerProvider p) => p.isSwitchingPath,
915-
builder: (BuildContext context, bool isSwitchingPath, __) {
916-
return IgnorePointer(
913+
return Positioned.fill(
914+
child: Selector<DefaultAssetPickerProvider, bool>(
915+
selector: (_, DefaultAssetPickerProvider p) => p.isSwitchingPath,
916+
builder: (_, bool isSwitchingPath, __) => IgnorePointer(
917917
ignoring: !isSwitchingPath,
918918
child: GestureDetector(
919919
onTap: () => provider.isSwitchingPath = false,
920920
child: AnimatedOpacity(
921921
duration: switchingPathDuration,
922-
opacity: isSwitchingPath ? 1.0 : 0.0,
923-
child: Container(color: Colors.black.withOpacity(0.75)),
922+
opacity: isSwitchingPath ? .75 : 0,
923+
child: const ColoredBox(color: Colors.black),
924924
),
925925
),
926-
);
927-
},
926+
),
927+
),
928928
);
929929
}
930930

931931
@override
932932
Widget pathEntityListWidget(BuildContext context) {
933-
final double appBarHeight = kToolbarHeight + Screens.topSafeHeight;
934-
final double maxHeight = Screens.height * 0.825;
935-
final bool isAudio = (provider as DefaultAssetPickerProvider).requestType ==
936-
RequestType.audio;
937-
return Selector<DefaultAssetPickerProvider, bool>(
938-
selector: (_, DefaultAssetPickerProvider p) => p.isSwitchingPath,
939-
builder: (_, bool isSwitchingPath, Widget? w) =>
940-
AnimatedPositionedDirectional(
941-
duration: switchingPathDuration,
942-
curve: switchingPathCurve,
943-
top: isAppleOS
944-
? !isSwitchingPath
945-
? -maxHeight
946-
: appBarHeight
947-
: -(!isSwitchingPath ? maxHeight : 1.0),
948-
child: AnimatedOpacity(
933+
return Positioned.fill(
934+
bottom: null,
935+
child: Selector<DefaultAssetPickerProvider, bool>(
936+
selector: (_, DefaultAssetPickerProvider p) => p.isSwitchingPath,
937+
builder: (_, bool isSwitchingPath, Widget? w) => AnimatedAlign(
949938
duration: switchingPathDuration,
950939
curve: switchingPathCurve,
951-
opacity: !isAppleOS || isSwitchingPath ? 1.0 : 0.0,
952-
child: Container(
953-
width: Screens.width,
954-
height: maxHeight,
955-
decoration: BoxDecoration(
956-
borderRadius: isAppleOS
957-
? const BorderRadius.vertical(bottom: Radius.circular(10.0))
958-
: null,
959-
color: theme.colorScheme.background,
940+
alignment: Alignment.bottomCenter,
941+
heightFactor: isSwitchingPath ? 1 : 0,
942+
child: AnimatedOpacity(
943+
duration: switchingPathDuration,
944+
curve: switchingPathCurve,
945+
opacity: !isAppleOS || isSwitchingPath ? 1.0 : 0.0,
946+
child: Container(
947+
height: Screens.height * 0.8,
948+
decoration: BoxDecoration(
949+
borderRadius: isAppleOS
950+
? const BorderRadius.vertical(bottom: Radius.circular(10.0))
951+
: null,
952+
color: theme.colorScheme.background,
953+
),
954+
child: w,
960955
),
961-
child: w,
962956
),
963957
),
964-
),
965-
child: Selector<DefaultAssetPickerProvider, int>(
966-
selector: (_, DefaultAssetPickerProvider p) => p.validPathThumbCount,
967-
builder: (_, int count, __) => Selector<DefaultAssetPickerProvider,
968-
Map<AssetPathEntity, Uint8List?>>(
969-
selector: (_, DefaultAssetPickerProvider p) => p.pathEntityList,
970-
builder: (BuildContext c, Map<AssetPathEntity, Uint8List?> list, __) {
971-
return ListView.separated(
972-
padding: const EdgeInsetsDirectional.only(top: 1.0),
973-
itemCount: list.length,
974-
itemBuilder: (_, int index) => pathEntityWidget(
975-
context: c,
976-
list: list,
977-
index: index,
978-
isAudio: isAudio,
979-
),
980-
separatorBuilder: (BuildContext _, int __) => Container(
981-
margin: const EdgeInsetsDirectional.only(start: 60.0),
982-
height: 1.0,
983-
color: theme.canvasColor,
984-
),
985-
);
986-
},
958+
child: Selector<DefaultAssetPickerProvider, int>(
959+
selector: (_, DefaultAssetPickerProvider p) => p.validPathThumbCount,
960+
builder: (_, int count, __) => Selector<DefaultAssetPickerProvider,
961+
Map<AssetPathEntity, Uint8List?>>(
962+
selector: (_, DefaultAssetPickerProvider p) => p.pathEntityList,
963+
builder: (_, Map<AssetPathEntity, Uint8List?> list, __) {
964+
return ListView.separated(
965+
padding: const EdgeInsetsDirectional.only(top: 1.0),
966+
itemCount: list.length,
967+
itemBuilder: (BuildContext c, int index) => pathEntityWidget(
968+
context: c,
969+
list: list,
970+
index: index,
971+
isAudio:
972+
(provider as DefaultAssetPickerProvider).requestType ==
973+
RequestType.audio,
974+
),
975+
separatorBuilder: (_, __) => Container(
976+
margin: const EdgeInsetsDirectional.only(start: 60.0),
977+
height: 1.0,
978+
color: theme.canvasColor,
979+
),
980+
);
981+
},
982+
),
987983
),
988984
),
989985
);

0 commit comments

Comments
 (0)