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

chore: Minor story viewer fixes

See merge request famedly/fluffychat!768
onboarding
Krille Fear 3 years ago
commit 3cd9d3a2b2

@ -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, Positioned(
left: 4, top: 4,
right: 4, left: 4,
child: SafeArea( right: 4,
child: Row( child: SafeArea(
mainAxisAlignment: MainAxisAlignment.center, child: Row(
children: [ mainAxisAlignment: MainAxisAlignment.center,
for (var i = 0; i < events.length; i++) children: [
Expanded( for (var i = 0; i < events.length; i++)
child: i == controller.index Expanded(
? LinearProgressIndicator( child: i == controller.index
color: Colors.white, ? LinearProgressIndicator(
minHeight: 2, color: Colors.white,
backgroundColor: Colors.grey.shade600, minHeight: 2,
value: controller.loadingMode backgroundColor: Colors.grey.shade600,
? null value: controller.loadingMode
: controller.progress.inMilliseconds / ? null
StoryPageController : controller.progress.inMilliseconds /
.maxProgress.inMilliseconds, StoryPageController
) .maxProgress.inMilliseconds,
: Container( )
margin: const EdgeInsets.all(4), : Container(
height: 2, margin: const EdgeInsets.all(4),
color: i < controller.index height: 2,
? Colors.white color: i < controller.index
: Colors.grey.shade600, ? Colors.white
), : Colors.grey.shade600,
), ),
], ),
), ],
), ),
), ),
if (!controller.isOwnStory && currentEvent != null) ),
Positioned( if (!controller.isOwnStory && currentEvent != null)
bottom: 16, Positioned(
left: 16, bottom: 16,
right: 16, left: 16,
child: SafeArea( right: 16,
child: TextField( child: SafeArea(
focusNode: controller.replyFocus, child: TextField(
controller: controller.replyController, focusNode: controller.replyFocus,
minLines: 1, controller: controller.replyController,
maxLines: 7, onSubmitted: controller.replyAction,
onSubmitted: controller.replyAction, textInputAction: TextInputAction.send,
textInputAction: TextInputAction.send, readOnly: controller.replyLoading,
readOnly: controller.replyLoading, decoration: InputDecoration(
decoration: InputDecoration( hintText: L10n.of(context)!.reply,
hintText: L10n.of(context)!.reply, prefixIcon: IconButton(
prefixIcon: IconButton( onPressed: controller.replyEmojiAction,
onPressed: controller.replyEmojiAction, icon: const Icon(Icons.emoji_emotions_outlined),
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 SizedBox(
width: 16,
height: 16,
child: Center(
child: CircularProgressIndicator.adaptive(
strokeWidth: 2),
),
)
: IconButton(
onPressed: controller.replyAction,
icon: const Icon(Icons.send_outlined),
),
), ),
), ),
), ),
if (controller.isOwnStory && ),
controller.currentSeenByUsers.isNotEmpty) if (controller.isOwnStory &&
Positioned( controller.currentSeenByUsers.isNotEmpty)
bottom: 16, Positioned(
left: 16, bottom: 16,
right: 16, left: 16,
child: SafeArea( right: 16,
child: Center( child: SafeArea(
child: OutlinedButton.icon( child: Center(
style: OutlinedButton.styleFrom( child: OutlinedButton.icon(
backgroundColor: style: OutlinedButton.styleFrom(
Theme.of(context).colorScheme.surface, 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…
Cancel
Save