Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

UI customization #187

Open
13 tasks
devtronic opened this issue Feb 22, 2020 · 29 comments
Open
13 tasks

UI customization #187

devtronic opened this issue Feb 22, 2020 · 29 comments
Labels
Feature Feature Request tracker Tracker issues link other issues for a specific topic together

Comments

@devtronic
Copy link
Member

devtronic commented Feb 22, 2020

Any ideas how can we achieve a dynamic scanner view?

  • Use a Flutter view which gets the current preview image + meta information where detected barcodes are located to render the view directly in flutter. (idk about performance)
  • Pass layout options to the BarcodeScanner.scan() method.
  • Overlay the platform screen with a flutter screen which renders the overlay UI

This issue belongs to:

@devtronic devtronic added Feature Feature Request tracker Tracker issues link other issues for a specific topic together labels Feb 22, 2020
@wesleyguirra
Copy link

Use a Flutter view which gets the current preview image + meta information where detected barcodes are located to render the view directly in flutter. (idk about performance) +1

@phcaraujo
Copy link

From what I saw then, will it not be possible to change the design, even in future versions?

@devtronic
Copy link
Member Author

It's just a definition thing. We need to determine what should be customizable by devs and implement this feature.

@tobyarevalo
Copy link

The default Ui from the scanner doesn´t matches the Ui from my app, i really need to change it.
Try to make it custom!

@cahyowhy
Copy link

thanks for this lib, its awesome
could you give me some reference about this..
about how to render flutter view inside the camera while scan the barcode

@vitorzarzar
Copy link

The best approach i've seen was the lib returning a Widget, so the dev could put anything on top of it (with Stack) without any need of implementation from the lib side.

As example, there is the qr_code_scanner

I'm new with Flutter and mobile development, so i may be saying something wrong, just tried to help.

@subinsv
Copy link

subinsv commented Apr 14, 2020

Hi. Thanks for this awesome library.

Is it possible to remove the AppBar in Android when in scannerview?

@devtronic
Copy link
Member Author

Maybe native views are a good solution for customizing the UI? https://medium.com/flutter-community/flutter-platformview-how-to-create-flutter-widgets-from-native-views-366e378115b6

@alexnaldo
Copy link

The barcode reads function is great, but without UI customization is very hard to adopt it. UI is essential feature for Flutter users.

@subinsv
Copy link

subinsv commented Apr 15, 2020

@devtronic From the article

Embedding Android views is an expensive operation and should be avoided when a Flutter equivalent is possible.

So, it is a choice between customization and performance.

@devtronic
Copy link
Member Author

devtronic commented Apr 15, 2020

@devtronic From the article

Embedding Android views is an expensive operation and should be avoided when a Flutter equivalent is possible.

So, it is a choice between customization and performance.

Yes, we've to evaluate what brings a better performance:

  • Using a Native View for the camera preview or
  • passing the raw image through a platform channel to render it directly in flutter

Never the less, this would be an optional feature like scanWithCustomPreview(...) or something else so we don't have to force the users to implement their own preview

@alexnaldo
Copy link

Another option is pass parameters for easy customizations like view size, colors, alignment etc.

@AlisonLopes
Copy link

Make it responsive when changing screen orientation portrait / landscape

@saddemYassin
Copy link

I want only to remove the app bar from the default view. Are they any available solution?
Screenshot_20200423-144618

@alexnaldo
Copy link

@saddem123 , you can edit the sources (iOS e Android). Remember that this component is a wrapper

@saddemYassin
Copy link

@alexnaldo what you mean by change the sources I just import the library in flutter how to edit it?

@Axort
Copy link

Axort commented Apr 23, 2020

@saddem123 You can fork this library, make the changes you need and then point to your fork in the pubspec.yaml, e.g.

barcode_scan:
    git: 
      url: [your_fork]

@devtronic
Copy link
Member Author

devtronic commented Apr 24, 2020

I want only to remove the app bar from the default view. Are they any available solution?

What's about the flash button? If there is no app bar you can't toggle the flash.

@daveparks23
Copy link

daveparks23 commented May 10, 2020

Pretty simple to change the color of the text in the App Bar in iOS
BarScannerViewControllerSwift
Color of text Flash On / Flash Off

private func updateToggleFlashButton() {
    if !hasTorch {
      return
    }
    
    let buttonText = isFlashOn ? config.strings["flash_off"] : config.strings["flash_on"]

    let customRightBarButtonItem = UIBarButtonItem(title: buttonText,
                                                        style: .plain,
                                                        target: self,
                                                        action: #selector(onToggleFlash)
    )
    customRightBarButtonItem.tintColor = UIColor.orange
    navigationItem.rightBarButtonItem = customRightBarButtonItem
    
  }

