pathEntitySelector method

  1. @override
Widget pathEntitySelector(
  1. BuildContext context
)
override

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 (isPermissionLimited && provider.isAssetsEmpty) {
          PhotoManager.presentLimited();
          return;
        }
        if (provider.currentPath == null) {
          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,
            PathWrapper<AssetPathEntity>?>(
          selector: (_, DefaultAssetPickerProvider p) => p.currentPath,
          builder: (_, PathWrapper<AssetPathEntity>? p, Widget? w) {
            final AssetPathEntity? path = p?.path;
            return Row(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                if (path == null && isPermissionLimited)
                  _text(
                    context,
                    textDelegate.changeAccessibleLimitedAssets,
                    semanticsTextDelegate.changeAccessibleLimitedAssets,
                  ),
                if (path != null)
                  _text(
                    context,
                    isPermissionLimited && path.isAll
                        ? textDelegate.accessiblePathName
                        : pathNameBuilder?.call(path) ?? path.name,
                    isPermissionLimited && path.isAll
                        ? semanticsTextDelegate.accessiblePathName
                        : pathNameBuilder?.call(path) ?? path.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,
                ),
              ),
            ),
          ),
        ),
      ),
    ),
  );
}