afriscic / BarcodeScanning.Native.Maui

Barcode scanning library for .NET MAUI
https://www.nuget.org/packages/BarcodeScanning.Native.Maui
MIT License
186 stars 35 forks source link

Missing Features #2

Closed UkeHa closed 11 months ago

UkeHa commented 1 year ago

Hi,

i've tried to use your plugin with MVVM and think there are some improvements out there.

MVVM Example: RelayCommand to toggle CameraProperty

    public CameraPageViewModel1()
    {
        CameraFacing = CameraFacing.Front;
    }

        [ObservableProperty] private CameraFacing _cameraFacing;

    [RelayCommand]
    private void ToggleCamera()
    {
        CameraFacing = CameraFacing == CameraFacing.Front ? CameraFacing.Back : CameraFacing.Front;
    }

XAML:

    <AbsoluteLayout>
        <scanner:CameraView
            AbsoluteLayout.LayoutFlags="All"
            AbsoluteLayout.LayoutBounds="0,0,1,1"
            CaptureQuality="Highest"
            ForceInverted="False"
            TapToFocusEnabled="True"
            OnDetectionFinished="CameraView_OnDetectionFinished"
            CameraFacing="{Binding CameraFacing}"
            VibrationOnDetected="{Binding VibrateOnDetection}"
            BarcodeSymbologies="All"
            x:Name="Barcode"/>

        <GraphicsView
            AbsoluteLayout.LayoutFlags="All"
            AbsoluteLayout.LayoutBounds="0,0,1,1"
            x:Name="Graphics"
            InputTransparent="True"/>

        <Grid ColumnDefinitions="*, *" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,0.1">
            <Picker x:Name="Quality" Title="Quality" Grid.Column="2" BackgroundColor="Transparent"  WidthRequest="45" HeightRequest="45" SelectedIndexChanged="Quality_SelectedIndexChanged"/>

            <Button Text="C" Grid.Column="0" WidthRequest="50" HeightRequest="50" CornerRadius="25" Command="{Binding ToggleCameraCommand}"/>
            <Button Text="T" Grid.Column="1" WidthRequest="50" HeightRequest="50" CornerRadius="25" Clicked="TorchButton_Clicked"/>
        </Grid>
    </AbsoluteLayout>

The Constructor Camera facing front is being ignored.

afriscic commented 1 year ago

Hello and thank you for comments.

  1. You can get duplication prevention and better recognition by setting "PoolingInterval" to some value in ms. The program should continue to scan in the background but should remove duplicates and return results at the end of each interval.
  2. I haven't fully tested iOS. I have possible fix but it will be a couple of days, maybe a few weeks until i can push it. I'm still battling some health issues so I'm unable to work fully.
  3. MVVM worked OK for me. I'll test it more, but any updates could come with .NET 8 update.
  4. Didn't think about donations, it would be nice to add :P
UkeHa commented 1 year ago

Hey, no worries your library has been super helpful to us thus far. Oh, i also ran into another issue. The front camera of iPads don't work. You can't switch to them.

afriscic commented 11 months ago

Unfortunately I don't have an iPad to test and to find where the problem is. If you can do a pull request with code that would fix this and I'll merge it.

geertgeerits commented 11 months ago

The front camera on an iPad is working but you have to set the quality lower (on medium). Tested on an iPad 8, iOS version 17.1.1.

afriscic commented 11 months ago

I have implemented a resolution fallback for iOS devices so it should be fixed in the newest release.