mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 06:52:35 +01:00
chore: Story design follow up
This commit is contained in:
parent
a532da6c39
commit
10c78039ee
@ -14,6 +14,7 @@ import 'package:vrouter/vrouter.dart';
|
|||||||
import 'package:fluffychat/pages/add_story/add_story_view.dart';
|
import 'package:fluffychat/pages/add_story/add_story_view.dart';
|
||||||
import 'package:fluffychat/pages/add_story/invite_story_page.dart';
|
import 'package:fluffychat/pages/add_story/invite_story_page.dart';
|
||||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart';
|
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart';
|
||||||
|
import 'package:fluffychat/utils/resize_image.dart';
|
||||||
import 'package:fluffychat/utils/room_send_file_extension.dart';
|
import 'package:fluffychat/utils/room_send_file_extension.dart';
|
||||||
import 'package:fluffychat/utils/string_color.dart';
|
import 'package:fluffychat/utils/string_color.dart';
|
||||||
import 'package:fluffychat/widgets/matrix.dart';
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
@ -81,6 +82,7 @@ class AddStoryController extends State<AddStoryPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void postStory() async {
|
void postStory() async {
|
||||||
|
if (video == null && image == null && controller.text.isEmpty) return;
|
||||||
final client = Matrix.of(context).client;
|
final client = Matrix.of(context).client;
|
||||||
var storiesRoom = await client.getStoriesRoom(context);
|
var storiesRoom = await client.getStoriesRoom(context);
|
||||||
|
|
||||||
@ -106,18 +108,20 @@ class AddStoryController extends State<AddStoryPage> {
|
|||||||
context: context,
|
context: context,
|
||||||
future: () async {
|
future: () async {
|
||||||
if (storiesRoom == null) throw ('Stories room is null');
|
if (storiesRoom == null) throw ('Stories room is null');
|
||||||
final video = this.video;
|
var video = this.video?.detectFileType;
|
||||||
if (video != null) {
|
if (video != null) {
|
||||||
|
video = await video.resizeVideo();
|
||||||
await storiesRoom.sendFileEventWithThumbnail(
|
await storiesRoom.sendFileEventWithThumbnail(
|
||||||
video.detectFileType,
|
video,
|
||||||
extraContent: {'body': controller.text},
|
extraContent: {'body': controller.text},
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final image = this.image;
|
var image = this.image?.detectFileType;
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
|
image = await image.resizeImage();
|
||||||
await storiesRoom.sendFileEventWithThumbnail(
|
await storiesRoom.sendFileEventWithThumbnail(
|
||||||
image.detectFileType,
|
image,
|
||||||
extraContent: {'body': controller.text},
|
extraContent: {'body': controller.text},
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
@ -59,13 +59,19 @@ class AddStoryView extends StatelessWidget {
|
|||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
if (video != null)
|
if (video != null)
|
||||||
FutureBuilder(
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 80.0),
|
||||||
|
child: FutureBuilder(
|
||||||
future: video.initialize().then((_) => video.play()),
|
future: video.initialize().then((_) => video.play()),
|
||||||
builder: (_, __) => Center(child: VideoPlayer(video)),
|
builder: (_, __) => Center(child: VideoPlayer(video)),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
duration: const Duration(seconds: 2),
|
duration: const Duration(seconds: 2),
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8.0,
|
||||||
|
vertical: 80.0,
|
||||||
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: controller.image == null
|
image: controller.image == null
|
||||||
? null
|
? null
|
||||||
@ -96,7 +102,9 @@ class AddStoryView extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
backgroundColor: !controller.hasMedia ? null : Colors.black,
|
backgroundColor: !controller.hasMedia
|
||||||
|
? null
|
||||||
|
: Colors.black.withOpacity(0.5),
|
||||||
),
|
),
|
||||||
onEditingComplete: controller.updateColors,
|
onEditingComplete: controller.updateColors,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@ -117,10 +125,7 @@ class AddStoryView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton:
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
controller.controller.text.isEmpty && !controller.hasMedia
|
|
||||||
? null
|
|
||||||
: FloatingActionButton.extended(
|
|
||||||
onPressed: controller.postStory,
|
onPressed: controller.postStory,
|
||||||
label: Text(L10n.of(context)!.publish),
|
label: Text(L10n.of(context)!.publish),
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
@ -32,10 +32,7 @@ class StoryView extends StatelessWidget {
|
|||||||
icon: const Icon(Icons.close),
|
icon: const Icon(Icons.close),
|
||||||
onPressed: Navigator.of(context).pop,
|
onPressed: Navigator.of(context).pop,
|
||||||
),
|
),
|
||||||
title: AnimatedOpacity(
|
title: ListTile(
|
||||||
duration: const Duration(seconds: 1),
|
|
||||||
opacity: controller.isHold ? 0 : 1,
|
|
||||||
child: ListTile(
|
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
title: Text(
|
title: Text(
|
||||||
controller.title,
|
controller.title,
|
||||||
@ -70,23 +67,15 @@ class StoryView extends StatelessWidget {
|
|||||||
name: controller.title,
|
name: controller.title,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
actions: currentEvent == null
|
actions: currentEvent == null
|
||||||
? null
|
? null
|
||||||
: [
|
: [
|
||||||
if (!controller.isOwnStory)
|
if (!controller.isOwnStory)
|
||||||
AnimatedOpacity(
|
IconButton(
|
||||||
duration: const Duration(seconds: 1),
|
|
||||||
opacity: controller.isHold ? 0 : 1,
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(Icons.adaptive.share_outlined),
|
icon: Icon(Icons.adaptive.share_outlined),
|
||||||
onPressed: controller.share,
|
onPressed: controller.share,
|
||||||
),
|
),
|
||||||
),
|
PopupMenuButton<PopupStoryAction>(
|
||||||
AnimatedOpacity(
|
|
||||||
duration: const Duration(seconds: 1),
|
|
||||||
opacity: controller.isHold ? 0 : 1,
|
|
||||||
child: PopupMenuButton<PopupStoryAction>(
|
|
||||||
onSelected: controller.onPopupStoryAction,
|
onSelected: controller.onPopupStoryAction,
|
||||||
itemBuilder: (context) => [
|
itemBuilder: (context) => [
|
||||||
if (controller.currentEvent?.canRedact ?? false)
|
if (controller.currentEvent?.canRedact ?? false)
|
||||||
@ -99,7 +88,7 @@ class StoryView extends StatelessWidget {
|
|||||||
child: Text(L10n.of(context)!.reportMessage),
|
child: Text(L10n.of(context)!.reportMessage),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
),
|
||||||
],
|
],
|
||||||
systemOverlayStyle: SystemUiOverlayStyle.light,
|
systemOverlayStyle: SystemUiOverlayStyle.light,
|
||||||
iconTheme: const IconThemeData(color: Colors.white),
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
@ -155,14 +144,25 @@ class StoryView extends StatelessWidget {
|
|||||||
if (event.messageType == MessageTypes.Text) {
|
if (event.messageType == MessageTypes.Text) {
|
||||||
controller.loadingModeOff();
|
controller.loadingModeOff();
|
||||||
}
|
}
|
||||||
|
final hash = event.infoMap['xyz.amorgan.blurhash'];
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTapDown: controller.hold,
|
onTapDown: controller.hold,
|
||||||
onTapUp: controller.unhold,
|
onTapUp: controller.unhold,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
|
if (hash is String)
|
||||||
|
BlurHash(
|
||||||
|
hash: hash,
|
||||||
|
imageFit: BoxFit.cover,
|
||||||
|
),
|
||||||
if (event.messageType == MessageTypes.Video &&
|
if (event.messageType == MessageTypes.Video &&
|
||||||
PlatformInfos.isMobile)
|
PlatformInfos.isMobile)
|
||||||
FutureBuilder<VideoPlayerController?>(
|
Positioned(
|
||||||
|
top: 80,
|
||||||
|
bottom: 64,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: FutureBuilder<VideoPlayerController?>(
|
||||||
future: controller.loadVideoControllerFuture ??=
|
future: controller.loadVideoControllerFuture ??=
|
||||||
controller.loadVideoController(event),
|
controller.loadVideoController(event),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
@ -172,15 +172,17 @@ class StoryView extends StatelessWidget {
|
|||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
controller.loadingModeOff();
|
controller.loadingModeOff();
|
||||||
return Center(child: VideoPlayer(videoPlayerController));
|
return Center(
|
||||||
|
child: VideoPlayer(videoPlayerController));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
if (event.messageType == MessageTypes.Image ||
|
if (event.messageType == MessageTypes.Image ||
|
||||||
(event.messageType == MessageTypes.Video &&
|
(event.messageType == MessageTypes.Video &&
|
||||||
!PlatformInfos.isMobile))
|
!PlatformInfos.isMobile))
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 0,
|
top: 80,
|
||||||
bottom: 0,
|
bottom: 64,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
child: FutureBuilder<MatrixFile>(
|
child: FutureBuilder<MatrixFile>(
|
||||||
@ -190,13 +192,7 @@ class StoryView extends StatelessWidget {
|
|||||||
final matrixFile = snapshot.data;
|
final matrixFile = snapshot.data;
|
||||||
if (matrixFile == null) {
|
if (matrixFile == null) {
|
||||||
controller.loadingModeOn();
|
controller.loadingModeOn();
|
||||||
final hash = event.infoMap['xyz.amorgan.blurhash'];
|
return Container();
|
||||||
return hash is String
|
|
||||||
? BlurHash(
|
|
||||||
hash: hash,
|
|
||||||
imageFit: BoxFit.cover,
|
|
||||||
)
|
|
||||||
: Container();
|
|
||||||
}
|
}
|
||||||
controller.loadingModeOff();
|
controller.loadingModeOff();
|
||||||
return Center(
|
return Center(
|
||||||
@ -210,7 +206,10 @@ class StoryView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8.0,
|
||||||
|
vertical: 64,
|
||||||
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: event.messageType == MessageTypes.Text
|
gradient: event.messageType == MessageTypes.Text
|
||||||
? LinearGradient(
|
? LinearGradient(
|
||||||
@ -259,9 +258,6 @@ class StoryView extends StatelessWidget {
|
|||||||
top: 4,
|
top: 4,
|
||||||
left: 4,
|
left: 4,
|
||||||
right: 4,
|
right: 4,
|
||||||
child: AnimatedOpacity(
|
|
||||||
duration: const Duration(seconds: 1),
|
|
||||||
opacity: controller.isHold ? 0 : 1,
|
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@ -291,15 +287,11 @@ class StoryView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
if (!controller.isOwnStory && currentEvent != null)
|
if (!controller.isOwnStory && currentEvent != null)
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 16,
|
bottom: 16,
|
||||||
left: 16,
|
left: 16,
|
||||||
right: 16,
|
right: 16,
|
||||||
child: AnimatedOpacity(
|
|
||||||
duration: const Duration(seconds: 1),
|
|
||||||
opacity: controller.isHold ? 0 : 1,
|
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
focusNode: controller.replyFocus,
|
focusNode: controller.replyFocus,
|
||||||
@ -326,16 +318,12 @@ class StoryView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
if (controller.isOwnStory &&
|
if (controller.isOwnStory &&
|
||||||
controller.currentSeenByUsers.isNotEmpty)
|
controller.currentSeenByUsers.isNotEmpty)
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 16,
|
bottom: 16,
|
||||||
left: 16,
|
left: 16,
|
||||||
right: 16,
|
right: 16,
|
||||||
child: AnimatedOpacity(
|
|
||||||
duration: const Duration(seconds: 1),
|
|
||||||
opacity: controller.isHold ? 0 : 1,
|
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: OutlinedButton.icon(
|
child: OutlinedButton.icon(
|
||||||
@ -350,7 +338,6 @@ class StoryView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user