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(
|
||||||
future: video.initialize().then((_) => video.play()),
|
padding: const EdgeInsets.symmetric(vertical: 80.0),
|
||||||
builder: (_, __) => Center(child: VideoPlayer(video)),
|
child: FutureBuilder(
|
||||||
|
future: video.initialize().then((_) => video.play()),
|
||||||
|
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,16 +125,13 @@ class AddStoryView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton:
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
controller.controller.text.isEmpty && !controller.hasMedia
|
onPressed: controller.postStory,
|
||||||
? null
|
label: Text(L10n.of(context)!.publish),
|
||||||
: FloatingActionButton.extended(
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
onPressed: controller.postStory,
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||||
label: Text(L10n.of(context)!.publish),
|
icon: const Icon(Icons.send_rounded),
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
),
|
||||||
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
|
||||||
icon: const Icon(Icons.send_rounded),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,74 +32,63 @@ 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),
|
contentPadding: EdgeInsets.zero,
|
||||||
opacity: controller.isHold ? 0 : 1,
|
title: Text(
|
||||||
child: ListTile(
|
controller.title,
|
||||||
contentPadding: EdgeInsets.zero,
|
style: const TextStyle(
|
||||||
title: Text(
|
color: Colors.white,
|
||||||
controller.title,
|
shadows: [
|
||||||
style: const TextStyle(
|
Shadow(
|
||||||
color: Colors.white,
|
color: Colors.black,
|
||||||
shadows: [
|
offset: Offset(0, 0),
|
||||||
Shadow(
|
blurRadius: 5,
|
||||||
color: Colors.black,
|
),
|
||||||
offset: Offset(0, 0),
|
],
|
||||||
blurRadius: 5,
|
),
|
||||||
|
),
|
||||||
|
subtitle: currentEvent != null
|
||||||
|
? Text(
|
||||||
|
currentEvent.originServerTs.localizedTime(context),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white70,
|
||||||
|
shadows: [
|
||||||
|
Shadow(
|
||||||
|
color: Colors.black,
|
||||||
|
offset: Offset(0, 0),
|
||||||
|
blurRadius: 5,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
)
|
||||||
),
|
: null,
|
||||||
),
|
leading: Avatar(
|
||||||
subtitle: currentEvent != null
|
mxContent: controller.avatar,
|
||||||
? Text(
|
name: controller.title,
|
||||||
currentEvent.originServerTs.localizedTime(context),
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white70,
|
|
||||||
shadows: [
|
|
||||||
Shadow(
|
|
||||||
color: Colors.black,
|
|
||||||
offset: Offset(0, 0),
|
|
||||||
blurRadius: 5,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
leading: Avatar(
|
|
||||||
mxContent: controller.avatar,
|
|
||||||
name: controller.title,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: currentEvent == null
|
actions: currentEvent == null
|
||||||
? null
|
? null
|
||||||
: [
|
: [
|
||||||
if (!controller.isOwnStory)
|
if (!controller.isOwnStory)
|
||||||
AnimatedOpacity(
|
IconButton(
|
||||||
duration: const Duration(seconds: 1),
|
icon: Icon(Icons.adaptive.share_outlined),
|
||||||
opacity: controller.isHold ? 0 : 1,
|
onPressed: controller.share,
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(Icons.adaptive.share_outlined),
|
|
||||||
onPressed: controller.share,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
AnimatedOpacity(
|
PopupMenuButton<PopupStoryAction>(
|
||||||
duration: const Duration(seconds: 1),
|
onSelected: controller.onPopupStoryAction,
|
||||||
opacity: controller.isHold ? 0 : 1,
|
itemBuilder: (context) => [
|
||||||
child: PopupMenuButton<PopupStoryAction>(
|
if (controller.currentEvent?.canRedact ?? false)
|
||||||
onSelected: controller.onPopupStoryAction,
|
PopupMenuItem(
|
||||||
itemBuilder: (context) => [
|
value: PopupStoryAction.delete,
|
||||||
if (controller.currentEvent?.canRedact ?? false)
|
child: Text(L10n.of(context)!.delete),
|
||||||
PopupMenuItem(
|
),
|
||||||
value: PopupStoryAction.delete,
|
PopupMenuItem(
|
||||||
child: Text(L10n.of(context)!.delete),
|
value: PopupStoryAction.report,
|
||||||
),
|
child: Text(L10n.of(context)!.reportMessage),
|
||||||
PopupMenuItem(
|
),
|
||||||
value: PopupStoryAction.report,
|
],
|
||||||
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,32 +144,45 @@ 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(
|
||||||
future: controller.loadVideoControllerFuture ??=
|
top: 80,
|
||||||
controller.loadVideoController(event),
|
bottom: 64,
|
||||||
builder: (context, snapshot) {
|
left: 0,
|
||||||
final videoPlayerController = snapshot.data;
|
right: 0,
|
||||||
if (videoPlayerController == null) {
|
child: FutureBuilder<VideoPlayerController?>(
|
||||||
controller.loadingModeOn();
|
future: controller.loadVideoControllerFuture ??=
|
||||||
return Container();
|
controller.loadVideoController(event),
|
||||||
}
|
builder: (context, snapshot) {
|
||||||
controller.loadingModeOff();
|
final videoPlayerController = snapshot.data;
|
||||||
return Center(child: VideoPlayer(videoPlayerController));
|
if (videoPlayerController == null) {
|
||||||
},
|
controller.loadingModeOn();
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
controller.loadingModeOff();
|
||||||
|
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,36 +258,32 @@ class StoryView extends StatelessWidget {
|
|||||||
top: 4,
|
top: 4,
|
||||||
left: 4,
|
left: 4,
|
||||||
right: 4,
|
right: 4,
|
||||||
child: AnimatedOpacity(
|
child: SafeArea(
|
||||||
duration: const Duration(seconds: 1),
|
child: Row(
|
||||||
opacity: controller.isHold ? 0 : 1,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
child: SafeArea(
|
children: [
|
||||||
child: Row(
|
for (var i = 0; i < events.length; i++)
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
Expanded(
|
||||||
children: [
|
child: i == controller.index
|
||||||
for (var i = 0; i < events.length; i++)
|
? LinearProgressIndicator(
|
||||||
Expanded(
|
color: Colors.white,
|
||||||
child: i == controller.index
|
minHeight: 2,
|
||||||
? LinearProgressIndicator(
|
backgroundColor: Colors.grey.shade600,
|
||||||
color: Colors.white,
|
value: controller.loadingMode
|
||||||
minHeight: 2,
|
? null
|
||||||
backgroundColor: Colors.grey.shade600,
|
: controller.progress.inMilliseconds /
|
||||||
value: controller.loadingMode
|
StoryPageController
|
||||||
? null
|
.maxProgress.inMilliseconds,
|
||||||
: controller.progress.inMilliseconds /
|
)
|
||||||
StoryPageController
|
: Container(
|
||||||
.maxProgress.inMilliseconds,
|
margin: const EdgeInsets.all(4),
|
||||||
)
|
height: 2,
|
||||||
: Container(
|
color: i < controller.index
|
||||||
margin: const EdgeInsets.all(4),
|
? Colors.white
|
||||||
height: 2,
|
: Colors.grey.shade600,
|
||||||
color: i < controller.index
|
),
|
||||||
? Colors.white
|
),
|
||||||
: Colors.grey.shade600,
|
],
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -297,32 +292,28 @@ class StoryView extends StatelessWidget {
|
|||||||
bottom: 16,
|
bottom: 16,
|
||||||
left: 16,
|
left: 16,
|
||||||
right: 16,
|
right: 16,
|
||||||
child: AnimatedOpacity(
|
child: SafeArea(
|
||||||
duration: const Duration(seconds: 1),
|
child: TextField(
|
||||||
opacity: controller.isHold ? 0 : 1,
|
focusNode: controller.replyFocus,
|
||||||
child: SafeArea(
|
controller: controller.replyController,
|
||||||
child: TextField(
|
minLines: 1,
|
||||||
focusNode: controller.replyFocus,
|
maxLines: 7,
|
||||||
controller: controller.replyController,
|
onSubmitted: controller.replyAction,
|
||||||
minLines: 1,
|
textInputAction: TextInputAction.newline,
|
||||||
maxLines: 7,
|
readOnly: controller.replyLoading,
|
||||||
onSubmitted: controller.replyAction,
|
decoration: InputDecoration(
|
||||||
textInputAction: TextInputAction.newline,
|
hintText: L10n.of(context)!.reply,
|
||||||
readOnly: controller.replyLoading,
|
prefixIcon: IconButton(
|
||||||
decoration: InputDecoration(
|
onPressed: controller.replyEmojiAction,
|
||||||
hintText: L10n.of(context)!.reply,
|
icon: const Icon(Icons.emoji_emotions_outlined),
|
||||||
prefixIcon: IconButton(
|
|
||||||
onPressed: controller.replyEmojiAction,
|
|
||||||
icon: const Icon(Icons.emoji_emotions_outlined),
|
|
||||||
),
|
|
||||||
suffixIcon: controller.replyLoading
|
|
||||||
? const CircularProgressIndicator.adaptive(
|
|
||||||
strokeWidth: 2)
|
|
||||||
: IconButton(
|
|
||||||
onPressed: controller.replyAction,
|
|
||||||
icon: const Icon(Icons.send_outlined),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
suffixIcon: controller.replyLoading
|
||||||
|
? const CircularProgressIndicator.adaptive(
|
||||||
|
strokeWidth: 2)
|
||||||
|
: IconButton(
|
||||||
|
onPressed: controller.replyAction,
|
||||||
|
icon: const Icon(Icons.send_outlined),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -333,20 +324,16 @@ class StoryView extends StatelessWidget {
|
|||||||
bottom: 16,
|
bottom: 16,
|
||||||
left: 16,
|
left: 16,
|
||||||
right: 16,
|
right: 16,
|
||||||
child: AnimatedOpacity(
|
child: SafeArea(
|
||||||
duration: const Duration(seconds: 1),
|
child: Center(
|
||||||
opacity: controller.isHold ? 0 : 1,
|
child: OutlinedButton.icon(
|
||||||
child: SafeArea(
|
style: OutlinedButton.styleFrom(
|
||||||
child: Center(
|
backgroundColor:
|
||||||
child: OutlinedButton.icon(
|
Theme.of(context).colorScheme.surface,
|
||||||
style: OutlinedButton.styleFrom(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).colorScheme.surface,
|
|
||||||
),
|
|
||||||
onPressed: controller.displaySeenByUsers,
|
|
||||||
icon: const Icon(Icons.visibility_outlined),
|
|
||||||
label: Text(controller.seenByUsersTitle),
|
|
||||||
),
|
),
|
||||||
|
onPressed: controller.displaySeenByUsers,
|
||||||
|
icon: const Icon(Icons.visibility_outlined),
|
||||||
|
label: Text(controller.seenByUsersTitle),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user