mirror of
https://github.com/Myzel394/quid_faciam_hodie.git
synced 2025-06-19 15:45: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 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:camera/camera.dart';
|
import 'package:camera/camera.dart';
|
||||||
|
import 'package:expandable_bottom_sheet/expandable_bottom_sheet.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:share_location/constants/spacing.dart';
|
import 'package:share_location/constants/spacing.dart';
|
||||||
import 'package:share_location/constants/values.dart';
|
import 'package:share_location/constants/values.dart';
|
||||||
@ -30,6 +31,7 @@ class MainScreen extends StatefulWidget {
|
|||||||
class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
||||||
bool isRecording = false;
|
bool isRecording = false;
|
||||||
bool lockCamera = false;
|
bool lockCamera = false;
|
||||||
|
bool isTorchEnabled = false;
|
||||||
List? lastPhoto;
|
List? lastPhoto;
|
||||||
Uint8List? uploadingPhotoAnimation;
|
Uint8List? uploadingPhotoAnimation;
|
||||||
|
|
||||||
@ -208,23 +210,26 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
body: SafeArea(
|
bottomSheet: () {
|
||||||
child: () {
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SizedBox(
|
return Container(
|
||||||
|
color: Colors.black,
|
||||||
|
child: ExpandableBottomSheet(
|
||||||
|
background: SafeArea(
|
||||||
|
child: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Column(
|
Align(
|
||||||
children: <Widget>[
|
alignment: Alignment.topCenter,
|
||||||
AnimateInBuilder(
|
child: AnimateInBuilder(
|
||||||
builder: (showPreview) => AnimatedOpacity(
|
builder: (showPreview) => AnimatedOpacity(
|
||||||
opacity: showPreview ? 1.0 : 0.0,
|
opacity: showPreview ? 1.0 : 0.0,
|
||||||
duration: const Duration(milliseconds: 1100),
|
duration: const Duration(milliseconds: 1100),
|
||||||
@ -238,34 +243,48 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
),
|
||||||
child: Column(
|
if (uploadingPhotoAnimation != null)
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
UploadingPhoto(
|
||||||
children: <Widget>[
|
data: uploadingPhotoAnimation!,
|
||||||
Padding(
|
onDone: () {
|
||||||
padding: const EdgeInsets.symmetric(
|
setState(() {
|
||||||
horizontal: LARGE_SPACE),
|
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(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
FadeAndMoveInAnimation(
|
FadeAndMoveInAnimation(
|
||||||
translationDuration:
|
translationDuration: DEFAULT_TRANSLATION_DURATION *
|
||||||
DEFAULT_TRANSLATION_DURATION *
|
|
||||||
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
||||||
opacityDuration: DEFAULT_OPACITY_DURATION *
|
opacityDuration: DEFAULT_OPACITY_DURATION *
|
||||||
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
||||||
child: ChangeCameraButton(
|
child: ChangeCameraButton(
|
||||||
onChangeCamera: () {
|
onChangeCamera: () {
|
||||||
final currentCameraIndex =
|
final currentCameraIndex = GlobalValuesManager.cameras
|
||||||
GlobalValuesManager.cameras
|
|
||||||
.indexOf(controller!.description);
|
.indexOf(controller!.description);
|
||||||
final availableCameras =
|
final availableCameras =
|
||||||
GlobalValuesManager.cameras.length;
|
GlobalValuesManager.cameras.length;
|
||||||
|
|
||||||
onNewCameraSelected(
|
onNewCameraSelected(
|
||||||
GlobalValuesManager.cameras[
|
GlobalValuesManager.cameras[
|
||||||
(currentCameraIndex + 1) %
|
(currentCameraIndex + 1) % availableCameras],
|
||||||
availableCameras],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -291,8 +310,7 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
FadeAndMoveInAnimation(
|
FadeAndMoveInAnimation(
|
||||||
translationDuration:
|
translationDuration: DEFAULT_TRANSLATION_DURATION *
|
||||||
DEFAULT_TRANSLATION_DURATION *
|
|
||||||
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
||||||
opacityDuration: DEFAULT_OPACITY_DURATION *
|
opacityDuration: DEFAULT_OPACITY_DURATION *
|
||||||
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
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)
|
foregroundColor: MaterialStateProperty.resolveWith<Color>(
|
||||||
UploadingPhoto(
|
(_) => isTorchEnabled ? Colors.black : Colors.white,
|
||||||
data: uploadingPhotoAnimation!,
|
),
|
||||||
onDone: () {
|
),
|
||||||
|
onPressed: () {
|
||||||
setState(() {
|
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"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
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:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -48,6 +48,7 @@ dependencies:
|
|||||||
provider: ^6.0.3
|
provider: ^6.0.3
|
||||||
gallery_saver: ^2.3.2
|
gallery_saver: ^2.3.2
|
||||||
fluttertoast: ^8.0.9
|
fluttertoast: ^8.0.9
|
||||||
|
expandable_bottom_sheet: ^1.1.1+1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user