pathEntityWidget method
Widget
pathEntityWidget({
- required BuildContext context,
- required List<
PathWrapper< list,AssetPathEntity> > - required int index,
override
Item widgets for path entity selector. 路径单独条目选择组件
Implementation
@override
Widget pathEntityWidget({
required BuildContext context,
required List<PathWrapper<AssetPathEntity>> list,
required int index,
}) {
final PathWrapper<AssetPathEntity> wrapper = list[index];
final AssetPathEntity pathEntity = wrapper.path;
final typed_data.Uint8List? data = wrapper.thumbnailData;
Widget builder() {
if (data != null) {
return Image.memory(data, fit: BoxFit.cover);
}
if (pathEntity.type.containsAudio()) {
return ColoredBox(
color: theme.colorScheme.primary.withOpacity(0.12),
child: const Center(child: Icon(Icons.audiotrack)),
);
}
return ColoredBox(color: theme.colorScheme.primary.withOpacity(0.12));
}
final String pathName =
pathNameBuilder?.call(pathEntity) ?? pathEntity.name;
final String name = isPermissionLimited && pathEntity.isAll
? textDelegate.accessiblePathName
: pathName;
final String semanticsName = isPermissionLimited && pathEntity.isAll
? semanticsTextDelegate.accessiblePathName
: pathName;
final String? semanticsCount = wrapper.assetCount?.toString();
final StringBuffer labelBuffer = StringBuffer(
'$semanticsName, ${semanticsTextDelegate.sUnitAssetCountLabel}',
);
if (semanticsCount != null) {
labelBuffer.write(': $semanticsCount');
}
return Selector<DefaultAssetPickerProvider, PathWrapper<AssetPathEntity>?>(
selector: (_, DefaultAssetPickerProvider p) => p.currentPath,
builder: (_, PathWrapper<AssetPathEntity>? currentWrapper, __) {
final bool isSelected = currentWrapper?.path == pathEntity;
return Semantics(
label: labelBuffer.toString(),
selected: isSelected,
onTapHint: semanticsTextDelegate.sActionSwitchPathLabel,
button: false,
child: Material(
type: MaterialType.transparency,
child: InkWell(
splashFactory: InkSplash.splashFactory,
onTap: () {
Feedback.forTap(context);
context.read<DefaultAssetPickerProvider>().switchPath(wrapper);
isSwitchingPath.value = false;
gridScrollController.jumpTo(0);
},
child: SizedBox(
height: isAppleOS ? 64 : 52,
child: Row(
children: <Widget>[
RepaintBoundary(
child: AspectRatio(aspectRatio: 1, child: builder()),
),
Expanded(
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: 15,
end: 20,
),
child: ExcludeSemantics(
child: Row(
children: <Widget>[
Flexible(
child: Padding(
padding: const EdgeInsetsDirectional.only(
end: 10,
),
child: ScaleText(
name,
style: const TextStyle(fontSize: 17),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
if (semanticsCount != null)
ScaleText(
'($semanticsCount)',
style: TextStyle(
color: theme.textTheme.bodySmall?.color,
fontSize: 17,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
),
),
if (isSelected)
AspectRatio(
aspectRatio: 1,
child: Icon(Icons.check, color: themeColor, size: 26),
),
],
),
),
),
),
);
},
);
}