pathEntitySelector method
Path entity select widget builder. 路径选择部件构建
Implementation
@override
Widget pathEntitySelector(BuildContext context) {
Widget _text(
BuildContext context,
String text,
String semanticsText,
) {
return Flexible(
child: ScaleText(
text,
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.normal,
),
maxLines: 1,
overflow: TextOverflow.fade,
maxScaleFactor: 1.2,
semanticsLabel: semanticsText,
),
);
}
return UnconstrainedBox(
child: GestureDetector(
onTap: () {
if (provider.currentPath == null) {
return;
}
Feedback.forTap(context);
if (isPermissionLimited && provider.isAssetsEmpty) {
PhotoManager.presentLimited();
return;
}
isSwitchingPath.value = !isSwitchingPath.value;
},
child: Container(
height: appBarItemHeight,
constraints: BoxConstraints(
maxWidth: context.mediaQuery.size.width * 0.5,
),
padding: const EdgeInsetsDirectional.only(start: 12, end: 6),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(999),
color: theme.dividerColor,
),
child: Selector<DefaultAssetPickerProvider, AssetPathEntity?>(
selector: (_, DefaultAssetPickerProvider p) => p.currentPath,
builder: (_, AssetPathEntity? p, Widget? w) => Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
if (p == null && isPermissionLimited)
_text(
context,
textDelegate.changeAccessibleLimitedAssets,
semanticsTextDelegate.changeAccessibleLimitedAssets,
),
if (p != null)
_text(
context,
isPermissionLimited && p.isAll
? textDelegate.accessiblePathName
: pathNameBuilder?.call(p) ?? p.name,
isPermissionLimited && p.isAll
? semanticsTextDelegate.accessiblePathName
: pathNameBuilder?.call(p) ?? p.name,
),
w!,
],
),
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 5),
child: DecoratedBox(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: theme.iconTheme.color!.withOpacity(0.5),
),
child: ValueListenableBuilder<bool>(
valueListenable: isSwitchingPath,
builder: (_, bool isSwitchingPath, Widget? w) {
return Transform.rotate(
angle: isSwitchingPath ? math.pi : 0,
child: w,
);
},
child: Icon(
Icons.keyboard_arrow_down,
size: 20,
color: theme.colorScheme.primary,
),
),
),
),
),
),
),
);
}