2021-10-03 22:15:58 -04:00
|
|
|
import 'package:flutter/material.dart';
|
2021-12-25 22:35:10 -05:00
|
|
|
import 'package:flutter/services.dart';
|
2021-10-23 00:31:27 -04:00
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
2023-01-18 05:34:54 -05:00
|
|
|
import 'package:frosty/screens/channel/chat/details/chat_users_list.dart';
|
|
|
|
|
import 'package:frosty/screens/channel/chat/stores/chat_store.dart';
|
|
|
|
|
import 'package:frosty/screens/channel/video/video_bar.dart';
|
2022-08-31 14:11:45 -04:00
|
|
|
import 'package:frosty/screens/channel/video/video_store.dart';
|
2022-12-27 23:47:55 -05:00
|
|
|
import 'package:frosty/widgets/uptime.dart';
|
2022-06-03 17:19:40 -04:00
|
|
|
import 'package:intl/intl.dart';
|
2021-09-13 00:13:09 -04:00
|
|
|
|
2022-08-31 14:11:45 -04:00
|
|
|
/// Creates a widget containing controls which enable interactions with an underlying [Video] widget.
|
|
|
|
|
class VideoOverlay extends StatelessWidget {
|
2022-06-03 17:19:40 -04:00
|
|
|
final VideoStore videoStore;
|
2023-01-18 05:34:54 -05:00
|
|
|
final ChatStore chatStore;
|
2022-06-03 17:19:40 -04:00
|
|
|
|
2022-08-31 14:11:45 -04:00
|
|
|
const VideoOverlay({
|
2022-08-07 18:46:05 -04:00
|
|
|
Key? key,
|
|
|
|
|
required this.videoStore,
|
2023-01-18 05:34:54 -05:00
|
|
|
required this.chatStore,
|
2022-08-07 18:46:05 -04:00
|
|
|
}) : super(key: key);
|
2022-06-03 17:19:40 -04:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final orientation = MediaQuery.of(context).orientation;
|
|
|
|
|
|
2022-12-27 23:47:55 -05:00
|
|
|
final backButton = IconButton(
|
|
|
|
|
tooltip: 'Back',
|
|
|
|
|
icon: Icon(
|
2023-01-18 05:34:54 -05:00
|
|
|
Icons.adaptive.arrow_back_rounded,
|
2022-12-27 23:47:55 -05:00
|
|
|
color: Colors.white,
|
2022-06-03 17:19:40 -04:00
|
|
|
),
|
2022-12-27 23:47:55 -05:00
|
|
|
onPressed: Navigator.of(context).pop,
|
2022-06-03 17:19:40 -04:00
|
|
|
);
|
|
|
|
|
|
2022-06-04 21:25:56 -04:00
|
|
|
final chatOverlayButton = Observer(
|
|
|
|
|
builder: (_) => IconButton(
|
2023-04-29 11:34:28 -04:00
|
|
|
tooltip: videoStore.settingsStore.fullScreenChatOverlay
|
|
|
|
|
? 'Hide chat overlay'
|
|
|
|
|
: 'Show chat overlay',
|
|
|
|
|
onPressed: () => videoStore.settingsStore.fullScreenChatOverlay =
|
|
|
|
|
!videoStore.settingsStore.fullScreenChatOverlay,
|
2023-01-18 05:34:54 -05:00
|
|
|
icon: videoStore.settingsStore.fullScreenChatOverlay
|
|
|
|
|
? const Icon(Icons.chat_rounded)
|
|
|
|
|
: const Icon(Icons.chat_outlined),
|
2022-06-04 21:25:56 -04:00
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
2022-06-03 17:19:40 -04:00
|
|
|
);
|
|
|
|
|
|
2023-01-18 05:34:54 -05:00
|
|
|
final refreshButton = Tooltip(
|
|
|
|
|
message: 'Refresh',
|
|
|
|
|
preferBelow: false,
|
|
|
|
|
child: IconButton(
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
Icons.refresh_rounded,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
onPressed: videoStore.handleRefresh,
|
2022-06-03 17:19:40 -04:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
2023-01-18 05:34:54 -05:00
|
|
|
final fullScreenButton = Tooltip(
|
2023-04-29 11:34:28 -04:00
|
|
|
message: videoStore.settingsStore.fullScreen
|
|
|
|
|
? 'Exit fullscreen mode'
|
|
|
|
|
: 'Enter fullscreen mode',
|
2023-01-18 05:34:54 -05:00
|
|
|
preferBelow: false,
|
|
|
|
|
child: IconButton(
|
|
|
|
|
icon: Icon(
|
2023-04-29 11:34:28 -04:00
|
|
|
videoStore.settingsStore.fullScreen
|
|
|
|
|
? Icons.fullscreen_exit_rounded
|
|
|
|
|
: Icons.fullscreen_rounded,
|
2023-01-18 05:34:54 -05:00
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
2023-04-29 11:34:28 -04:00
|
|
|
onPressed: () => videoStore.settingsStore.fullScreen =
|
|
|
|
|
!videoStore.settingsStore.fullScreen,
|
2022-06-03 17:19:40 -04:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
2023-01-18 05:34:54 -05:00
|
|
|
final rotateButton = Tooltip(
|
2023-04-29 11:34:28 -04:00
|
|
|
message: orientation == Orientation.portrait
|
|
|
|
|
? 'Enter landscape mode'
|
|
|
|
|
: 'Exit landscape mode',
|
2023-01-18 05:34:54 -05:00
|
|
|
preferBelow: false,
|
|
|
|
|
child: IconButton(
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
Icons.screen_rotation_rounded,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (orientation == Orientation.portrait) {
|
2022-06-05 17:24:51 -04:00
|
|
|
SystemChrome.setPreferredOrientations([
|
2023-01-19 23:23:28 -05:00
|
|
|
DeviceOrientation.landscapeLeft,
|
|
|
|
|
DeviceOrientation.landscapeRight,
|
2022-06-05 17:24:51 -04:00
|
|
|
]);
|
2023-01-19 23:23:28 -05:00
|
|
|
} else {
|
2023-04-29 11:34:28 -04:00
|
|
|
SystemChrome.setPreferredOrientations(
|
2023-10-22 18:38:32 -04:00
|
|
|
[DeviceOrientation.portraitUp],
|
|
|
|
|
);
|
2023-01-18 05:34:54 -05:00
|
|
|
SystemChrome.setPreferredOrientations([]);
|
2022-06-05 17:24:51 -04:00
|
|
|
}
|
2023-01-18 05:34:54 -05:00
|
|
|
},
|
|
|
|
|
),
|
2022-06-05 02:23:40 -04:00
|
|
|
);
|
|
|
|
|
|
2022-06-03 17:19:40 -04:00
|
|
|
final streamInfo = videoStore.streamInfo;
|
|
|
|
|
if (streamInfo == null) {
|
|
|
|
|
return Stack(
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
backButton,
|
|
|
|
|
const Spacer(),
|
2023-04-29 11:34:28 -04:00
|
|
|
if (videoStore.settingsStore.fullScreen &&
|
|
|
|
|
orientation == Orientation.landscape)
|
|
|
|
|
chatOverlayButton,
|
2022-06-03 17:19:40 -04:00
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.bottomRight,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
refreshButton,
|
2022-06-06 17:44:25 -04:00
|
|
|
if (!videoStore.isIPad) rotateButton,
|
2022-06-03 17:19:40 -04:00
|
|
|
if (orientation == Orientation.landscape) fullScreenButton,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Observer(
|
|
|
|
|
builder: (context) {
|
|
|
|
|
return Stack(
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
backButton,
|
2023-01-18 05:34:54 -05:00
|
|
|
if (orientation == Orientation.landscape)
|
|
|
|
|
Expanded(
|
|
|
|
|
child: VideoBar(
|
|
|
|
|
streamInfo: streamInfo,
|
|
|
|
|
titleTextColor: Colors.white,
|
|
|
|
|
subtitleTextColor: Colors.white,
|
|
|
|
|
subtitleTextWeight: FontWeight.w500,
|
2022-12-27 23:47:55 -05:00
|
|
|
),
|
|
|
|
|
),
|
2023-04-29 11:34:28 -04:00
|
|
|
if (videoStore.settingsStore.fullScreen &&
|
|
|
|
|
orientation == Orientation.landscape)
|
|
|
|
|
chatOverlayButton,
|
2022-06-03 17:19:40 -04:00
|
|
|
],
|
|
|
|
|
),
|
2022-12-27 23:47:55 -05:00
|
|
|
Center(
|
2023-01-18 05:34:54 -05:00
|
|
|
child: Tooltip(
|
|
|
|
|
message: videoStore.paused ? 'Play' : 'Pause',
|
|
|
|
|
preferBelow: false,
|
|
|
|
|
child: IconButton(
|
2023-10-22 18:38:32 -04:00
|
|
|
iconSize: 56,
|
2023-01-18 05:34:54 -05:00
|
|
|
icon: Icon(
|
2023-04-29 11:34:28 -04:00
|
|
|
videoStore.paused
|
|
|
|
|
? Icons.play_arrow_rounded
|
|
|
|
|
: Icons.pause_rounded,
|
2023-01-18 05:34:54 -05:00
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
onPressed: videoStore.handlePausePlay,
|
|
|
|
|
),
|
2022-06-03 17:19:40 -04:00
|
|
|
),
|
2022-12-27 23:47:55 -05:00
|
|
|
),
|
2022-06-03 17:19:40 -04:00
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.bottomLeft,
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
2022-12-27 23:47:55 -05:00
|
|
|
child: Padding(
|
2023-10-22 18:38:32 -04:00
|
|
|
padding: const EdgeInsets.all(12),
|
2023-01-18 05:34:54 -05:00
|
|
|
child: Row(
|
2022-12-27 23:47:55 -05:00
|
|
|
children: [
|
2023-01-18 05:34:54 -05:00
|
|
|
Tooltip(
|
|
|
|
|
message: 'Stream uptime',
|
|
|
|
|
preferBelow: false,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
2023-10-22 18:38:32 -04:00
|
|
|
const Icon(
|
|
|
|
|
Icons.circle,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
size: 10,
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SizedBox(width: 4),
|
2023-01-18 05:34:54 -05:00
|
|
|
Uptime(
|
|
|
|
|
startTime: streamInfo.startedAt,
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SizedBox(width: 12),
|
2023-01-18 05:34:54 -05:00
|
|
|
Tooltip(
|
|
|
|
|
message: 'Viewer count',
|
|
|
|
|
preferBelow: false,
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
onTap: () => showModalBottomSheet(
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
context: context,
|
2023-10-22 18:38:32 -04:00
|
|
|
builder: (context) => SizedBox(
|
|
|
|
|
height:
|
|
|
|
|
MediaQuery.of(context).size.height * 0.8,
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
onTap: FocusScope.of(context).unfocus,
|
|
|
|
|
child: ChattersList(
|
|
|
|
|
chatDetailsStore:
|
|
|
|
|
chatStore.chatDetailsStore,
|
|
|
|
|
chatStore: chatStore,
|
|
|
|
|
userLogin: streamInfo.userLogin,
|
2022-06-03 17:19:40 -04:00
|
|
|
),
|
|
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
2022-12-27 23:47:55 -05:00
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
child: Row(
|
2022-12-27 23:47:55 -05:00
|
|
|
children: [
|
|
|
|
|
const Icon(
|
2023-01-18 05:34:54 -05:00
|
|
|
Icons.visibility,
|
2022-12-27 23:47:55 -05:00
|
|
|
size: 14,
|
2023-01-18 05:34:54 -05:00
|
|
|
color: Colors.white,
|
2022-12-27 23:47:55 -05:00
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SizedBox(width: 4),
|
2022-06-03 17:19:40 -04:00
|
|
|
Text(
|
2023-04-29 11:34:28 -04:00
|
|
|
NumberFormat().format(
|
2023-10-22 18:38:32 -04:00
|
|
|
videoStore.streamInfo?.viewerCount,
|
|
|
|
|
),
|
2022-06-03 17:19:40 -04:00
|
|
|
style: const TextStyle(
|
|
|
|
|
color: Colors.white,
|
2022-12-27 23:47:55 -05:00
|
|
|
fontWeight: FontWeight.w500,
|
2022-06-03 17:19:40 -04:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2022-12-27 23:47:55 -05:00
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
),
|
2022-12-27 23:47:55 -05:00
|
|
|
),
|
|
|
|
|
],
|
2022-06-03 17:19:40 -04:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2023-01-18 05:34:54 -05:00
|
|
|
Tooltip(
|
|
|
|
|
message: 'Enter picture-in-picture',
|
|
|
|
|
preferBelow: false,
|
|
|
|
|
child: IconButton(
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
Icons.picture_in_picture_alt_rounded,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
onPressed: videoStore.requestPictureInPicture,
|
2022-06-03 17:19:40 -04:00
|
|
|
),
|
2022-09-12 22:37:25 -04:00
|
|
|
),
|
2022-06-03 17:19:40 -04:00
|
|
|
refreshButton,
|
2022-06-05 17:24:51 -04:00
|
|
|
if (!videoStore.isIPad) rotateButton,
|
2022-06-05 02:23:40 -04:00
|
|
|
if (orientation == Orientation.landscape) fullScreenButton,
|
2022-06-03 17:19:40 -04:00
|
|
|
],
|
|
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
),
|
2022-06-03 17:19:40 -04:00
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|