pathEntitySelector method

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

Path entity select widget builder. 路径选择部件构建

Implementation

@override
Widget pathEntitySelector(BuildContext context) {
  Widget pathText(
    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: MediaQuery.sizeOf(context).width * 0.5,
        ),
        padding: const EdgeInsetsDirectional.only(start: 12, end: 6),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(999),
          color: theme.focusColor,
        ),
        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)
                  pathText(
                    context,
                    textDelegate.changeAccessibleLimitedAssets,
                    semanticsTextDelegate.changeAccessibleLimitedAssets,
                  ),
                if (path != null)
                  pathText(
                    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,
                ),
              ),
            ),
          ),
        ),
      ),
    ),
  );
}