Skip to content

Commit

Permalink
API docs (#5)
Browse files Browse the repository at this point in the history
* Added the documentation for public APIs

* Added the documentation for public APIs
  • Loading branch information
PiotrMitkowski authored Mar 7, 2023
1 parent 0a9d36d commit 4312ee7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.1.2
* Added the API documentation

## 0.1.1
* Fixed code format and license declaration

Expand Down
13 changes: 13 additions & 0 deletions lib/src/ar_quido_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,53 @@ abstract class ARQuidoPlatform extends PlatformInterface {
throw UnimplementedError('init() has not been implemented.');
}

/// Sets the current state of the device's flashlight.
///
/// The returned [Future] completes after the switch has been triggered on the
/// platform side.
Future<void> toggleFlashlight({required bool shouldTurnOn}) {
throw UnimplementedError('toggleFlashlight() has not been implemented.');
}

/// Returns a stream that receives data when a reference image has been detected.
Stream<ImageDetectedEvent> onImageDetected() {
throw UnimplementedError('onImageDetected() has not been implemented.');
}

/// Returns a stream that receives data when a reference image has been tapped.
Stream<ImageTappedEvent> onDetectedImageTapped() {
throw UnimplementedError('onImageDetected() has not been implemented.');
}

/// Returns a stream that receives data when the recognition mode was started.
Stream<RecognitionStartedEvent> onRecognitionStarted() {
throw UnimplementedError(
'onRecognitionStarted() has not been implemented.',
);
}

/// Returns a stream that receives data when the recognition mode was resumed
/// after a pause.
Stream<RecognitionResumedEvent> onRecognitionResumed() {
throw UnimplementedError(
'onRecognitionResumed() has not been implemented.',
);
}

/// Returns a stream that receives data when the recognition mode was paused.
Stream<RecognitionPausedEvent> onRecognitionPaused() {
throw UnimplementedError(
'onRecognitionResumed() has not been implemented.',
);
}

/// Returns a stream that receives data when the recognition module raises an
/// error.
Stream<ErrorEvent> onError() {
throw UnimplementedError('onError() has not been implemented.');
}

/// Dispose of whatever resources the platform is holding on to.
void dispose() {
throw UnimplementedError('dispose() has not been implemented.');
}
Expand Down
28 changes: 28 additions & 0 deletions lib/src/view/ar_quido_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';

/// A widget which displays a camera stream with image recognition features enabled.
class ARQuidoView extends StatefulWidget {
const ARQuidoView({
required this.referenceImageNames,
Expand All @@ -20,13 +21,40 @@ class ARQuidoView extends StatefulWidget {
super.key,
});

/// A list of names of files, that contain reference images. The names should
/// be provided without their path and extension.
///
/// All image files should be placed in `assets/reference_images` directory
/// and should be listed in the `assets` section of `pubspec.yaml`.
///
/// Only `.jpg` image files are supported at this time.
final List<String> referenceImageNames;

/// Callback method for when the view is ready to be used.
///
/// Used to receive a [ARQuidoViewController] for this [ARQuidoView].
final void Function(ARQuidoViewController controller)? onViewCreated;

/// Called when one of the reference images is detected in the current camera
/// stream.
final void Function(String? imageName) onImageDetected;

/// Called when a marker for detected reference image is tapped.
final void Function(String? imageName)? onDetectedImageTapped;

/// Called when all reference images are loaded to the recognition module and
/// the view starts the detection.
final VoidCallback? onRecognitionStarted;

/// iOS only; called when the view becomes invisible in the current context
/// (e.g. after navigating to another [Route]).
final VoidCallback? onRecognitionPaused;

/// iOS only; called when the view is restored after being paused (e.g. after
/// navigating to the [Route] with the view).
final VoidCallback? onRecognitionResumed;

/// Called when the view encounters an error.
final void Function(String error)? onError;

static const String _androidViewType =
Expand Down
6 changes: 6 additions & 0 deletions lib/src/view/ar_quido_view_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';

import 'package:ar_quido/ar_quido.dart';

/// Controller for a single ARQuidoView instance running on the host platform.
class ARQuidoViewController {
ARQuidoViewController(this._scannerViewState) {
ARQuidoPlatform.instance.init();
Expand All @@ -11,12 +12,17 @@ class ARQuidoViewController {
final ARQuidoViewState _scannerViewState;
final List<StreamSubscription<dynamic>> _subscriptions = [];

/// Disposes the controller resources (event stream subscriptions).
void dispose() {
for (final subscription in _subscriptions) {
subscription.cancel();
}
}

/// Sets the current state of the device's flashlight.
///
/// The returned [Future] completes after the switch has been triggered on the
/// platform side.
Future<void> toggleFlashlight({required bool shouldTurnOn}) {
return ARQuidoPlatform.instance.toggleFlashlight(
shouldTurnOn: shouldTurnOn,
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: ar_quido
description: A Flutter plugin for handling image recognition on mobile platforms
version: 0.1.1
version: 0.1.2
repository: https://github.com/miquido/ar_quido
issue_tracker: https://github.com/miquido/ar_quido/issues
homepage: https://github.com/miquido/ar_quido
Expand Down

0 comments on commit 4312ee7

Please sign in to comment.