AwesomeAspectRatioButton constructor

AwesomeAspectRatioButton({
  1. Key? key,
  2. required PhotoCameraState state,
  3. AwesomeTheme? theme,
  4. Widget iconBuilder(
    1. CameraAspectRatios aspectRatio
    )?,
  5. void onAspectRatioTap(
    1. SensorConfig sensorConfig,
    2. CameraAspectRatios aspectRatio
    )?,
})

Implementation

AwesomeAspectRatioButton({
  super.key,
  required this.state,
  this.theme,
  Widget Function(CameraAspectRatios aspectRatio)? iconBuilder,
  void Function(SensorConfig sensorConfig, CameraAspectRatios aspectRatio)? onAspectRatioTap,
})  : iconBuilder = iconBuilder ??
          ((aspectRatio) {
            final AssetImage icon;
            double width;
            switch (aspectRatio) {
              case CameraAspectRatios.ratio_16_9:
                width = 32;
                icon = const AssetImage("packages/camerawesome_fork/assets/icons/16_9.png");
                break;
              case CameraAspectRatios.ratio_4_3:
                width = 24;
                icon = const AssetImage("packages/camerawesome_fork/assets/icons/4_3.png");
                break;
              case CameraAspectRatios.ratio_1_1:
                width = 24;
                icon = const AssetImage("packages/camerawesome_fork/assets/icons/1_1.png");
                break;
            }

            return Builder(builder: (context) {
              final iconSize = theme?.buttonTheme.iconSize ??
                  AwesomeThemeProvider.of(context).theme.buttonTheme.iconSize;

              final scaleRatio = iconSize / AwesomeButtonTheme.baseIconSize;
              return AwesomeCircleWidget(
                theme: theme,
                child: Center(
                  child: SizedBox(
                    width: iconSize,
                    height: iconSize,
                    child: FittedBox(
                      child: Builder(
                        builder: (context) => Image(
                          image: icon,
                          color:
                              AwesomeThemeProvider.of(context).theme.buttonTheme.foregroundColor,
                          width: width * scaleRatio,
                        ),
                      ),
                    ),
                  ),
                ),
              );
            });
          }),
      onAspectRatioTap =
          onAspectRatioTap ?? ((sensorConfig, aspectRatio) => sensorConfig.switchCameraRatio());