Skip to content

Commit

Permalink
feat: added appbar title and center title field
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingWithTashi committed Dec 24, 2022
1 parent 4abc91e commit 2249102
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 13 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@

## 0.0.6
* Document update
* warning update
* warning update


## 0.0.7
* Fixed performance issue with window [5](https://github.com/CodingWithTashi/simple_barcode_scanner/issues/5)
* Added appBar title and centerTitle param [11](https://github.com/CodingWithTashi/simple_barcode_scanner/issues/11)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Window | Web
## Getting started

```dart
simple_barcode_scanner: ^0.0.6
simple_barcode_scanner: ^0.0.7
```
Import the library:
Expand Down
8 changes: 7 additions & 1 deletion lib/screens/io_device.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
import 'package:simple_barcode_scanner/enum.dart';
Expand All @@ -11,14 +12,17 @@ class BarcodeScanner extends StatelessWidget {
final bool isShowFlashIcon;
final ScanType scanType;
final Function(String) onScanned;

final String? appBarTitle;
final bool? centerTitle;
const BarcodeScanner({
Key? key,
required this.lineColor,
required this.cancelButtonText,
required this.isShowFlashIcon,
required this.scanType,
required this.onScanned,
this.appBarTitle,
this.centerTitle,
}) : super(key: key);

@override
Expand All @@ -31,6 +35,8 @@ class BarcodeScanner extends StatelessWidget {
isShowFlashIcon: isShowFlashIcon,
scanType: scanType,
onScanned: onScanned,
appBarTitle: appBarTitle,
centerTitle: centerTitle,
);
} else {
/// Scan Android and ios barcode scanner with flutter_barcode_scanner
Expand Down
6 changes: 5 additions & 1 deletion lib/screens/unsupported.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ class BarcodeScanner extends StatelessWidget {
final bool isShowFlashIcon;
final ScanType scanType;
final Function(String) onScanned;
final String? appBarTitle;
final bool? centerTitle;
const BarcodeScanner(
{Key? key,
this.lineColor = "#ff6666",
this.cancelButtonText = "Cancel",
this.isShowFlashIcon = false,
this.scanType = ScanType.barcode,
required this.onScanned})
required this.onScanned,
this.appBarTitle,
this.centerTitle})
: super(key: key);

@override
Expand Down
14 changes: 10 additions & 4 deletions lib/screens/web.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import 'package:flutter/material.dart';
import 'package:simple_barcode_scanner/constant.dart';
import 'package:simple_barcode_scanner/enum.dart';
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;
import 'dart:ui' as ui;

import 'package:flutter/material.dart';
import 'package:simple_barcode_scanner/constant.dart';
import 'package:simple_barcode_scanner/enum.dart';

/// Barcode scanner for web using iframe
class BarcodeScanner extends StatelessWidget {
final String lineColor;
final String cancelButtonText;
final bool isShowFlashIcon;
final ScanType scanType;
final Function(String) onScanned;
final String? appBarTitle;
final bool? centerTitle;

const BarcodeScanner({
Key? key,
Expand All @@ -20,6 +23,8 @@ class BarcodeScanner extends StatelessWidget {
required this.isShowFlashIcon,
required this.scanType,
required this.onScanned,
this.appBarTitle,
this.centerTitle,
}) : super(key: key);

@override
Expand Down Expand Up @@ -47,7 +52,8 @@ class BarcodeScanner extends StatelessWidget {

return Scaffold(
appBar: AppBar(
title: Text(kScanPageTitle),
title: Text(appBarTitle ?? kScanPageTitle),
centerTitle: centerTitle,
),
body: HtmlElementView(
viewType: createdViewId,
Expand Down
7 changes: 6 additions & 1 deletion lib/screens/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class WindowBarcodeScanner extends StatelessWidget {
final bool isShowFlashIcon;
final ScanType scanType;
final Function(String) onScanned;
final String? appBarTitle;
final bool? centerTitle;

const WindowBarcodeScanner({
Key? key,
Expand All @@ -21,6 +23,8 @@ class WindowBarcodeScanner extends StatelessWidget {
required this.isShowFlashIcon,
required this.scanType,
required this.onScanned,
this.appBarTitle,
this.centerTitle,
}) : super(key: key);

@override
Expand All @@ -29,7 +33,8 @@ class WindowBarcodeScanner extends StatelessWidget {
bool isPermissionGranted = false;
return Scaffold(
appBar: AppBar(
title: Text(kScanPageTitle),
title: Text(appBarTitle ?? kScanPageTitle),
centerTitle: centerTitle,
leading: IconButton(
onPressed: () {
/// send close event to web-view
Expand Down
17 changes: 14 additions & 3 deletions lib/simple_barcode_scanner.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
library simple_barcode_scanner;

export 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
import 'package:flutter/material.dart';
import 'package:simple_barcode_scanner/enum.dart';
import 'package:simple_barcode_scanner/screens/shared.dart';

export 'package:simple_barcode_scanner/simple_barcode_scanner.dart';

class SimpleBarcodeScannerPage extends StatelessWidget {
///Barcode line color default set to #ff6666
final String lineColor;
Expand All @@ -18,14 +19,22 @@ class SimpleBarcodeScannerPage extends StatelessWidget {
///Enter enum scanType, It can be BARCODE, QR, DEFAULT
final ScanType scanType;

///All param only support for mobile and tab,
///desktop and web is not yet support
///AppBar Title
final String? appBarTitle;

///center Title
final bool? centerTitle;

/// appBatTitle and centerTitle support in web and window only
/// Remaining field support in only mobile devices
const SimpleBarcodeScannerPage({
Key? key,
this.lineColor = "#ff6666",
this.cancelButtonText = "Cancel",
this.isShowFlashIcon = false,
this.scanType = ScanType.barcode,
this.appBarTitle,
this.centerTitle,
}) : super(key: key);

@override
Expand All @@ -35,6 +44,8 @@ class SimpleBarcodeScannerPage extends StatelessWidget {
cancelButtonText: cancelButtonText,
isShowFlashIcon: isShowFlashIcon,
scanType: scanType,
appBarTitle: appBarTitle,
centerTitle: centerTitle,
onScanned: (res) {
Navigator.pop(context, res);
},
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: simple_barcode_scanner
description: Scanner plugin for Barcode/QR code. Scan using flutter_barcode_scanner for mobile device and html5-qrcode for web and windows
version: 0.0.6
version: 0.0.7
homepage: https://github.com/CodingWithTashi/simple_barcode_scanner
issue_tracker: https://github.com/CodingWithTashi/simple_barcode_scanner/issues

Expand Down

0 comments on commit 2249102

Please sign in to comment.