Showing
3 changed files
with
157 additions
and
492 deletions
| ... | @@ -23,20 +23,10 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> | ... | @@ -23,20 +23,10 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> |
| 23 | File? _imageFile; | 23 | File? _imageFile; |
| 24 | File? _videoFile; | 24 | File? _videoFile; |
| 25 | 25 | ||
| 26 | - // Initial values | 26 | + final bool _isVideoCameraSelected = true; |
| 27 | bool _isCameraInitialized = false; | 27 | bool _isCameraInitialized = false; |
| 28 | bool _isRearCameraSelected = true; | 28 | bool _isRearCameraSelected = true; |
| 29 | - bool _isVideoCameraSelected = false; | ||
| 30 | bool _isRecordingInProgress = false; | 29 | bool _isRecordingInProgress = false; |
| 31 | - double _minAvailableExposureOffset = 0.0; | ||
| 32 | - double _maxAvailableExposureOffset = 0.0; | ||
| 33 | - double _minAvailableZoom = 1.0; | ||
| 34 | - double _maxAvailableZoom = 1.0; | ||
| 35 | - | ||
| 36 | - // Current values | ||
| 37 | - double _currentZoomLevel = 1.0; | ||
| 38 | - double _currentExposureOffset = 0.0; | ||
| 39 | - FlashMode? _currentFlashMode; | ||
| 40 | 30 | ||
| 41 | List<File> allFileList = []; | 31 | List<File> allFileList = []; |
| 42 | 32 | ||
| ... | @@ -193,11 +183,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> | ... | @@ -193,11 +183,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> |
| 193 | } | 183 | } |
| 194 | } | 184 | } |
| 195 | 185 | ||
| 196 | - void resetCameraValues() async { | ||
| 197 | - _currentZoomLevel = 1.0; | ||
| 198 | - _currentExposureOffset = 0.0; | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | void onNewCameraSelected(CameraDescription cameraDescription) async { | 186 | void onNewCameraSelected(CameraDescription cameraDescription) async { |
| 202 | final previousCameraController = controller; | 187 | final previousCameraController = controller; |
| 203 | 188 | ||
| ... | @@ -209,8 +194,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> | ... | @@ -209,8 +194,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> |
| 209 | 194 | ||
| 210 | await previousCameraController?.dispose(); | 195 | await previousCameraController?.dispose(); |
| 211 | 196 | ||
| 212 | - resetCameraValues(); | ||
| 213 | - | ||
| 214 | if (mounted) { | 197 | if (mounted) { |
| 215 | setState(() { | 198 | setState(() { |
| 216 | controller = cameraController; | 199 | controller = cameraController; |
| ... | @@ -224,22 +207,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> | ... | @@ -224,22 +207,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> |
| 224 | 207 | ||
| 225 | try { | 208 | try { |
| 226 | await cameraController.initialize(); | 209 | await cameraController.initialize(); |
| 227 | - await Future.wait([ | ||
| 228 | - cameraController | ||
| 229 | - .getMinExposureOffset() | ||
| 230 | - .then((value) => _minAvailableExposureOffset = value), | ||
| 231 | - cameraController | ||
| 232 | - .getMaxExposureOffset() | ||
| 233 | - .then((value) => _maxAvailableExposureOffset = value), | ||
| 234 | - cameraController | ||
| 235 | - .getMaxZoomLevel() | ||
| 236 | - .then((value) => _maxAvailableZoom = value), | ||
| 237 | - cameraController | ||
| 238 | - .getMinZoomLevel() | ||
| 239 | - .then((value) => _minAvailableZoom = value), | ||
| 240 | - ]); | ||
| 241 | - | ||
| 242 | - _currentFlashMode = controller!.value.flashMode; | ||
| 243 | } on CameraException catch (e) { | 210 | } on CameraException catch (e) { |
| 244 | // print('Error initializing camera: $e'); | 211 | // print('Error initializing camera: $e'); |
| 245 | } | 212 | } |
| ... | @@ -280,484 +247,182 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> | ... | @@ -280,484 +247,182 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage> |
| 280 | child: Scaffold( | 247 | child: Scaffold( |
| 281 | backgroundColor: Colors.black, | 248 | backgroundColor: Colors.black, |
| 282 | body: _isCameraInitialized | 249 | body: _isCameraInitialized |
| 283 | - ? Column( | 250 | + ? Stack( |
| 284 | children: [ | 251 | children: [ |
| 285 | - AspectRatio( | 252 | + controller!.buildPreview(), |
| 286 | - aspectRatio: 1 / controller!.value.aspectRatio, | 253 | + Padding( |
| 287 | - child: Stack( | 254 | + padding: const EdgeInsets.fromLTRB( |
| 255 | + 16.0, | ||
| 256 | + 8.0, | ||
| 257 | + 16.0, | ||
| 258 | + 8.0, | ||
| 259 | + ), | ||
| 260 | + child: Column( | ||
| 261 | + crossAxisAlignment: CrossAxisAlignment.end, | ||
| 288 | children: [ | 262 | children: [ |
| 289 | - controller!.buildPreview(), | 263 | + // Spacer(), |
| 290 | - Padding( | 264 | + const Spacer( |
| 291 | - padding: const EdgeInsets.fromLTRB( | 265 | + flex: 1, |
| 292 | - 16.0, | 266 | + ), |
| 293 | - 8.0, | 267 | + Row( |
| 294 | - 16.0, | 268 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 295 | - 8.0, | 269 | + children: [ |
| 296 | - ), | 270 | + InkWell( |
| 297 | - child: Column( | 271 | + onTap: _isRecordingInProgress |
| 298 | - crossAxisAlignment: CrossAxisAlignment.end, | 272 | + ? () async { |
| 299 | - children: [ | 273 | + if (controller!.value.isRecordingPaused) { |
| 300 | - Align( | 274 | + await resumeVideoRecording(); |
| 301 | - alignment: Alignment.topRight, | 275 | + } else { |
| 302 | - child: Container( | 276 | + await pauseVideoRecording(); |
| 303 | - decoration: BoxDecoration( | 277 | + } |
| 304 | - color: Colors.black87, | 278 | + } |
| 305 | - borderRadius: BorderRadius.circular(10.0), | 279 | + : () { |
| 306 | - ), | 280 | + setState(() { |
| 307 | - child: Padding( | 281 | + _isCameraInitialized = false; |
| 308 | - padding: const EdgeInsets.only( | 282 | + }); |
| 309 | - left: 8.0, | 283 | + onNewCameraSelected(cameras![ |
| 310 | - right: 8.0, | 284 | + _isRearCameraSelected ? 1 : 0]); |
| 311 | - ), | 285 | + setState(() { |
| 312 | - child: DropdownButton<ResolutionPreset>( | 286 | + _isRearCameraSelected = |
| 313 | - dropdownColor: Colors.black87, | 287 | + !_isRearCameraSelected; |
| 314 | - underline: Container(), | 288 | + }); |
| 315 | - value: currentResolutionPreset, | 289 | + }, |
| 316 | - items: [ | 290 | + child: Stack( |
| 317 | - for (ResolutionPreset preset | 291 | + alignment: Alignment.center, |
| 318 | - in resolutionPresets) | ||
| 319 | - DropdownMenuItem( | ||
| 320 | - child: Text( | ||
| 321 | - preset | ||
| 322 | - .toString() | ||
| 323 | - .split('.')[1] | ||
| 324 | - .toUpperCase(), | ||
| 325 | - style: const TextStyle( | ||
| 326 | - color: Colors.white), | ||
| 327 | - ), | ||
| 328 | - value: preset, | ||
| 329 | - ) | ||
| 330 | - ], | ||
| 331 | - onChanged: (value) { | ||
| 332 | - setState(() { | ||
| 333 | - currentResolutionPreset = value!; | ||
| 334 | - _isCameraInitialized = false; | ||
| 335 | - }); | ||
| 336 | - onNewCameraSelected( | ||
| 337 | - controller!.description); | ||
| 338 | - }, | ||
| 339 | - hint: const Text("Select item"), | ||
| 340 | - ), | ||
| 341 | - ), | ||
| 342 | - ), | ||
| 343 | - ), | ||
| 344 | - // Spacer(), | ||
| 345 | - Padding( | ||
| 346 | - padding: const EdgeInsets.only( | ||
| 347 | - right: 8.0, top: 16.0), | ||
| 348 | - child: Container( | ||
| 349 | - decoration: BoxDecoration( | ||
| 350 | - color: Colors.white, | ||
| 351 | - borderRadius: BorderRadius.circular(10.0), | ||
| 352 | - ), | ||
| 353 | - child: Padding( | ||
| 354 | - padding: const EdgeInsets.all(8.0), | ||
| 355 | - child: Text( | ||
| 356 | - _currentExposureOffset | ||
| 357 | - .toStringAsFixed(1) + | ||
| 358 | - 'x', | ||
| 359 | - style: | ||
| 360 | - const TextStyle(color: Colors.black), | ||
| 361 | - ), | ||
| 362 | - ), | ||
| 363 | - ), | ||
| 364 | - ), | ||
| 365 | - Expanded( | ||
| 366 | - child: RotatedBox( | ||
| 367 | - quarterTurns: 3, | ||
| 368 | - child: SizedBox( | ||
| 369 | - height: 30, | ||
| 370 | - child: Slider( | ||
| 371 | - value: _currentExposureOffset, | ||
| 372 | - min: _minAvailableExposureOffset, | ||
| 373 | - max: _maxAvailableExposureOffset, | ||
| 374 | - activeColor: Colors.white, | ||
| 375 | - inactiveColor: Colors.white30, | ||
| 376 | - onChanged: (value) async { | ||
| 377 | - setState(() { | ||
| 378 | - _currentExposureOffset = value; | ||
| 379 | - }); | ||
| 380 | - await controller! | ||
| 381 | - .setExposureOffset(value); | ||
| 382 | - }, | ||
| 383 | - ), | ||
| 384 | - ), | ||
| 385 | - ), | ||
| 386 | - ), | ||
| 387 | - Row( | ||
| 388 | children: [ | 292 | children: [ |
| 389 | - Expanded( | 293 | + const Icon( |
| 390 | - child: Slider( | 294 | + Icons.circle, |
| 391 | - value: _currentZoomLevel, | 295 | + color: Colors.black38, |
| 392 | - min: _minAvailableZoom, | 296 | + size: 60, |
| 393 | - max: _maxAvailableZoom, | ||
| 394 | - activeColor: Colors.white, | ||
| 395 | - inactiveColor: Colors.white30, | ||
| 396 | - onChanged: (value) async { | ||
| 397 | - setState(() { | ||
| 398 | - _currentZoomLevel = value; | ||
| 399 | - }); | ||
| 400 | - await controller!.setZoomLevel(value); | ||
| 401 | - }, | ||
| 402 | - ), | ||
| 403 | ), | 297 | ), |
| 404 | - Padding( | 298 | + _isRecordingInProgress |
| 405 | - padding: const EdgeInsets.only(right: 8.0), | 299 | + ? controller!.value.isRecordingPaused |
| 406 | - child: Container( | 300 | + ? const Icon( |
| 407 | - decoration: BoxDecoration( | 301 | + Icons.play_arrow, |
| 408 | - color: Colors.black87, | 302 | + color: Colors.white, |
| 409 | - borderRadius: | 303 | + size: 30, |
| 410 | - BorderRadius.circular(10.0), | 304 | + ) |
| 411 | - ), | 305 | + : const Icon( |
| 412 | - child: Padding( | 306 | + Icons.pause, |
| 413 | - padding: const EdgeInsets.all(8.0), | 307 | + color: Colors.white, |
| 414 | - child: Text( | 308 | + size: 30, |
| 415 | - _currentZoomLevel.toStringAsFixed(1) + | 309 | + ) |
| 416 | - 'x', | 310 | + : Icon( |
| 417 | - style: const TextStyle( | 311 | + _isRearCameraSelected |
| 418 | - color: Colors.white), | 312 | + ? Icons.camera_front |
| 313 | + : Icons.camera_rear, | ||
| 314 | + color: Colors.white, | ||
| 315 | + size: 30, | ||
| 419 | ), | 316 | ), |
| 420 | - ), | ||
| 421 | - ), | ||
| 422 | - ), | ||
| 423 | ], | 317 | ], |
| 424 | ), | 318 | ), |
| 425 | - Row( | 319 | + ), |
| 426 | - mainAxisAlignment: | 320 | + InkWell( |
| 427 | - MainAxisAlignment.spaceBetween, | 321 | + onTap: () async { |
| 322 | + if (_isRecordingInProgress) { | ||
| 323 | + XFile? rawVideo = await stopVideoRecording(); | ||
| 324 | + File videoFile = File(rawVideo!.path); | ||
| 325 | + | ||
| 326 | + int currentUnix = | ||
| 327 | + DateTime.now().millisecondsSinceEpoch; | ||
| 328 | + | ||
| 329 | + final directory = | ||
| 330 | + await getApplicationDocumentsDirectory(); | ||
| 331 | + | ||
| 332 | + String fileFormat = | ||
| 333 | + videoFile.path.split('.').last; | ||
| 334 | + | ||
| 335 | + _videoFile = await videoFile.copy( | ||
| 336 | + '${directory.path}/$currentUnix.$fileFormat', | ||
| 337 | + ); | ||
| 338 | + | ||
| 339 | + _startVideoPlayer(); | ||
| 340 | + } else { | ||
| 341 | + await startVideoRecording(); | ||
| 342 | + } | ||
| 343 | + }, | ||
| 344 | + child: Stack( | ||
| 345 | + alignment: Alignment.center, | ||
| 428 | children: [ | 346 | children: [ |
| 429 | - InkWell( | 347 | + Icon( |
| 430 | - onTap: _isRecordingInProgress | 348 | + Icons.circle, |
| 431 | - ? () async { | 349 | + color: _isVideoCameraSelected |
| 432 | - if (controller! | 350 | + ? Colors.white |
| 433 | - .value.isRecordingPaused) { | 351 | + : Colors.white38, |
| 434 | - await resumeVideoRecording(); | 352 | + size: 80, |
| 435 | - } else { | ||
| 436 | - await pauseVideoRecording(); | ||
| 437 | - } | ||
| 438 | - } | ||
| 439 | - : () { | ||
| 440 | - setState(() { | ||
| 441 | - _isCameraInitialized = false; | ||
| 442 | - }); | ||
| 443 | - onNewCameraSelected(cameras![ | ||
| 444 | - _isRearCameraSelected ? 1 : 0]); | ||
| 445 | - setState(() { | ||
| 446 | - _isRearCameraSelected = | ||
| 447 | - !_isRearCameraSelected; | ||
| 448 | - }); | ||
| 449 | - }, | ||
| 450 | - child: Stack( | ||
| 451 | - alignment: Alignment.center, | ||
| 452 | - children: [ | ||
| 453 | - const Icon( | ||
| 454 | - Icons.circle, | ||
| 455 | - color: Colors.black38, | ||
| 456 | - size: 60, | ||
| 457 | - ), | ||
| 458 | - _isRecordingInProgress | ||
| 459 | - ? controller! | ||
| 460 | - .value.isRecordingPaused | ||
| 461 | - ? const Icon( | ||
| 462 | - Icons.play_arrow, | ||
| 463 | - color: Colors.white, | ||
| 464 | - size: 30, | ||
| 465 | - ) | ||
| 466 | - : const Icon( | ||
| 467 | - Icons.pause, | ||
| 468 | - color: Colors.white, | ||
| 469 | - size: 30, | ||
| 470 | - ) | ||
| 471 | - : Icon( | ||
| 472 | - _isRearCameraSelected | ||
| 473 | - ? Icons.camera_front | ||
| 474 | - : Icons.camera_rear, | ||
| 475 | - color: Colors.white, | ||
| 476 | - size: 30, | ||
| 477 | - ), | ||
| 478 | - ], | ||
| 479 | - ), | ||
| 480 | ), | 353 | ), |
| 481 | - InkWell( | 354 | + Icon( |
| 482 | - onTap: _isVideoCameraSelected | 355 | + Icons.circle, |
| 483 | - ? () async { | 356 | + color: _isVideoCameraSelected |
| 484 | - if (_isRecordingInProgress) { | 357 | + ? Colors.red |
| 485 | - XFile? rawVideo = | 358 | + : Colors.white, |
| 486 | - await stopVideoRecording(); | 359 | + size: 65, |
| 487 | - File videoFile = | ||
| 488 | - File(rawVideo!.path); | ||
| 489 | - | ||
| 490 | - int currentUnix = DateTime.now() | ||
| 491 | - .millisecondsSinceEpoch; | ||
| 492 | - | ||
| 493 | - final directory = | ||
| 494 | - await getApplicationDocumentsDirectory(); | ||
| 495 | - | ||
| 496 | - String fileFormat = videoFile.path | ||
| 497 | - .split('.') | ||
| 498 | - .last; | ||
| 499 | - | ||
| 500 | - _videoFile = await videoFile.copy( | ||
| 501 | - '${directory.path}/$currentUnix.$fileFormat', | ||
| 502 | - ); | ||
| 503 | - | ||
| 504 | - _startVideoPlayer(); | ||
| 505 | - } else { | ||
| 506 | - await startVideoRecording(); | ||
| 507 | - } | ||
| 508 | - } | ||
| 509 | - : () async { | ||
| 510 | - XFile? rawImage = | ||
| 511 | - await takePicture(); | ||
| 512 | - File imageFile = | ||
| 513 | - File(rawImage!.path); | ||
| 514 | - | ||
| 515 | - int currentUnix = DateTime.now() | ||
| 516 | - .millisecondsSinceEpoch; | ||
| 517 | - | ||
| 518 | - final directory = | ||
| 519 | - await getApplicationDocumentsDirectory(); | ||
| 520 | - | ||
| 521 | - String fileFormat = | ||
| 522 | - imageFile.path.split('.').last; | ||
| 523 | - await imageFile.copy( | ||
| 524 | - '${directory.path}/$currentUnix.$fileFormat', | ||
| 525 | - ); | ||
| 526 | - | ||
| 527 | - refreshAlreadyCapturedImages(); | ||
| 528 | - }, | ||
| 529 | - child: Stack( | ||
| 530 | - alignment: Alignment.center, | ||
| 531 | - children: [ | ||
| 532 | - Icon( | ||
| 533 | - Icons.circle, | ||
| 534 | - color: _isVideoCameraSelected | ||
| 535 | - ? Colors.white | ||
| 536 | - : Colors.white38, | ||
| 537 | - size: 80, | ||
| 538 | - ), | ||
| 539 | - Icon( | ||
| 540 | - Icons.circle, | ||
| 541 | - color: _isVideoCameraSelected | ||
| 542 | - ? Colors.red | ||
| 543 | - : Colors.white, | ||
| 544 | - size: 65, | ||
| 545 | - ), | ||
| 546 | - _isVideoCameraSelected && | ||
| 547 | - _isRecordingInProgress | ||
| 548 | - ? const Icon( | ||
| 549 | - Icons.stop_rounded, | ||
| 550 | - color: Colors.white, | ||
| 551 | - size: 32, | ||
| 552 | - ) | ||
| 553 | - : Container(), | ||
| 554 | - ], | ||
| 555 | - ), | ||
| 556 | ), | 360 | ), |
| 557 | - InkWell( | 361 | + _isVideoCameraSelected && |
| 558 | - onTap: | 362 | + _isRecordingInProgress |
| 559 | - _imageFile != null || _videoFile != null | 363 | + ? const Icon( |
| 560 | - ? () { | 364 | + Icons.stop_rounded, |
| 561 | - Navigator.of(context).push( | ||
| 562 | - MaterialPageRoute( | ||
| 563 | - builder: (context) => | ||
| 564 | - PreviewScreen( | ||
| 565 | - imageFile: _imageFile!, | ||
| 566 | - fileList: allFileList, | ||
| 567 | - ), | ||
| 568 | - ), | ||
| 569 | - ); | ||
| 570 | - } | ||
| 571 | - : null, | ||
| 572 | - child: Container( | ||
| 573 | - width: 60, | ||
| 574 | - height: 60, | ||
| 575 | - decoration: BoxDecoration( | ||
| 576 | - color: Colors.black, | ||
| 577 | - borderRadius: | ||
| 578 | - BorderRadius.circular(10.0), | ||
| 579 | - border: Border.all( | ||
| 580 | color: Colors.white, | 365 | color: Colors.white, |
| 581 | - width: 2, | 366 | + size: 32, |
| 582 | - ), | 367 | + ) |
| 583 | - image: _imageFile != null | 368 | + : Container(), |
| 584 | - ? DecorationImage( | ||
| 585 | - image: FileImage(_imageFile!), | ||
| 586 | - fit: BoxFit.cover, | ||
| 587 | - ) | ||
| 588 | - : null, | ||
| 589 | - ), | ||
| 590 | - child: videoController != null && | ||
| 591 | - videoController! | ||
| 592 | - .value.isInitialized | ||
| 593 | - ? ClipRRect( | ||
| 594 | - borderRadius: | ||
| 595 | - BorderRadius.circular(8.0), | ||
| 596 | - child: AspectRatio( | ||
| 597 | - aspectRatio: videoController! | ||
| 598 | - .value.aspectRatio, | ||
| 599 | - child: VideoPlayer( | ||
| 600 | - videoController!), | ||
| 601 | - ), | ||
| 602 | - ) | ||
| 603 | - : Container(), | ||
| 604 | - ), | ||
| 605 | - ), | ||
| 606 | ], | 369 | ], |
| 607 | ), | 370 | ), |
| 608 | - ], | ||
| 609 | - ), | ||
| 610 | - ), | ||
| 611 | - ], | ||
| 612 | - ), | ||
| 613 | - ), | ||
| 614 | - Expanded( | ||
| 615 | - child: SingleChildScrollView( | ||
| 616 | - physics: const BouncingScrollPhysics(), | ||
| 617 | - child: Column( | ||
| 618 | - children: [ | ||
| 619 | - Padding( | ||
| 620 | - padding: const EdgeInsets.only(top: 8.0), | ||
| 621 | - child: Row( | ||
| 622 | - children: [ | ||
| 623 | - Expanded( | ||
| 624 | - child: Padding( | ||
| 625 | - padding: const EdgeInsets.only( | ||
| 626 | - left: 8.0, | ||
| 627 | - right: 4.0, | ||
| 628 | - ), | ||
| 629 | - child: TextButton( | ||
| 630 | - onPressed: _isRecordingInProgress | ||
| 631 | - ? null | ||
| 632 | - : () { | ||
| 633 | - if (_isVideoCameraSelected) { | ||
| 634 | - setState(() { | ||
| 635 | - _isVideoCameraSelected = | ||
| 636 | - false; | ||
| 637 | - }); | ||
| 638 | - } | ||
| 639 | - }, | ||
| 640 | - style: TextButton.styleFrom( | ||
| 641 | - primary: _isVideoCameraSelected | ||
| 642 | - ? Colors.black54 | ||
| 643 | - : Colors.black, | ||
| 644 | - backgroundColor: _isVideoCameraSelected | ||
| 645 | - ? Colors.white30 | ||
| 646 | - : Colors.white, | ||
| 647 | - ), | ||
| 648 | - child: const Text('IMAGE'), | ||
| 649 | - ), | ||
| 650 | - ), | ||
| 651 | - ), | ||
| 652 | - Expanded( | ||
| 653 | - child: Padding( | ||
| 654 | - padding: const EdgeInsets.only( | ||
| 655 | - left: 4.0, right: 8.0), | ||
| 656 | - child: TextButton( | ||
| 657 | - onPressed: () { | ||
| 658 | - if (!_isVideoCameraSelected) { | ||
| 659 | - setState(() { | ||
| 660 | - _isVideoCameraSelected = true; | ||
| 661 | - }); | ||
| 662 | - } | ||
| 663 | - }, | ||
| 664 | - style: TextButton.styleFrom( | ||
| 665 | - primary: _isVideoCameraSelected | ||
| 666 | - ? Colors.black | ||
| 667 | - : Colors.black54, | ||
| 668 | - backgroundColor: _isVideoCameraSelected | ||
| 669 | - ? Colors.white | ||
| 670 | - : Colors.white30, | ||
| 671 | - ), | ||
| 672 | - child: const Text('VIDEO'), | ||
| 673 | - ), | ||
| 674 | - ), | ||
| 675 | - ), | ||
| 676 | - ], | ||
| 677 | ), | 371 | ), |
| 678 | - ), | 372 | + InkWell( |
| 679 | - Padding( | 373 | + onTap: _imageFile != null || _videoFile != null |
| 680 | - padding: | 374 | + ? () { |
| 681 | - const EdgeInsets.fromLTRB(16.0, 8.0, 16.0, 8.0), | 375 | + Navigator.of(context).push( |
| 682 | - child: Row( | 376 | + MaterialPageRoute( |
| 683 | - mainAxisAlignment: MainAxisAlignment.spaceBetween, | 377 | + builder: (context) => PreviewScreen( |
| 684 | - children: [ | 378 | + imageFile: _imageFile!, |
| 685 | - InkWell( | 379 | + fileList: allFileList, |
| 686 | - onTap: () async { | 380 | + ), |
| 687 | - setState(() { | 381 | + ), |
| 688 | - _currentFlashMode = FlashMode.off; | 382 | + ); |
| 689 | - }); | 383 | + } |
| 690 | - await controller!.setFlashMode( | 384 | + : null, |
| 691 | - FlashMode.off, | 385 | + child: Container( |
| 692 | - ); | 386 | + width: 60, |
| 693 | - }, | 387 | + height: 60, |
| 694 | - child: Icon( | 388 | + decoration: BoxDecoration( |
| 695 | - Icons.flash_off, | 389 | + color: Colors.black, |
| 696 | - color: _currentFlashMode == FlashMode.off | 390 | + borderRadius: BorderRadius.circular(10.0), |
| 697 | - ? Colors.amber | 391 | + border: Border.all( |
| 698 | - : Colors.white, | 392 | + color: Colors.white, |
| 699 | - ), | 393 | + width: 2, |
| 700 | - ), | ||
| 701 | - InkWell( | ||
| 702 | - onTap: () async { | ||
| 703 | - setState(() { | ||
| 704 | - _currentFlashMode = FlashMode.auto; | ||
| 705 | - }); | ||
| 706 | - await controller!.setFlashMode( | ||
| 707 | - FlashMode.auto, | ||
| 708 | - ); | ||
| 709 | - }, | ||
| 710 | - child: Icon( | ||
| 711 | - Icons.flash_auto, | ||
| 712 | - color: _currentFlashMode == FlashMode.auto | ||
| 713 | - ? Colors.amber | ||
| 714 | - : Colors.white, | ||
| 715 | - ), | ||
| 716 | - ), | ||
| 717 | - InkWell( | ||
| 718 | - onTap: () async { | ||
| 719 | - setState(() { | ||
| 720 | - _currentFlashMode = FlashMode.always; | ||
| 721 | - }); | ||
| 722 | - await controller!.setFlashMode( | ||
| 723 | - FlashMode.always, | ||
| 724 | - ); | ||
| 725 | - }, | ||
| 726 | - child: Icon( | ||
| 727 | - Icons.flash_on, | ||
| 728 | - color: _currentFlashMode == FlashMode.always | ||
| 729 | - ? Colors.amber | ||
| 730 | - : Colors.white, | ||
| 731 | - ), | ||
| 732 | - ), | ||
| 733 | - InkWell( | ||
| 734 | - onTap: () async { | ||
| 735 | - setState(() { | ||
| 736 | - _currentFlashMode = FlashMode.torch; | ||
| 737 | - }); | ||
| 738 | - await controller!.setFlashMode( | ||
| 739 | - FlashMode.torch, | ||
| 740 | - ); | ||
| 741 | - }, | ||
| 742 | - child: Icon( | ||
| 743 | - Icons.highlight, | ||
| 744 | - color: _currentFlashMode == FlashMode.torch | ||
| 745 | - ? Colors.amber | ||
| 746 | - : Colors.white, | ||
| 747 | ), | 394 | ), |
| 395 | + image: _imageFile != null | ||
| 396 | + ? DecorationImage( | ||
| 397 | + image: FileImage(_imageFile!), | ||
| 398 | + fit: BoxFit.cover, | ||
| 399 | + ) | ||
| 400 | + : null, | ||
| 748 | ), | 401 | ), |
| 749 | - ], | 402 | + child: videoController != null && |
| 403 | + videoController!.value.isInitialized | ||
| 404 | + ? ClipRRect( | ||
| 405 | + borderRadius: | ||
| 406 | + BorderRadius.circular(8.0), | ||
| 407 | + child: AspectRatio( | ||
| 408 | + aspectRatio: videoController! | ||
| 409 | + .value.aspectRatio, | ||
| 410 | + child: VideoPlayer(videoController!), | ||
| 411 | + ), | ||
| 412 | + ) | ||
| 413 | + : Container(), | ||
| 414 | + ), | ||
| 750 | ), | 415 | ), |
| 751 | - ) | 416 | + ], |
| 752 | - ], | 417 | + ), |
| 753 | - ), | 418 | + ], |
| 754 | ), | 419 | ), |
| 755 | ), | 420 | ), |
| 756 | ], | 421 | ], |
| 757 | ) | 422 | ) |
| 758 | : const Center( | 423 | : const Center( |
| 759 | child: Text( | 424 | child: Text( |
| 760 | - 'LOADING', | 425 | + '开启摄像头..', |
| 761 | style: TextStyle(color: Colors.white), | 426 | style: TextStyle(color: Colors.white), |
| 762 | ), | 427 | ), |
| 763 | ), | 428 | ), | ... | ... |
| ... | @@ -32,7 +32,7 @@ class PreviewScreen extends StatelessWidget { | ... | @@ -32,7 +32,7 @@ class PreviewScreen extends StatelessWidget { |
| 32 | ), | 32 | ), |
| 33 | ); | 33 | ); |
| 34 | }, | 34 | }, |
| 35 | - child: Text('Go to all captures'), | 35 | + child: const Text('打开全部视频'), |
| 36 | style: TextButton.styleFrom( | 36 | style: TextButton.styleFrom( |
| 37 | primary: Colors.black, | 37 | primary: Colors.black, |
| 38 | backgroundColor: Colors.white, | 38 | backgroundColor: Colors.white, | ... | ... |
| ... | @@ -1118,7 +1118,7 @@ packages: | ... | @@ -1118,7 +1118,7 @@ packages: |
| 1118 | name: url_launcher_macos | 1118 | name: url_launcher_macos |
| 1119 | url: "https://pub.dartlang.org" | 1119 | url: "https://pub.dartlang.org" |
| 1120 | source: hosted | 1120 | source: hosted |
| 1121 | - version: "2.0.2" | 1121 | + version: "2.0.3" |
| 1122 | url_launcher_platform_interface: | 1122 | url_launcher_platform_interface: |
| 1123 | dependency: transitive | 1123 | dependency: transitive |
| 1124 | description: | 1124 | description: |
| ... | @@ -1181,7 +1181,7 @@ packages: | ... | @@ -1181,7 +1181,7 @@ packages: |
| 1181 | name: video_player | 1181 | name: video_player |
| 1182 | url: "https://pub.dartlang.org" | 1182 | url: "https://pub.dartlang.org" |
| 1183 | source: hosted | 1183 | source: hosted |
| 1184 | - version: "2.2.13" | 1184 | + version: "2.2.15" |
| 1185 | video_player_platform_interface: | 1185 | video_player_platform_interface: |
| 1186 | dependency: transitive | 1186 | dependency: transitive |
| 1187 | description: | 1187 | description: | ... | ... |
-
Please register or login to post a comment