pathEntitySelector method

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

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

Implementation

@override
Widget pathEntitySelector(BuildContext context) {
  return UnconstrainedBox(
    child: GestureDetector(
      onTap: () => provider.isSwitchingPath = !provider.isSwitchingPath,
      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.currentPathEntity,
          builder: (_, AssetPathEntity? p, Widget? w) => Row(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              if (p != null)
                Flexible(
                  child: ScaleText(
                    isPermissionLimited && p.isAll
                        ? Constants.textDelegate.accessiblePathName
                        : p.name,
                    style: const TextStyle(
                      fontSize: 17,
                      fontWeight: FontWeight.normal,
                    ),
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    maxScaleFactor: 1.2,
                  ),
                ),
              w!,
            ],
          ),
          child: Padding(
            padding: const EdgeInsetsDirectional.only(start: 5),
            child: DecoratedBox(
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                color: theme.iconTheme.color!.withOpacity(0.5),
              ),
              child: Selector<DefaultAssetPickerProvider, bool>(
                selector: (_, DefaultAssetPickerProvider p) =>
                    p.isSwitchingPath,
                builder: (_, bool isSwitchingPath, Widget? w) =>
                    Transform.rotate(
                  angle: isSwitchingPath ? math.pi : 0,
                  alignment: Alignment.center,
                  child: w,
                ),
                child: Icon(
                  Icons.keyboard_arrow_down,
                  size: 20,
                  color: theme.colorScheme.primary,
                ),
              ),
            ),
          ),
        ),
      ),
    ),
  );
}