khoren93 / flutter_zxing

Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
https://pub.dev/packages/flutter_zxing
MIT License
97 stars 56 forks source link

feat: Makes render widget action buttons customizable #133

Closed BolisettySujith closed 6 months ago

BolisettySujith commented 6 months ago

Overview:

Action buttons(torch, gallery, toggle camera) present in the ReaderWidget are not customizable, this PR helps in making them customizable. This PR also makes the action buttons background color and background border radius customizable.

All the fields are declared in the ReaderWidget class parameters also contains a default parameter values.

The following are the fields that are being newly added to the class paramters:

  /// Custom flash_on icon
  final Widget flashOnIcon;

  /// Custom flash_off icon
  final Widget flashOffIcon;

  /// Custom flash_always icon
  final Widget flashAlwaysIcon;

  /// Custom flash_auto icon
  final Widget flashAutoIcon;

  /// Custom gallery icon
  final Widget galleryIcon;

  /// Custom camera toggle icon
  final Widget toggleCameraIcon;

  /// Custom background color for action buttons
  final Color actionButtonsBackgroundColor;

  /// Custom background border radius for action buttons
  final BorderRadius? actionButtonsBackgroundBorderRadius;

Example Code:

ReaderWidget(
  //....
  flashOnIcon: const Icon(Icons.flash_on),              
  flashOffIcon: const Icon(Icons.flash_off),              
  flashAlwaysIcon: const Icon(Icons.flash_on),
  flashAutoIcon: const Icon(Icons.flash_auto),
  galleryIcon: const Icon(Icons.photo_library),
  toggleCameraIcon: const Icon(Icons.switch_camera),
  actionButtonsBackgroundBorderRadius: BorderRadius.circular(10),
  actionButtonsBackgroundColor: Colors.black.withOpacity(0.5),
  //....
 )

Closes:

132

BolisettySujith commented 6 months ago

@khoren93

Could you please review this PR :)

BolisettySujith commented 6 months ago

Even though it is a sample implementation, it contains almost every feature and customisation option that requires for a mobile scanner, it contains flash, gallery, toggle camera options...You can also hide the buttons as well if you don't want, like as you mentioned it is not possible to remove the gallery button, you can do that by passing showGallary = false. You can also customise the position of the render widgets anyplace in the screen. You can also change the overlay styles as well, and it's pretty good. When I have all these many options why I or anyone wants to use their own.

The only thing that was left was customising default icons, so I think this pr helps in fixing it.

khoren93 commented 6 months ago

@BolisettySujith Thank you for this valuable contribution! Customizable action buttons and parameters in the ReaderWidget will enhance its flexibility and usability.