Add dismiss emote menu when tapping video

This commit is contained in:
Tommy Chow 2022-01-19 16:50:03 -05:00
parent 9faa4bbecc
commit f72f6fc0f6
3 changed files with 95 additions and 83 deletions

View file

@ -20,57 +20,50 @@ class Chat extends StatelessWidget {
child: Stack(
alignment: AlignmentDirectional.bottomCenter,
children: [
GestureDetector(
onTap: () {
// If tapping chat, hide the keyboard and emote menu.
FocusManager.instance.primaryFocus?.unfocus();
if (chatStore.assetsStore.showEmoteMenu) chatStore.assetsStore.showEmoteMenu = false;
},
child: MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: chatStore.settings.messageScale),
child: DefaultTextStyle(
style: DefaultTextStyle.of(context).style.copyWith(fontSize: chatStore.settings.fontSize),
child: Observer(
builder: (context) => ListView.separated(
padding: const EdgeInsets.symmetric(vertical: 5.0),
addAutomaticKeepAlives: false,
addRepaintBoundaries: false,
itemCount: chatStore.messages.length,
controller: chatStore.scrollController,
separatorBuilder: (context, index) => SizedBox(height: chatStore.settings.messageSpacing),
itemBuilder: (context, index) => Observer(
builder: (context) {
final message = chatStore.messages[index];
MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: chatStore.settings.messageScale),
child: DefaultTextStyle(
style: DefaultTextStyle.of(context).style.copyWith(fontSize: chatStore.settings.fontSize),
child: Observer(
builder: (context) => ListView.separated(
padding: const EdgeInsets.symmetric(vertical: 5.0),
addAutomaticKeepAlives: false,
addRepaintBoundaries: false,
itemCount: chatStore.messages.length,
controller: chatStore.scrollController,
separatorBuilder: (context, index) => SizedBox(height: chatStore.settings.messageSpacing),
itemBuilder: (context, index) => Observer(
builder: (context) {
final message = chatStore.messages[index];
if (message.user != null && message.user != chatStore.auth.user.details?.login) {
return InkWell(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
if (chatStore.assetsStore.showEmoteMenu) chatStore.assetsStore.showEmoteMenu = false;
},
onLongPress: () => showModalBottomSheet(
context: context,
builder: (context) => ChatUserModal(
username: message.user!,
chatStore: chatStore,
userId: message.tags['user-id']!,
displayName: message.tags['display-name']!,
),
if (message.user != null && message.user != chatStore.auth.user.details?.login) {
return InkWell(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
if (chatStore.assetsStore.showEmoteMenu) chatStore.assetsStore.showEmoteMenu = false;
},
onLongPress: () => showModalBottomSheet(
context: context,
builder: (context) => ChatUserModal(
username: message.user!,
chatStore: chatStore,
userId: message.tags['user-id']!,
displayName: message.tags['display-name']!,
),
child: ChatMessage(
ircMessage: message,
assetsStore: chatStore.assetsStore,
settingsStore: chatStore.settings,
),
);
}
return ChatMessage(
ircMessage: message,
assetsStore: chatStore.assetsStore,
settingsStore: chatStore.settings,
),
child: ChatMessage(
ircMessage: message,
assetsStore: chatStore.assetsStore,
settingsStore: chatStore.settings,
),
);
},
),
}
return ChatMessage(
ircMessage: message,
assetsStore: chatStore.assetsStore,
settingsStore: chatStore.settings,
);
},
),
),
),

View file

@ -58,34 +58,25 @@ class Video extends StatelessWidget {
),
},
),
GestureDetector(
onTap: () {
if (textFieldFocus.hasFocus) {
textFieldFocus.unfocus();
} else {
videoStore.handleVideoTap();
}
},
child: Observer(
builder: (_) {
if (videoStore.paused) return VideoOverlay(videoStore: videoStore);
return SizedBox.expand(
child: Observer(
builder: (_) => AnimatedOpacity(
opacity: videoStore.overlayVisible ? 1.0 : 0.0,
duration: const Duration(milliseconds: 200),
child: ColoredBox(
color: const Color.fromRGBO(0, 0, 0, 0.5),
child: IgnorePointer(
ignoring: !videoStore.overlayVisible,
child: VideoOverlay(videoStore: videoStore),
),
Observer(
builder: (_) {
if (videoStore.paused) return VideoOverlay(videoStore: videoStore);
return SizedBox.expand(
child: Observer(
builder: (_) => AnimatedOpacity(
opacity: videoStore.overlayVisible ? 1.0 : 0.0,
duration: const Duration(milliseconds: 200),
child: ColoredBox(
color: const Color.fromRGBO(0, 0, 0, 0.5),
child: IgnorePointer(
ignoring: !videoStore.overlayVisible,
child: VideoOverlay(videoStore: videoStore),
),
),
),
);
},
),
),
);
},
)
],
);

View file

@ -25,21 +25,49 @@ class _VideoChatState extends State<VideoChat> {
final chatStore = widget.chatStore;
final settingsStore = chatStore.settings;
final video = Video(
key: GlobalKey(),
final videoStore = VideoStore(
twitchApi: context.read<TwitchApi>(),
userLogin: chatStore.channelName,
textFieldFocus: chatStore.textFieldFocusNode,
videoStore: VideoStore(
twitchApi: context.read<TwitchApi>(),
authStore: chatStore.auth,
settingsStore: chatStore.settings,
);
final video = GestureDetector(
onTap: () {
if (chatStore.assetsStore.showEmoteMenu) {
chatStore.assetsStore.showEmoteMenu = false;
} else {
if (chatStore.textFieldFocusNode.hasFocus) {
chatStore.textFieldFocusNode.unfocus();
} else {
videoStore.handleVideoTap();
}
}
},
child: Video(
key: GlobalKey(),
userLogin: chatStore.channelName,
authStore: chatStore.auth,
settingsStore: chatStore.settings,
textFieldFocus: chatStore.textFieldFocusNode,
videoStore: videoStore,
),
);
final chat = Chat(
key: GlobalKey(),
chatStore: chatStore,
final chat = GestureDetector(
onTap: () {
if (chatStore.assetsStore.showEmoteMenu) {
chatStore.assetsStore.showEmoteMenu = false;
} else {
if (chatStore.textFieldFocusNode.hasFocus) {
chatStore.textFieldFocusNode.unfocus();
} else {
videoStore.handleVideoTap();
}
}
},
child: Chat(
key: GlobalKey(),
chatStore: chatStore,
),
);
final appBar = AppBar(