2021-12-24 14:18:09 +01:00
|
|
|
//@dart=2.12
|
|
|
|
|
|
|
|
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 'package:fluffychat/utils/platform_infos.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;
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2021-12-24 14:18:09 +01:00
|
|
|
actions: controller.hasMedia
|
|
|
|
? null
|
|
|
|
: [
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.photo_outlined),
|
|
|
|
onPressed: controller.importMedia,
|
|
|
|
),
|
|
|
|
if (PlatformInfos.isMobile)
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.camera_alt_outlined),
|
|
|
|
onPressed: controller.capturePhoto,
|
|
|
|
),
|
|
|
|
if (PlatformInfos.isMobile)
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.video_camera_back_outlined),
|
|
|
|
onPressed: controller.captureVideo,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
extendBodyBehindAppBar: true,
|
|
|
|
body: Stack(
|
|
|
|
children: [
|
|
|
|
if (video != null)
|
2022-01-19 08:30:43 +01:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 80.0),
|
|
|
|
child: FutureBuilder(
|
|
|
|
future: video.initialize().then((_) => video.play()),
|
|
|
|
builder: (_, __) => Center(child: VideoPlayer(video)),
|
|
|
|
),
|
2021-12-24 14:18:09 +01:00
|
|
|
),
|
|
|
|
AnimatedContainer(
|
|
|
|
duration: const Duration(seconds: 2),
|
2022-01-19 08:30:43 +01:00
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 8.0,
|
|
|
|
vertical: 80.0,
|
|
|
|
),
|
2021-12-24 14:18:09 +01:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
image: controller.image == null
|
|
|
|
? null
|
|
|
|
: DecorationImage(
|
|
|
|
image: MemoryImage(controller.image!.bytes),
|
2021-12-27 16:43:26 +01:00
|
|
|
fit: BoxFit.contain,
|
2021-12-24 14:18:09 +01:00
|
|
|
opacity: 0.75,
|
|
|
|
),
|
|
|
|
gradient: controller.hasMedia
|
|
|
|
? null
|
|
|
|
: LinearGradient(
|
|
|
|
colors: [
|
|
|
|
controller.backgroundColorDark,
|
|
|
|
controller.backgroundColor,
|
|
|
|
],
|
2021-12-25 08:56:35 +01:00
|
|
|
begin: Alignment.topCenter,
|
|
|
|
end: Alignment.bottomCenter,
|
2021-12-24 14:18:09 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Center(
|
|
|
|
child: TextField(
|
|
|
|
controller: controller.controller,
|
|
|
|
minLines: 1,
|
2021-12-26 12:46:18 +01:00
|
|
|
maxLines: 15,
|
|
|
|
maxLength: 500,
|
2021-12-25 14:07:48 +01:00
|
|
|
autofocus: true,
|
2021-12-24 14:18:09 +01:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24,
|
|
|
|
color: Colors.white,
|
2022-01-19 08:30:43 +01:00
|
|
|
backgroundColor: !controller.hasMedia
|
|
|
|
? null
|
|
|
|
: Colors.black.withOpacity(0.5),
|
2021-12-24 14:18:09 +01:00
|
|
|
),
|
2022-01-12 14:58:36 +01:00
|
|
|
onEditingComplete: controller.updateColors,
|
2021-12-24 14:18:09 +01:00
|
|
|
decoration: InputDecoration(
|
|
|
|
border: InputBorder.none,
|
2021-12-31 09:12:47 +01:00
|
|
|
hintText: controller.hasMedia
|
|
|
|
? L10n.of(context)!.addDescription
|
|
|
|
: L10n.of(context)!.whatIsGoingOn,
|
2021-12-24 14:18:09 +01:00
|
|
|
filled: false,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: Colors.white.withOpacity(0.5),
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
),
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-01-19 08:30:43 +01:00
|
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
|
|
onPressed: controller.postStory,
|
|
|
|
label: Text(L10n.of(context)!.publish),
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
|
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
|
|
|
icon: const Icon(Icons.send_rounded),
|
|
|
|
),
|
2021-12-24 14:18:09 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|