mirror of
https://github.com/Myzel394/quid_faciam_hodie.git
synced 2025-06-19 07:35:26 +02:00
improved today button
This commit is contained in:
parent
24927627ab
commit
e49c8f8211
@ -35,7 +35,6 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
bool isRecording = false;
|
bool isRecording = false;
|
||||||
bool lockCamera = false;
|
bool lockCamera = false;
|
||||||
bool isTorchEnabled = false;
|
bool isTorchEnabled = false;
|
||||||
List? lastPhoto;
|
|
||||||
Uint8List? uploadingPhotoAnimation;
|
Uint8List? uploadingPhotoAnimation;
|
||||||
List<double>? zoomLevels;
|
List<double>? zoomLevels;
|
||||||
|
|
||||||
@ -62,7 +61,6 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
getLastPhoto();
|
|
||||||
onNewCameraSelected(GlobalValuesManager.cameras[0]);
|
onNewCameraSelected(GlobalValuesManager.cameras[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,14 +99,6 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getLastPhoto() async {
|
|
||||||
final data = await FileManager.getLastFile(_user);
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
lastPhoto = data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void onNewCameraSelected(final CameraDescription cameraDescription) async {
|
void onNewCameraSelected(final CameraDescription cameraDescription) async {
|
||||||
final previousCameraController = controller;
|
final previousCameraController = controller;
|
||||||
// Instantiating the camera controller
|
// Instantiating the camera controller
|
||||||
@ -198,10 +188,6 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
uploadingPhotoAnimation = null;
|
uploadingPhotoAnimation = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
await getLastPhoto();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> takeVideo() async {
|
Future<void> takeVideo() async {
|
||||||
@ -240,10 +226,6 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
lockCamera = false;
|
lockCamera = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
await getLastPhoto();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -362,8 +344,6 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
opacityDuration: DEFAULT_OPACITY_DURATION *
|
opacityDuration: DEFAULT_OPACITY_DURATION *
|
||||||
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
SECONDARY_BUTTONS_DURATION_MULTIPLIER,
|
||||||
child: TodayPhotoButton(
|
child: TodayPhotoButton(
|
||||||
data: lastPhoto == null ? null : lastPhoto![0],
|
|
||||||
type: lastPhoto == null ? null : lastPhoto![1],
|
|
||||||
onLeave: () {
|
onLeave: () {
|
||||||
controller!.setFlashMode(FlashMode.off);
|
controller!.setFlashMode(FlashMode.off);
|
||||||
},
|
},
|
||||||
@ -436,7 +416,7 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: zoomLevels == null
|
child: zoomLevels == null
|
||||||
? Text('1x')
|
? const Text('1x')
|
||||||
: Text(
|
: Text(
|
||||||
formatZoomLevel(currentZoomLevel),
|
formatZoomLevel(currentZoomLevel),
|
||||||
),
|
),
|
||||||
|
@ -62,6 +62,10 @@ class _RawMemoryDisplayState extends State<RawMemoryDisplay> {
|
|||||||
|
|
||||||
videoController = VideoPlayerController.file(file);
|
videoController = VideoPlayerController.file(file);
|
||||||
videoController!.initialize().then((value) {
|
videoController!.initialize().then((value) {
|
||||||
|
if (!mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
videoController!.setLooping(widget.loopVideo);
|
videoController!.setLooping(widget.loopVideo);
|
||||||
videoController!.play();
|
videoController!.play();
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:quid_faciam_hodie/constants/spacing.dart';
|
import 'package:quid_faciam_hodie/constants/spacing.dart';
|
||||||
import 'package:quid_faciam_hodie/enums.dart';
|
import 'package:quid_faciam_hodie/enums.dart';
|
||||||
|
import 'package:quid_faciam_hodie/models/memories.dart';
|
||||||
import 'package:quid_faciam_hodie/screens/server_loading_screen.dart';
|
import 'package:quid_faciam_hodie/screens/server_loading_screen.dart';
|
||||||
import 'package:quid_faciam_hodie/screens/timeline_screen.dart';
|
import 'package:quid_faciam_hodie/screens/timeline_screen.dart';
|
||||||
|
|
||||||
import 'raw_memory_display.dart';
|
import 'raw_memory_display.dart';
|
||||||
|
|
||||||
class TodayPhotoButton extends StatelessWidget {
|
class TodayPhotoButton extends StatefulWidget {
|
||||||
final Uint8List? data;
|
|
||||||
final MemoryType? type;
|
|
||||||
final VoidCallback onLeave;
|
final VoidCallback onLeave;
|
||||||
final VoidCallback onComeBack;
|
final VoidCallback onComeBack;
|
||||||
|
|
||||||
@ -18,26 +18,70 @@ class TodayPhotoButton extends StatelessWidget {
|
|||||||
Key? key,
|
Key? key,
|
||||||
required this.onLeave,
|
required this.onLeave,
|
||||||
required this.onComeBack,
|
required this.onComeBack,
|
||||||
this.data,
|
|
||||||
this.type,
|
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TodayPhotoButton> createState() => _TodayPhotoButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TodayPhotoButtonState extends State<TodayPhotoButton> {
|
||||||
|
Uint8List? data;
|
||||||
|
MemoryType? type;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
final memories = context.read<Memories>();
|
||||||
|
|
||||||
|
memories.addListener(loadMemory, ['memories']);
|
||||||
|
|
||||||
|
loadMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
final memories = context.read<Memories>();
|
||||||
|
|
||||||
|
memories.removeListener(loadMemory);
|
||||||
|
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadMemory() async {
|
||||||
|
if (!mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final memories = context.read<Memories>();
|
||||||
|
|
||||||
|
final lastMemory = memories.memories.first;
|
||||||
|
|
||||||
|
final file = await lastMemory.downloadToFile();
|
||||||
|
final memoryData = await file.readAsBytes();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
data = memoryData;
|
||||||
|
type = lastMemory.type;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
onLeave();
|
widget.onLeave();
|
||||||
|
|
||||||
await Navigator.push(
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => ServerLoadingScreen(
|
builder: (context) => const ServerLoadingScreen(
|
||||||
nextScreen: TimelineScreen.ID,
|
nextScreen: TimelineScreen.ID,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
onComeBack();
|
widget.onComeBack();
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 45,
|
width: 45,
|
||||||
@ -53,7 +97,7 @@ class TodayPhotoButton extends StatelessWidget {
|
|||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(SMALL_SPACE),
|
borderRadius: BorderRadius.circular(SMALL_SPACE),
|
||||||
child: (data == null || type == null)
|
child: (data == null || type == null)
|
||||||
? const SizedBox()
|
? const SizedBox.shrink()
|
||||||
: RawMemoryDisplay(
|
: RawMemoryDisplay(
|
||||||
data: data!,
|
data: data!,
|
||||||
type: type!,
|
type: type!,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user