-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added fullscreen webcam
- Loading branch information
Showing
16 changed files
with
216 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_mjpeg/flutter_mjpeg.dart'; | ||
import 'package:mobileraker/ui/views/fullcam/full_cam_viewmodel.dart'; | ||
import 'package:stacked/stacked.dart'; | ||
|
||
class FullCamView extends ViewModelBuilderWidget<FullCamViewModel> { | ||
@override | ||
FullCamViewModel viewModelBuilder(BuildContext context) => | ||
FullCamViewModel(); | ||
|
||
@override | ||
Widget builder(BuildContext context, FullCamViewModel model, Widget? child) { | ||
return Scaffold( | ||
body: Container( | ||
child: Stack(children: [ | ||
Center( | ||
child: InteractiveViewer( | ||
panEnabled: true, | ||
minScale: 1, | ||
maxScale: 10, | ||
child: Transform( | ||
alignment: Alignment.center, | ||
transform: model.transformMatrix, | ||
child: Mjpeg( | ||
isLive: true, | ||
stream: model.selectedCam.url, | ||
)), | ||
), | ||
), | ||
Align( | ||
alignment: Alignment.bottomRight, | ||
child: IconButton( | ||
icon: Icon(Icons.close_fullscreen_outlined), | ||
tooltip: 'Close', | ||
onPressed: model.onCloseTapped, | ||
), | ||
), | ||
]), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'dart:math'; | ||
|
||
import 'package:flutter/widgets.dart'; | ||
import 'package:mobileraker/app/app_setup.locator.dart'; | ||
import 'package:mobileraker/dto/machine/webcam_setting.dart'; | ||
import 'package:mobileraker/service/machine_service.dart'; | ||
import 'package:stacked/stacked.dart'; | ||
import 'package:stacked_services/stacked_services.dart'; | ||
|
||
class FullCamViewModel extends BaseViewModel { | ||
final _navigationService = locator<NavigationService>(); | ||
final _machineService = locator<MachineService>(); | ||
|
||
WebcamSetting? _camHack() { | ||
var printSetting = _machineService.selectedPrinter.valueOrNull; | ||
if (printSetting != null && printSetting.cams.isNotEmpty) { | ||
return printSetting.cams.first; | ||
} | ||
return null; | ||
} | ||
|
||
bool get hasCam => _camHack() != null; | ||
|
||
WebcamSetting get selectedCam => _camHack()!; | ||
|
||
double get yTransformation { | ||
if (selectedCam.flipHorizontal) | ||
return pi; | ||
else | ||
return 0; | ||
} | ||
|
||
double get xTransformation { | ||
if (selectedCam.flipVertical) | ||
return pi; | ||
else | ||
return 0; | ||
} | ||
|
||
Matrix4 get transformMatrix => Matrix4.identity() | ||
..rotateX(xTransformation) | ||
..rotateY(yTransformation); | ||
|
||
onCloseTapped() { | ||
_navigationService.back(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.