Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

Commit

Permalink
Provided a new parameter to control preview alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateus Felipe committed Jan 31, 2020
1 parent d132065 commit afcee75
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.4

* Added a new parameter to `MagicEye` to control preview alignment.
* **Possibly Breaking Change:** By default, the alignment is now `topCenter`.

## 0.1.3+2

* Added a [`analysis_options.yaml`](https://dart.dev/guides/language/analysis-options) file
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.3+2"
version: "0.1.4"
matcher:
dependency: transitive
description:
Expand Down
24 changes: 17 additions & 7 deletions lib/src/layers/default_camera_control_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Widget Function(BuildContext, ControlLayerContext) defaultCameraControlLayer() {
}

return Stack(
alignment: Alignment.bottomCenter,
alignment: Alignment.topCenter,
children: <Widget>[
if (snapshot.data is _TakingPicture ||
snapshot.data is _WithPicture)
Expand All @@ -73,16 +73,26 @@ Widget Function(BuildContext, ControlLayerContext) defaultCameraControlLayer() {
),
),
if (snapshot.data is _WithPicture)
_BottomConfirmationButtons(
path: (snapshot.data as _WithPicture).path,
pathStream: cameraState,
Positioned(
bottom: 0,
left: 0,
right: 0,
child: _BottomConfirmationButtons(
path: (snapshot.data as _WithPicture).path,
pathStream: cameraState,
),
),
if (snapshot.data is _TakingPicture)
Center(child: CircularProgressIndicator()),
if (snapshot.data is _Idle)
_BottomPictureButtons(
layerContext: layerContext,
cameraState: cameraState,
Positioned(
bottom: 0,
left: 0,
right: 0,
child: _BottomPictureButtons(
layerContext: layerContext,
cameraState: cameraState,
),
),
],
);
Expand Down
26 changes: 18 additions & 8 deletions lib/src/widget/magiceye_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class MagicEye extends StatelessWidget with WidgetsBindingObserver {
.map((orientation) => DeviceDirection.values[orientation.index])
.shareValue() as BehaviorSubject<DeviceDirection>;

/// The alignment of the preview in the stack
final AlignmentDirectional previewAlignment;

/// Creates a MagicEye component.
MagicEye({
Key key,
Expand All @@ -115,6 +118,7 @@ class MagicEye extends StatelessWidget with WidgetsBindingObserver {
DeviceDirection.portraitReversed,
DeviceDirection.landscapeRight,
},
this.previewAlignment = AlignmentDirectional.topCenter,
}) : this._bloc = MagicEyeBloc(
resolutionPreset: resolutionPreset,
defaultDirection: defaultDirection,
Expand All @@ -137,7 +141,7 @@ class MagicEye extends StatelessWidget with WidgetsBindingObserver {
builder: (context, snapshot) => snapshot.data.fold<Widget>(
() => Center(child: loadingWidget),
(controller) => Stack(
alignment: AlignmentDirectional.bottomCenter,
alignment: this.previewAlignment,
children: [
AspectRatio(
aspectRatio: controller.value.aspectRatio,
Expand All @@ -154,13 +158,19 @@ class MagicEye extends StatelessWidget with WidgetsBindingObserver {
],
),
),
controlLayer(
context,
ControlLayerContext(
allowedCameras: allowedCameras,
allowedDirections: allowedDirections,
bloc: _bloc,
direction: _orientation,
Positioned(
bottom: 0,
top: 0,
left: 0,
right: 0,
child: controlLayer(
context,
ControlLayerContext(
allowedCameras: allowedCameras,
allowedDirections: allowedDirections,
bloc: _bloc,
direction: _orientation,
),
),
),
],
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: magiceye
description: An abstraction on top of flutter camera, that allows you to have a default camera screen or build your own with the layer builders.
version: 0.1.3+2
version: 0.1.4
homepage: https://github.com/mateusfccp/magiceye
repository: https://github.com/mateusfccp/magiceye

Expand Down

0 comments on commit afcee75

Please sign in to comment.