2021-12-24 14:18:09 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2021-12-25 08:56:35 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2021-12-24 14:18:09 +01:00
|
|
|
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
import 'package:video_player/video_player.dart';
|
|
|
|
|
|
|
|
import 'add_story.dart';
|
|
|
|
|
|
|
|
class AddStoryView extends StatelessWidget {
|
|
|
|
final AddStoryController controller;
|
|
|
|
const AddStoryView(this.controller, {Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final video = controller.videoPlayerController;
|
2022-02-20 10:24:23 +01:00
|
|
|
|
2021-12-24 14:18:09 +01:00
|
|
|
return Scaffold(
|
2021-12-27 17:16:35 +01:00
|
|
|
backgroundColor: Colors.blueGrey.shade900,
|
2021-12-24 14:18:09 +01:00
|
|
|
appBar: AppBar(
|
2021-12-25 08:56:35 +01:00
|
|
|
systemOverlayStyle: SystemUiOverlayStyle.light,
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
elevation: 0,
|
|
|
|
iconTheme: const IconThemeData(color: Colors.white),
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context)!.addToStory,
|
|
|
|
style: const TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
shadows: [
|
|
|
|
Shadow(
|
|
|
|
color: Colors.black,
|
|
|
|
offset: Offset(0, 0),
|
|
|
|
blurRadius: 5,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-02-05 09:58:47 +01:00
|
|
|
actions: [
|
|
|
|
if (controller.hasMedia)
|
|
|
|
IconButton(
|
2022-02-20 10:24:23 +01:00
|
|
|
icon: const Icon(Icons.fullscreen_outlined),
|
|
|
|
onPressed: controller.toggleBoxFit,
|
|
|
|
),
|
|
|
|
if (!controller.hasMedia)
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.color_lens_outlined),
|
|
|
|
onPressed: controller.updateColor,
|
2022-02-05 09:58:47 +01:00
|
|
|
),
|
2022-02-20 10:24:23 +01:00
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.delete_outlined),
|
|
|
|
onPressed: controller.reset,
|
|
|
|
),
|
2022-02-05 09:58:47 +01:00
|
|
|
],
|
2021-12-24 14:18:09 +01:00
|
|
|
),
|
|
|
|
extendBodyBehindAppBar: true,
|
2022-02-20 10:24:23 +01:00
|
|
|
body: GestureDetector(
|
|
|
|
onVerticalDragUpdate: controller.onVerticalDragUpdate,
|
|
|
|
onHorizontalDragUpdate: controller.onHorizontalDragUpdate,
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
if (video != null)
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 80.0),
|
|
|
|
child: FutureBuilder(
|
|
|
|
future: video.initialize().then((_) => video.play()),
|
|
|
|
builder: (_, __) => Center(child: VideoPlayer(video)),
|
|
|
|
),
|
2022-01-19 08:30:43 +01:00
|
|
|
),
|
2022-02-20 10:24:23 +01:00
|
|
|
AnimatedContainer(
|
|
|
|
duration: const Duration(seconds: 1),
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 8.0,
|
|
|
|
vertical: 80.0,
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
image: controller.image == null
|
|
|
|
? null
|
|
|
|
: DecorationImage(
|
|
|
|
image: MemoryImage(controller.image!.bytes),
|
|
|
|
fit: controller.fit,
|
|
|
|
opacity: 0.75,
|
|
|
|
),
|
|
|
|
gradient: controller.hasMedia
|
|
|
|
? null
|
|
|
|
: LinearGradient(
|
|
|
|
colors: [
|
|
|
|
controller.backgroundColorDark,
|
|
|
|
controller.backgroundColor,
|
|
|
|
],
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment(
|
|
|
|
controller.alignmentX / 100,
|
|
|
|
controller.alignmentY / 100,
|
|
|
|
),
|
|
|
|
child: IntrinsicWidth(
|
|
|
|
child: TextField(
|
|
|
|
controller: controller.controller,
|
|
|
|
focusNode: controller.focusNode,
|
|
|
|
minLines: 1,
|
|
|
|
maxLines: 15,
|
|
|
|
autofocus: false,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24,
|
|
|
|
color: Colors.white,
|
|
|
|
shadows: controller.hasMedia
|
|
|
|
? const [
|
|
|
|
Shadow(
|
|
|
|
color: Colors.black,
|
|
|
|
offset: Offset(5, 5),
|
|
|
|
blurRadius: 20,
|
|
|
|
),
|
|
|
|
Shadow(
|
|
|
|
color: Colors.black,
|
|
|
|
offset: Offset(5, 5),
|
|
|
|
blurRadius: 20,
|
|
|
|
),
|
|
|
|
Shadow(
|
|
|
|
color: Colors.black,
|
|
|
|
offset: Offset(-5, -5),
|
|
|
|
blurRadius: 20,
|
|
|
|
),
|
|
|
|
Shadow(
|
|
|
|
color: Colors.black,
|
|
|
|
offset: Offset(-5, -5),
|
|
|
|
blurRadius: 20,
|
|
|
|
),
|
|
|
|
]
|
|
|
|
: null,
|
2021-12-24 14:18:09 +01:00
|
|
|
),
|
2022-02-20 10:24:23 +01:00
|
|
|
onChanged: controller.updateHasText,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border: InputBorder.none,
|
|
|
|
hintText: controller.hasMedia
|
|
|
|
? L10n.of(context)!.addDescription
|
|
|
|
: L10n.of(context)!.whatIsGoingOn,
|
|
|
|
filled: false,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: Colors.white.withOpacity(0.5),
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
),
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
focusedBorder: InputBorder.none,
|
2021-12-24 14:18:09 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-02-20 10:24:23 +01:00
|
|
|
],
|
|
|
|
),
|
2021-12-24 14:18:09 +01:00
|
|
|
),
|
2022-02-20 10:24:23 +01:00
|
|
|
floatingActionButton: Row(
|
2022-02-05 09:58:47 +01:00
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
2022-02-20 10:24:23 +01:00
|
|
|
if (!controller.hasMedia) ...[
|
2022-02-11 22:50:20 +01:00
|
|
|
FloatingActionButton(
|
2022-02-20 10:24:23 +01:00
|
|
|
onPressed: controller.importMedia,
|
2022-02-11 22:50:20 +01:00
|
|
|
backgroundColor: controller.backgroundColorDark,
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
heroTag: null,
|
2022-02-20 10:24:23 +01:00
|
|
|
child: const Icon(Icons.photo_outlined),
|
2022-02-11 22:50:20 +01:00
|
|
|
),
|
2022-02-20 10:24:23 +01:00
|
|
|
const SizedBox(width: 16),
|
2022-02-11 22:50:20 +01:00
|
|
|
FloatingActionButton(
|
|
|
|
onPressed: controller.capturePhoto,
|
|
|
|
backgroundColor: controller.backgroundColorDark,
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
heroTag: null,
|
|
|
|
child: const Icon(Icons.camera_alt_outlined),
|
|
|
|
),
|
2022-02-20 10:24:23 +01:00
|
|
|
const SizedBox(width: 16),
|
2022-02-11 22:50:20 +01:00
|
|
|
FloatingActionButton(
|
2022-02-20 10:24:23 +01:00
|
|
|
onPressed: controller.captureVideo,
|
2022-02-11 22:50:20 +01:00
|
|
|
backgroundColor: controller.backgroundColorDark,
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
heroTag: null,
|
2022-02-20 10:24:23 +01:00
|
|
|
child: const Icon(Icons.video_camera_front_outlined),
|
2022-02-11 22:50:20 +01:00
|
|
|
),
|
|
|
|
],
|
2022-02-05 09:58:47 +01:00
|
|
|
if (controller.hasMedia || controller.hasText) ...[
|
2022-02-20 10:24:23 +01:00
|
|
|
const SizedBox(width: 16),
|
2022-02-05 09:58:47 +01:00
|
|
|
FloatingActionButton(
|
|
|
|
onPressed: controller.postStory,
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
|
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
|
|
|
child: const Icon(Icons.send_rounded),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
2022-01-19 08:30:43 +01:00
|
|
|
),
|
2021-12-24 14:18:09 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|