Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading State for camera overlay capture #1918

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions modules/camera/lib/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class CameraState extends EWidgetState<Camera> with WidgetsBindingObserver {
bool isRecording = false;
bool hasPermission = false;
bool isLoading = true;
bool isCropping = false;
int currentModeIndex = 0;

List<CameraMode> modes = [];
Expand Down Expand Up @@ -510,6 +511,17 @@ class CameraState extends EWidgetState<Camera> with WidgetsBindingObserver {
child: widget.overlayWidget!,
),
),
if (isCropping)
Container(
color: Colors.black.withOpacity(0.7), // Black background
width: MediaQuery.of(context).size.width, // Full screen width
height: MediaQuery.of(context).size.height, // Full screen height
child: Center(
child: CircularProgressIndicator(
color: Colors.white, // Optional: Change the color of the progress indicator
Comment on lines +520 to +521
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we allow user to build his own loading indicator? if loading widget is not defined we can use this as default, but user should have the option to define his own widget for customization

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we can have custom widget.

),
),
),
imagePreviewButton(),
Align(
alignment: Alignment.bottomCenter,
Expand Down Expand Up @@ -1027,10 +1039,17 @@ class CameraState extends EWidgetState<Camera> with WidgetsBindingObserver {
}
} else {
if (widget._controller.captureOverlay) {
setState(() {
isCropping = true;
});
try {
file = await takeOverlayCapture();
} on Exception catch (e) {
print(e);
} finally {
setState(() {
isCropping = false;
});
Comment on lines +1042 to +1052
Copy link
Member

Choose a reason for hiding this comment

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

based on the video in PR, this is taking too much time, is there a way to optimize this? maybe doing a something in background, please checkout why its taking that much time, we can push this for now, but there should be way to optimize take

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually there's image encoding decoding going on there and also file reading too

}
} else {
file = await takePicture();
Expand Down