Skip to content

CameraView torch support - #3211

Merged
TheCodeTraveler merged 6 commits into
CommunityToolkit:mainfrom
MFinkBK:cameraview-torch-support
May 8, 2026
Merged

TheCodeTraveler merged 6 commits into
CommunityToolkit:mainfrom
MFinkBK:cameraview-torch-support

Conversation

@MFinkBK

@MFinkBK MFinkBK commented May 7, 2026

Copy link
Copy Markdown
Contributor

Description of Change

This implements the property mapper for the CameraView property IsTorchOn. I based the property mapper on the code in the ZXing.Net.MAUI repository.

Tests were omitted, since this is not possible to test automatically. It has a sample, though. I didn't create a Documentation PR, since the property is already documented:
https://github.com/MicrosoftDocs/CommunityToolkit/blob/07e8463e67e4e24ed93d67490197cf4548537b71/docs/maui/views/camera-view.md?plain=1#L749

Linked Issues

PR Checklist

Additional information

I tested this with an Android device. I will test it also on an iOS device, as soon as I figure out my deployment problems. Unfortunately I don't have a Windows device with integrated flash, so I couldn't test it on that platform.

@TheCodeTraveler
TheCodeTraveler requested a review from Copilot May 7, 2026 14:54
@TheCodeTraveler TheCodeTraveler added the needs discussion Discuss it on the next Monthly standup label May 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements handler/property-mapper support for CameraView.IsTorchOn, enabling torch control through the Toolkit CameraView across platforms, and updates the sample UI to demonstrate the feature.

Changes:

  • Added IsTorchOn property mapping in CameraViewHandler and routed it to a new CameraManager.UpdateIsTorchOn(...) API.
  • Implemented UpdateIsTorchOn(...) for Android, iOS/macOS, and Windows (and net fallback as not supported).
  • Updated the CameraView sample page + view model to toggle torch state via a checkbox.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs Adds property mapper entry and mapping method for IsTorchOn.
src/CommunityToolkit.Maui.Camera/CameraManager.shared.cs Introduces UpdateIsTorchOn(bool) as a new cross-platform partial method.
src/CommunityToolkit.Maui.Camera/CameraManager.android.cs Implements torch toggling via CameraX EnableTorch.
src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs Implements torch toggling via AVCaptureDevice.TorchMode.
src/CommunityToolkit.Maui.Camera/CameraManager.windows.cs Implements torch toggling via TorchControl.Enabled.
src/CommunityToolkit.Maui.Camera/CameraManager.net.cs Adds not-supported stub for UpdateIsTorchOn.
samples/CommunityToolkit.Maui.Sample/ViewModels/Views/CameraView/CameraViewViewModel.cs Adds IsTorchOn observable property for the sample.
samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml Wires CameraView.IsTorchOn + checkbox to the sample view model.

Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.shared.cs
@MFinkBK

MFinkBK commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

My tests on an iPad mini 6. Gen was successful, the torch checkbox in the sample correctly toggles the torch light.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread src/CommunityToolkit.Maui.Camera/CameraManager.windows.cs
@TheCodeTraveler TheCodeTraveler self-assigned this May 7, 2026
@TheCodeTraveler TheCodeTraveler removed the needs discussion Discuss it on the next Monthly standup label May 7, 2026

@TheCodeTraveler TheCodeTraveler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work @MFinkBK!

@TheCodeTraveler
TheCodeTraveler enabled auto-merge (squash) May 8, 2026 23:45
@TheCodeTraveler
TheCodeTraveler merged commit 0fe8edc into CommunityToolkit:main May 8, 2026
10 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 10, 2026
@MFinkBK
MFinkBK deleted the cameraview-torch-support branch May 11, 2026 07:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Toolkit MAUI CameraView IsTorchOn then as wll torch not working [BUG] CameraView IsTorchOn not working on Android

3 participants