Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/src/model/account/account_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ Future<LightUser?> accountUser(Ref ref) async {
return ref.watch(accountProvider.selectAsync((user) => user?.lightUser));
}

@riverpod
Future<bool> kidMode(Ref ref) async {
return ref.watch(accountProvider.selectAsync((user) => user?.kid ?? false));
}

@riverpod
Future<IList<UserActivity>> accountActivity(Ref ref) async {
final session = ref.watch(authSessionProvider);
Expand Down
53 changes: 30 additions & 23 deletions lib/src/view/game/game_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ class GameBody extends ConsumerWidget {
final enableChat = ref.watch(
gamePreferencesProvider.select((prefs) => prefs.enableChat ?? false),
);
final kidModeAsync = ref.watch(kidModeProvider);

final gameStateAsync = ref.watch(ctrlProvider);

return gameStateAsync.when(
data: (gameState) {
final isChatEnabled = enableChat && !gameState.isZenModeActive;
final isChatEnabled =
enableChat && !gameState.isZenModeActive && kidModeAsync.valueOrNull == false;
if (isChatEnabled) {
ref.listen(
chatControllerProvider(id),
Expand Down Expand Up @@ -430,11 +432,15 @@ class _GameBottomBar extends ConsumerWidget {
final gameStateAsync = ref.watch(gameControllerProvider(id));
final chatStateAsync =
gamePrefs.enableChat == true ? ref.watch(chatControllerProvider(id)) : null;
final kidModeAsync = ref.watch(kidModeProvider);

return PlatformBottomBar(
children: gameStateAsync.when(
data: (gameState) {
final isChatEnabled = chatStateAsync != null && !gameState.isZenModeActive;
final isChatEnabled =
chatStateAsync != null &&
!gameState.isZenModeActive &&
kidModeAsync.valueOrNull == false;

final chatUnreadLabel =
isChatEnabled
Expand Down Expand Up @@ -579,27 +585,28 @@ class _GameBottomBar extends ConsumerWidget {
orElse: () => null,
),
),
BottomBarButton(
label: context.l10n.chat,
onTap:
isChatEnabled
? () {
Navigator.of(context).push(
MessageScreen.buildRoute(
context,
title: UserFullNameWidget(user: gameState.game.opponent?.user),
me: gameState.game.me?.user,
id: id,
),
);
}
: null,
icon:
Theme.of(context).platform == TargetPlatform.iOS
? CupertinoIcons.chat_bubble
: Icons.chat_bubble_outline,
badgeLabel: chatUnreadLabel,
),
if (kidModeAsync.valueOrNull == false)
BottomBarButton(
label: context.l10n.chat,
onTap:
isChatEnabled
? () {
Navigator.of(context).push(
MessageScreen.buildRoute(
context,
title: UserFullNameWidget(user: gameState.game.opponent?.user),
me: gameState.game.me?.user,
id: id,
),
);
}
: null,
icon:
Theme.of(context).platform == TargetPlatform.iOS
? CupertinoIcons.chat_bubble
: Icons.chat_bubble_outline,
badgeLabel: chatUnreadLabel,
),
RepeatButton(
onLongPress: gameState.canGoBackward ? () => _moveBackward(ref) : null,
child: BottomBarButton(
Expand Down