mirror of
https://github.com/Myzel394/quid_faciam_hodie.git
synced 2025-06-19 07:35:26 +02:00
added torch button
This commit is contained in:
parent
90a52ec9a6
commit
fc19c81127
@ -2,6 +2,7 @@ import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:expandable_bottom_sheet/expandable_bottom_sheet.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:share_location/constants/spacing.dart';
|
||||
import 'package:share_location/constants/values.dart';
|
||||
@ -30,6 +31,7 @@ class MainScreen extends StatefulWidget {
|
||||
class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
||||
bool isRecording = false;
|
||||
bool lockCamera = false;
|
||||
bool isTorchEnabled = false;
|
||||
List? lastPhoto;
|
||||
Uint8List? uploadingPhotoAnimation;
|
||||
|
||||
@ -208,23 +210,26 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
body: SafeArea(
|
||||
child: () {
|
||||
bottomSheet: () {
|
||||
if (isLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
return Container(
|
||||
color: Colors.black,
|
||||
child: ExpandableBottomSheet(
|
||||
background: SafeArea(
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
children: <Widget>[
|
||||
AnimateInBuilder(
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: AnimateInBuilder(
|
||||
builder: (showPreview) => AnimatedOpacity(
|
||||
opacity: showPreview ? 1.0 : 0.0,
|
||||
duration: const Duration(milliseconds: 1100),
|
||||
@ -238,34 +243,48 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: LARGE_SPACE),
|
||||
),
|
||||
if (uploadingPhotoAnimation != null)
|
||||
UploadingPhoto(
|
||||
data: uploadingPhotoAnimation!,
|
||||
onDone: () {
|
||||
setState(() {
|
||||
uploadingPhotoAnimation = null;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
persistentHeader: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(LARGE_SPACE),
|
||||
topRight: Radius.circular(LARGE_SPACE),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(LARGE_SPACE),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
FadeAndMoveInAnimation(
|
||||
translationDuration:
|
||||
DEFAULT_TRANSLATION_DURATION *
|
||||
translationDuration: DEFAULT_TRANSLATION_DURATION *
|
||||
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
||||
opacityDuration: DEFAULT_OPACITY_DURATION *
|
||||
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
||||
child: ChangeCameraButton(
|
||||
onChangeCamera: () {
|
||||
final currentCameraIndex =
|
||||
GlobalValuesManager.cameras
|
||||
final currentCameraIndex = GlobalValuesManager.cameras
|
||||
.indexOf(controller!.description);
|
||||
final availableCameras =
|
||||
GlobalValuesManager.cameras.length;
|
||||
|
||||
onNewCameraSelected(
|
||||
GlobalValuesManager.cameras[
|
||||
(currentCameraIndex + 1) %
|
||||
availableCameras],
|
||||
(currentCameraIndex + 1) % availableCameras],
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -291,8 +310,7 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
||||
),
|
||||
),
|
||||
FadeAndMoveInAnimation(
|
||||
translationDuration:
|
||||
DEFAULT_TRANSLATION_DURATION *
|
||||
translationDuration: DEFAULT_TRANSLATION_DURATION *
|
||||
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
||||
opacityDuration: DEFAULT_OPACITY_DURATION *
|
||||
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
||||
@ -305,26 +323,41 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
expandableContent: Padding(
|
||||
padding: const EdgeInsets.all(LARGE_SPACE),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.flashlight_on_rounded),
|
||||
label: const Text('Torch'),
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
||||
(_) => isTorchEnabled ? Colors.white : Colors.black,
|
||||
),
|
||||
if (uploadingPhotoAnimation != null)
|
||||
UploadingPhoto(
|
||||
data: uploadingPhotoAnimation!,
|
||||
onDone: () {
|
||||
foregroundColor: MaterialStateProperty.resolveWith<Color>(
|
||||
(_) => isTorchEnabled ? Colors.black : Colors.white,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
uploadingPhotoAnimation = null;
|
||||
isTorchEnabled = !isTorchEnabled;
|
||||
|
||||
if (isTorchEnabled) {
|
||||
controller!.setFlashMode(FlashMode.torch);
|
||||
} else {
|
||||
controller!.setFlashMode(FlashMode.off);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +106,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
expandable_bottom_sheet:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: expandable_bottom_sheet
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.1+1"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -48,6 +48,7 @@ dependencies:
|
||||
provider: ^6.0.3
|
||||
gallery_saver: ^2.3.2
|
||||
fluttertoast: ^8.0.9
|
||||
expandable_bottom_sheet: ^1.1.1+1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
x
Reference in New Issue
Block a user