Merge branch 'krille/better-story-viewer' into 'main'

chore: Minor story viewer fixes

See merge request famedly/fluffychat!768
This commit is contained in:
Krille Fear 2022-03-10 16:48:16 +00:00
commit c4609edb52

View File

@ -172,65 +172,64 @@ class StoryView extends StatelessWidget {
controller.loadingModeOff(); controller.loadingModeOff();
} }
final hash = event.infoMap['xyz.amorgan.blurhash']; final hash = event.infoMap['xyz.amorgan.blurhash'];
return GestureDetector( return Stack(
onTapDown: controller.hold, children: [
onTapUp: controller.unhold, if (hash is String)
onTapCancel: controller.unhold, BlurHash(
onVerticalDragStart: controller.hold, hash: hash,
onVerticalDragEnd: controller.unhold, imageFit: BoxFit.cover,
onHorizontalDragStart: controller.hold, ),
onHorizontalDragEnd: controller.unhold, if (event.messageType == MessageTypes.Video &&
child: Stack( PlatformInfos.isMobile)
children: [ Positioned(
if (hash is String) top: 80,
BlurHash( bottom: 64,
hash: hash, left: 0,
imageFit: BoxFit.cover, right: 0,
), child: FutureBuilder<VideoPlayerController?>(
if (event.messageType == MessageTypes.Video && future: controller.loadVideoControllerFuture ??=
PlatformInfos.isMobile) controller.loadVideoController(event),
Positioned(
top: 80,
bottom: 64,
left: 0,
right: 0,
child: FutureBuilder<VideoPlayerController?>(
future: controller.loadVideoControllerFuture ??=
controller.loadVideoController(event),
builder: (context, snapshot) {
final videoPlayerController = snapshot.data;
if (videoPlayerController == null) {
controller.loadingModeOn();
return Container();
}
controller.loadingModeOff();
return Center(
child: VideoPlayer(videoPlayerController));
},
),
),
if (event.messageType == MessageTypes.Image ||
(event.messageType == MessageTypes.Video &&
!PlatformInfos.isMobile))
FutureBuilder<MatrixFile>(
future: controller.downloadAndDecryptAttachment(
event, event.messageType == MessageTypes.Video),
builder: (context, snapshot) { builder: (context, snapshot) {
final matrixFile = snapshot.data; final videoPlayerController = snapshot.data;
if (matrixFile == null) { if (videoPlayerController == null) {
controller.loadingModeOn(); controller.loadingModeOn();
return Container(); return Container();
} }
controller.loadingModeOff(); controller.loadingModeOff();
return Center( return Center(child: VideoPlayer(videoPlayerController));
child: Image.memory(
matrixFile.bytes,
fit: controller.storyThemeData.fit,
),
);
}, },
), ),
AnimatedContainer( ),
if (event.messageType == MessageTypes.Image ||
(event.messageType == MessageTypes.Video &&
!PlatformInfos.isMobile))
FutureBuilder<MatrixFile>(
future: controller.downloadAndDecryptAttachment(
event, event.messageType == MessageTypes.Video),
builder: (context, snapshot) {
final matrixFile = snapshot.data;
if (matrixFile == null) {
controller.loadingModeOn();
return Container();
}
controller.loadingModeOff();
return Center(
child: Image.memory(
matrixFile.bytes,
fit: controller.storyThemeData.fit,
),
);
},
),
GestureDetector(
onTapDown: controller.hold,
onTapUp: controller.unhold,
onTapCancel: controller.unhold,
onVerticalDragStart: controller.hold,
onVerticalDragEnd: controller.unhold,
onHorizontalDragStart: controller.hold,
onHorizontalDragEnd: controller.unhold,
child: AnimatedContainer(
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 8.0, horizontal: 8.0,
@ -275,92 +274,96 @@ class StoryView extends StatelessWidget {
), ),
), ),
), ),
),
Positioned(
top: 4,
left: 4,
right: 4,
child: SafeArea(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
for (var i = 0; i < events.length; i++)
Expanded(
child: i == controller.index
? LinearProgressIndicator(
color: Colors.white,
minHeight: 2,
backgroundColor: Colors.grey.shade600,
value: controller.loadingMode
? null
: controller.progress.inMilliseconds /
StoryPageController
.maxProgress.inMilliseconds,
)
: Container(
margin: const EdgeInsets.all(4),
height: 2,
color: i < controller.index
? Colors.white
: Colors.grey.shade600,
),
),
],
),
),
),
if (!controller.isOwnStory && currentEvent != null)
Positioned( Positioned(
top: 4, bottom: 16,
left: 4, left: 16,
right: 4, right: 16,
child: SafeArea( child: SafeArea(
child: Row( child: TextField(
mainAxisAlignment: MainAxisAlignment.center, focusNode: controller.replyFocus,
children: [ controller: controller.replyController,
for (var i = 0; i < events.length; i++) onSubmitted: controller.replyAction,
Expanded( textInputAction: TextInputAction.send,
child: i == controller.index readOnly: controller.replyLoading,
? LinearProgressIndicator( decoration: InputDecoration(
color: Colors.white, hintText: L10n.of(context)!.reply,
minHeight: 2, prefixIcon: IconButton(
backgroundColor: Colors.grey.shade600, onPressed: controller.replyEmojiAction,
value: controller.loadingMode icon: const Icon(Icons.emoji_emotions_outlined),
? null ),
: controller.progress.inMilliseconds / suffixIcon: controller.replyLoading
StoryPageController ? const SizedBox(
.maxProgress.inMilliseconds, width: 16,
) height: 16,
: Container( child: Center(
margin: const EdgeInsets.all(4), child: CircularProgressIndicator.adaptive(
height: 2, strokeWidth: 2),
color: i < controller.index ),
? Colors.white )
: Colors.grey.shade600, : IconButton(
), onPressed: controller.replyAction,
), icon: const Icon(Icons.send_outlined),
], ),
),
), ),
), ),
), ),
if (!controller.isOwnStory && currentEvent != null) if (controller.isOwnStory &&
Positioned( controller.currentSeenByUsers.isNotEmpty)
bottom: 16, Positioned(
left: 16, bottom: 16,
right: 16, left: 16,
child: SafeArea( right: 16,
child: TextField( child: SafeArea(
focusNode: controller.replyFocus, child: Center(
controller: controller.replyController, child: OutlinedButton.icon(
minLines: 1, style: OutlinedButton.styleFrom(
maxLines: 7, backgroundColor:
onSubmitted: controller.replyAction, Theme.of(context).colorScheme.surface,
textInputAction: TextInputAction.send,
readOnly: controller.replyLoading,
decoration: InputDecoration(
hintText: L10n.of(context)!.reply,
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),
),
), ),
onPressed: controller.displaySeenByUsers,
icon: const Icon(Icons.visibility_outlined),
label: Text(controller.seenByUsersTitle),
), ),
), ),
), ),
if (controller.isOwnStory && ),
controller.currentSeenByUsers.isNotEmpty) ],
Positioned(
bottom: 16,
left: 16,
right: 16,
child: SafeArea(
child: Center(
child: OutlinedButton.icon(
style: OutlinedButton.styleFrom(
backgroundColor:
Theme.of(context).colorScheme.surface,
),
onPressed: controller.displaySeenByUsers,
icon: const Icon(Icons.visibility_outlined),
label: Text(controller.seenByUsersTitle),
),
),
),
),
],
),
); );
}, },
), ),