frosty/lib/screens/channel/video/video_overlay.dart
Tommy Chow 9a6892746d
Update to Material 3/You and other changes/fixes (#280)
* Use adaptive refresh indicators

* Add new message count indicator in chat

* Sync pubspec.lock

* Initial migration to material 3

* Restore default bottom sheet style

* Remove FrostyListTile and reset styles

* Use "Clear" button for all search history

* Add `require_trailing_commas` lint rule

* Exclude generated files from linter

* Use ListView for safe area support in bottom sheet

* Add initial dark theme

* Make sizing and units consistent

* Update onbaording spacings & copy

* Migrate to default material 3 buttons

* Add headers to chat details bottom sheet

* Simplify token log in method

* Use bottom sheet for account options

* Remove `AnimateScale` widget

* Tweak search paddings

* Update message spacing divisions

* Upgrade packages

* Update message spacing divisions

* Regenerate splash screens

* Update Inter & add google fonts

* Add initial material 3 themes

* Use adaptive alert dialogs

* Revert to oultined inputs

* Fix tooltip message

* Revert add google_fonts

* Improve themes and various styling

* Convert categories grid to list

* Tweak stream card thumbnail radii

* Tweak settings headers

* Left align floating snackbars

* Tweak search header padding

* Fix profile pics occasionally not rounded

* Use profile pic for settings button if logged in

* Redesign sleep timer

* Use divider theme and reduce thickness

* Use 0 letter spacing for tab bar titles

* Redesign category streams list

* Add border to tooltips

* Increase category card font weight

* Use outlined icon btton for chat user modal

* Reduce profile pic radius in search results

* Fix scrolll to top button safe area

* Add support for reply threads

* Reduce tooltip and snackbar border thickness

* Rebuild reply threads on new messages

* Upgrade packages (iOS)

* Reduce font weight for all chat alerts

* Use tabbars for pageview

* Add dividers everywhere

* Revert "Add dividers everywhere"

This reverts commit 5f0d349fdb.

* Remove fill from inputs

* Add dividers to settings

* Use segmented button for settings list

* Add scrollbar to lists with scrollcontroller

* Redesign badge/emote tooltip

* Remove outline from chat user modal buttons

* Remove divider from reply thread

* Use tap for chatters list and increase font weight

* Constrain emote tooltip width
2023-10-22 18:38:32 -04:00

271 lines
9.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
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';
import 'package:frosty/screens/channel/video/video_store.dart';
import 'package:frosty/widgets/uptime.dart';
import 'package:intl/intl.dart';
/// Creates a widget containing controls which enable interactions with an underlying [Video] widget.
class VideoOverlay extends StatelessWidget {
final VideoStore videoStore;
final ChatStore chatStore;
const VideoOverlay({
Key? key,
required this.videoStore,
required this.chatStore,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final orientation = MediaQuery.of(context).orientation;
final backButton = IconButton(
tooltip: 'Back',
icon: Icon(
Icons.adaptive.arrow_back_rounded,
color: Colors.white,
),
onPressed: Navigator.of(context).pop,
);
final chatOverlayButton = Observer(
builder: (_) => IconButton(
tooltip: videoStore.settingsStore.fullScreenChatOverlay
? 'Hide chat overlay'
: 'Show chat overlay',
onPressed: () => videoStore.settingsStore.fullScreenChatOverlay =
!videoStore.settingsStore.fullScreenChatOverlay,
icon: videoStore.settingsStore.fullScreenChatOverlay
? const Icon(Icons.chat_rounded)
: const Icon(Icons.chat_outlined),
color: Colors.white,
),
);
final refreshButton = Tooltip(
message: 'Refresh',
preferBelow: false,
child: IconButton(
icon: const Icon(
Icons.refresh_rounded,
color: Colors.white,
),
onPressed: videoStore.handleRefresh,
),
);
final fullScreenButton = Tooltip(
message: videoStore.settingsStore.fullScreen
? 'Exit fullscreen mode'
: 'Enter fullscreen mode',
preferBelow: false,
child: IconButton(
icon: Icon(
videoStore.settingsStore.fullScreen
? Icons.fullscreen_exit_rounded
: Icons.fullscreen_rounded,
color: Colors.white,
),
onPressed: () => videoStore.settingsStore.fullScreen =
!videoStore.settingsStore.fullScreen,
),
);
final rotateButton = Tooltip(
message: orientation == Orientation.portrait
? 'Enter landscape mode'
: 'Exit landscape mode',
preferBelow: false,
child: IconButton(
icon: const Icon(
Icons.screen_rotation_rounded,
color: Colors.white,
),
onPressed: () {
if (orientation == Orientation.portrait) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
} else {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp],
);
SystemChrome.setPreferredOrientations([]);
}
},
),
);
final streamInfo = videoStore.streamInfo;
if (streamInfo == null) {
return Stack(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
backButton,
const Spacer(),
if (videoStore.settingsStore.fullScreen &&
orientation == Orientation.landscape)
chatOverlayButton,
],
),
Align(
alignment: Alignment.bottomRight,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
refreshButton,
if (!videoStore.isIPad) rotateButton,
if (orientation == Orientation.landscape) fullScreenButton,
],
),
),
],
);
}
return Observer(
builder: (context) {
return Stack(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
backButton,
if (orientation == Orientation.landscape)
Expanded(
child: VideoBar(
streamInfo: streamInfo,
titleTextColor: Colors.white,
subtitleTextColor: Colors.white,
subtitleTextWeight: FontWeight.w500,
),
),
if (videoStore.settingsStore.fullScreen &&
orientation == Orientation.landscape)
chatOverlayButton,
],
),
Center(
child: Tooltip(
message: videoStore.paused ? 'Play' : 'Pause',
preferBelow: false,
child: IconButton(
iconSize: 56,
icon: Icon(
videoStore.paused
? Icons.play_arrow_rounded
: Icons.pause_rounded,
color: Colors.white,
),
onPressed: videoStore.handlePausePlay,
),
),
),
Align(
alignment: Alignment.bottomLeft,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
Tooltip(
message: 'Stream uptime',
preferBelow: false,
child: Row(
children: [
const Icon(
Icons.circle,
color: Colors.red,
size: 10,
),
const SizedBox(width: 4),
Uptime(
startTime: streamInfo.startedAt,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
],
),
),
const SizedBox(width: 12),
Tooltip(
message: 'Viewer count',
preferBelow: false,
child: GestureDetector(
onTap: () => showModalBottomSheet(
isScrollControlled: true,
context: context,
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,
),
),
),
),
child: Row(
children: [
const Icon(
Icons.visibility,
size: 14,
color: Colors.white,
),
const SizedBox(width: 4),
Text(
NumberFormat().format(
videoStore.streamInfo?.viewerCount,
),
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
],
),
),
),
],
),
),
),
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,
),
),
refreshButton,
if (!videoStore.isIPad) rotateButton,
if (orientation == Orientation.landscape) fullScreenButton,
],
),
),
],
);
},
);
}
}