ScannerOverlay.swift
Corner line color orange

override init(frame: CGRect) {
        super.init(frame: frame)
        line.backgroundColor = UIColor.orange
        line.translatesAutoresizingMaskIntoConstraints = false
        
        addSubview(line)
    }

Scanner line color orange
At the end of the draw function inside ScannerOverlay.swift file

path.lineWidth = 2
UIColor.orange.setStroke()
path.stroke()

Can someone show me where the code is for the Android-related color options? I can't find it.

@webberlin0933
Copy link

Pretty simple to change the color of the text in the App Bar in iOS
BarScannerViewControllerSwift
Color of text Flash On / Flash Off

private func updateToggleFlashButton() {
    if !hasTorch {
      return
    }
    
    let buttonText = isFlashOn ? config.strings["flash_off"] : config.strings["flash_on"]

    let customRightBarButtonItem = UIBarButtonItem(title: buttonText,
                                                        style: .plain,
                                                        target: self,
                                                        action: #selector(onToggleFlash)
    )
    customRightBarButtonItem.tintColor = UIColor.orange
    navigationItem.rightBarButtonItem = customRightBarButtonItem
    
  }

ScannerOverlay.swift
Corner line color orange

override init(frame: CGRect) {
        super.init(frame: frame)
        line.backgroundColor = UIColor.orange
        line.translatesAutoresizingMaskIntoConstraints = false
        
        addSubview(line)
    }

Scanner line color orange
At the end of the draw function inside ScannerOverlay.swift file

path.lineWidth = 2
UIColor.orange.setStroke()
path.stroke()

Can someone show me where the code is for the Android-related color options? I can't find it.

I have the similar problem.I want to add a straight line to make it point to the center when scanning.
This requirement stems from the fact that when scanninng, the center point needs to be aligned in order to scan quickly and effectively.
Finally, Thanks to the person who provided this source for solving my many problems.

@bero93
Copy link

bero93 commented Jun 20, 2020

@saddem123 You can fork this library, make the changes you need and then point to your fork in the pubspec.yaml, e.g.

barcode_scan:
    git: 
      url: [your_fork]

non related question : how to do the same functionality if i want to replace a flutter core widget with a custom one made by me

@Sandro-darli
Copy link

Hello! We already have a solution to change hide the title?

@saddemYassin
Copy link

saddemYassin commented Aug 9, 2020 via email

@xi1570-krupeshanadkat
Copy link

xi1570-krupeshanadkat commented Aug 26, 2020

@devtronic just marking the 10-15 issues closed and bringing everyone on same thread won't help. How about some solution?

@devtronic
Copy link
Member Author

How about some solution?! This is an open source project so feel free to contribute!

@xi1570-krupeshanadkat
Copy link

xi1570-krupeshanadkat commented Aug 26, 2020

How about some solution?! This is an open source project so feel free to contribute!

@devtronic modified readme for Custom Title, created PR. Could you help me know where in source code we have colors defined (for scanning rectangle)?? I would be happy to help put some info in readme for everyone.

@xi1570-krupeshanadkat
Copy link

xi1570-krupeshanadkat commented Aug 26, 2020

@saddem123 Solution to your issue, (for Android)
add these lines in android/app/src/main/AndroidManifest.xml after </activity> tag

<activity 
          android:name="de.mintware.barcode_scan.BarcodeScannerActivity"
          android:theme="@android:style/Theme.Black.NoTitleBar" />

This will remove title bar (app bar) in the scanning screen.

To just change the title use below:

<activity 
     android:name="de.mintware.barcode_scan.BarcodeScannerActivity"
     android:label="My Activity Title" />

(Replace "My Activity Title" with your desired title)

@bhammer88
Copy link

Would be a great help even we can modify the the outline colors to match out app design theme. Of course overlaying will give us more customisation.

@kamleshwebtech
Copy link

@saddem123 Solution to your issue, (for Android)
add these lines in android/app/src/main/AndroidManifest.xml after </activity> tag

<activity 
          android:name="de.mintware.barcode_scan.BarcodeScannerActivity"
          android:theme="@android:style/Theme.Black.NoTitleBar" />

This will remove title bar (app bar) in the scanning screen.

To just change the title use below:

<activity 
     android:name="de.mintware.barcode_scan.BarcodeScannerActivity"
     android:label="My Activity Title" />

(Replace "My Activity Title" with your desired title)

Dear, i do not want to remove scan screen appbar, just want to change background color of app bar, please suggest how can we do? Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature Feature Request tracker Tracker issues link other issues for a specific topic together
Projects
None yet
Development

No branches or pull requests