addLegendOverlays method

void addLegendOverlays(
  1. Size size
)

TODO 需要重构,以提高代码复用率

needs to be refactored to improve code reuse

Implementation

void addLegendOverlays(Size size) {
  overlays.addEntry('legendOverlay', (_, game) {
    return Stack(
      children: [
        Positioned(
          left: 24,
          top: 32,
          bottom: 10,
          child: ListenableBuilder(
            listenable: algorithm.$size,
            builder: (context, child) {
              var leftOverlays = algorithm.leftOverlays(
                    world: world,
                    rootAlg: algorithm,
                    graphComponent: this,
                  ) ??
                  [];
              if (leftOverlays.isEmpty) {
                return const SizedBox.shrink();
              }
              return ColoredBox(
                color: Colors.grey.withOpacity(0.1),
                child: SingleChildScrollView(
                  scrollDirection: Axis.vertical,
                  child: Padding(
                    padding: const EdgeInsets.only(right: 16.0),
                    child: ClipRRect(
                      borderRadius: BorderRadius.circular(12),
                      child: Padding(
                        padding: const EdgeInsets.fromLTRB(16, 12, 0, 12),
                        child: Column(
                          mainAxisSize: MainAxisSize.min,
                          mainAxisAlignment: MainAxisAlignment.start,
                          children: leftOverlays,
                        ),
                      ),
                    ),
                  ),
                ),
              );
            },
          ),
        )
      ],
    );
  });
  if (!overlays.activeOverlays.contains('legendOverlay')) {
    overlays.add('legendOverlay');
  }
}