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
25 changes: 0 additions & 25 deletions lib/src/model/study/study_filter.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:lichess_mobile/l10n/l10n.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'study_filter.freezed.dart';
part 'study_filter.g.dart';

enum StudyCategory {
all,
Expand Down Expand Up @@ -38,23 +33,3 @@ enum StudyListOrder {
StudyListOrder.popular => l10n.studyMostPopular,
};
}

@riverpod
class StudyFilter extends _$StudyFilter {
@override
StudyFilterState build() => const StudyFilterState();

void setCategory(StudyCategory category) => state = state.copyWith(category: category);

void setOrder(StudyListOrder order) => state = state.copyWith(order: order);
}

@freezed
sealed class StudyFilterState with _$StudyFilterState {
const StudyFilterState._();

const factory StudyFilterState({
@Default(StudyCategory.all) StudyCategory category,
@Default(StudyListOrder.hot) StudyListOrder order,
}) = _StudyFilterState;
}
8 changes: 6 additions & 2 deletions lib/src/model/study/study_list_paginator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ typedef StudyList = ({IList<StudyPageData> studies, int? nextPage});
@riverpod
class StudyListPaginator extends _$StudyListPaginator {
@override
Future<StudyList> build({required StudyFilterState filter, String? search}) {
Future<StudyList> build({
required StudyCategory category,
required StudyListOrder order,
String? search,
}) {
return _nextPage();
}

Expand All @@ -33,7 +37,7 @@ class StudyListPaginator extends _$StudyListPaginator {

final repo = ref.read(studyRepositoryProvider);
return search == null
? repo.getStudies(category: filter.category, order: filter.order, page: nextPage)
? repo.getStudies(category: category, order: order, page: nextPage)
: repo.searchStudies(query: search!, page: nextPage);
}
}
6 changes: 1 addition & 5 deletions lib/src/view/analysis/analysis_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ class _AnalysisScreenState extends ConsumerState<_AnalysisScreen>
);
case AsyncError(:final error, :final stackTrace):
_logger.severe('Cannot load analysis: $error', stackTrace);
return FullScreenRetryRequest(
onRetry: () {
ref.invalidate(ctrlProvider);
},
);
return FullScreenRetryRequest(onRetry: () => ref.invalidate(ctrlProvider));
case _:
return Scaffold(
resizeToAvoidBottomInset: false,
Expand Down
14 changes: 8 additions & 6 deletions lib/src/view/broadcast/broadcast_carousel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import 'package:lichess_mobile/src/utils/l10n_context.dart';
import 'package:lichess_mobile/src/utils/screen.dart';
import 'package:lichess_mobile/src/view/broadcast/broadcast_round_screen.dart';
import 'package:lichess_mobile/src/view/broadcast/broadcast_share_menu.dart';
import 'package:lichess_mobile/src/widgets/platform.dart';
import 'package:lichess_mobile/src/widgets/platform_context_menu_button.dart';

const kDefaultBroadcastImage = AssetImage('assets/images/broadcast_image.png');
Expand Down Expand Up @@ -420,12 +419,13 @@ class _BroadcastCardContent extends StatelessWidget {
),
const Spacer(),
],
ContextMenuButton(
ContextMenuIconButton(
consumeOutsideTap: true,
semanticsLabel: context.l10n.menu,
icon: Icon(Icons.more_horiz, color: titleColor?.withValues(alpha: 0.5)),
actions: [
ContextMenuAction(
icon: const Icon(Icons.info),
icon: Icons.info,
label: context.l10n.broadcastOverview,
onPressed: () {
Navigator.of(context, rootNavigator: true).push(
Expand All @@ -438,7 +438,7 @@ class _BroadcastCardContent extends StatelessWidget {
},
),
ContextMenuAction(
icon: const Icon(LichessIcons.chess_board),
icon: LichessIcons.chess_board,
label: context.l10n.broadcastBoards,
onPressed: () {
Navigator.of(context, rootNavigator: true).push(
Expand All @@ -451,7 +451,7 @@ class _BroadcastCardContent extends StatelessWidget {
},
),
ContextMenuAction(
icon: const Icon(Icons.people),
icon: Icons.people,
label: context.l10n.players,
onPressed: () {
Navigator.of(context, rootNavigator: true).push(
Expand All @@ -464,7 +464,9 @@ class _BroadcastCardContent extends StatelessWidget {
},
),
ContextMenuAction(
icon: const PlatformShareIcon(),
icon: Theme.of(context).platform == TargetPlatform.iOS
? Icons.ios_share_outlined
: Icons.share_outlined,
label: context.l10n.studyShareAndExport,
onPressed: () {
showBroadcastShareMenu(context, broadcast);
Expand Down
3 changes: 2 additions & 1 deletion lib/src/view/game/archived_game_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ class _BodyState extends ConsumerState<_Body> {
if (widget.gameData == null && widget.error == null)
const PlatformAppBarLoadingIndicator(),
if (widget.gameData != null)
ContextMenuButton(
ContextMenuIconButton(
consumeOutsideTap: true,
icon: const Icon(Icons.more_horiz),
semanticsLabel: context.l10n.menu,
actions: [
Expand Down
13 changes: 7 additions & 6 deletions lib/src/view/game/game_common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:lichess_mobile/src/utils/share.dart';
import 'package:lichess_mobile/src/view/game/archived_game_screen.dart';
import 'package:lichess_mobile/src/view/game/game_screen.dart';
import 'package:lichess_mobile/src/widgets/feedback.dart';
import 'package:lichess_mobile/src/widgets/platform.dart';
import 'package:lichess_mobile/src/widgets/platform_context_menu_button.dart';
import 'package:share_plus/share_plus.dart';

Expand Down Expand Up @@ -95,7 +94,7 @@ class _GameBookmarkContextMenuActionState extends ConsumerState<GameBookmarkCont
builder: (context, snapshot) {
return ContextMenuAction(
dismissOnPress: false,
icon: Icon(_bookmarked ? Icons.bookmark_remove_outlined : Icons.bookmark_add_outlined),
icon: _bookmarked ? Icons.bookmark_remove_outlined : Icons.bookmark_add_outlined,
label: _bookmarked ? 'Unbookmark' : 'Bookmark',
onPressed: snapshot.connectionState == ConnectionState.waiting
? null
Expand Down Expand Up @@ -142,14 +141,16 @@ List<Widget> makeFinishedGameShareContextMenuActions(
}) {
return [
ContextMenuAction(
icon: const PlatformShareIcon(),
icon: Theme.of(context).platform == TargetPlatform.iOS
? Icons.ios_share_outlined
: Icons.share_outlined,
label: context.l10n.mobileShareGameURL,
onPressed: () {
launchShareDialog(context, ShareParams(uri: lichessUri('/$gameId/${orientation.name}')));
},
),
ContextMenuAction(
icon: const Icon(Icons.gif_outlined),
icon: Icons.gif_outlined,
label: context.l10n.gameAsGIF,
onPressed: () async {
try {
Expand All @@ -173,7 +174,7 @@ List<Widget> makeFinishedGameShareContextMenuActions(
},
),
ContextMenuAction(
icon: const Icon(Icons.text_snippet_outlined),
icon: Icons.text_snippet_outlined,
label: 'PGN: ${context.l10n.downloadAnnotated}',
onPressed: () async {
try {
Expand All @@ -189,7 +190,7 @@ List<Widget> makeFinishedGameShareContextMenuActions(
},
),
ContextMenuAction(
icon: const Icon(Icons.description_outlined),
icon: Icons.description_outlined,
label: 'PGN: ${context.l10n.downloadRaw}',
onPressed: () async {
try {
Expand Down
5 changes: 2 additions & 3 deletions lib/src/view/game/game_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,12 @@ class _GameMenu extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final isBookmarkedAsync = ref.watch(isGameBookmarkedProvider(gameId));

return ContextMenuButton(
consumeOutsideTap: false,
return ContextMenuIconButton(
icon: const Icon(Icons.more_horiz),
semanticsLabel: context.l10n.menu,
actions: [
ContextMenuAction(
icon: const Icon(Icons.settings),
icon: Icons.settings,
label: context.l10n.settingsSettings,
onPressed: () => showModalBottomSheet<void>(
context: context,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/settings/toggle_sound_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ToggleSoundContextMenuAction extends ConsumerWidget {

return ContextMenuAction(
dismissOnPress: false,
icon: Icon(isSoundEnabled ? Icons.volume_up : Icons.volume_off),
icon: isSoundEnabled ? Icons.volume_up : Icons.volume_off,
label: context.l10n.sound,
onPressed: () {
ref.read(generalPreferencesProvider.notifier).toggleSoundEnabled();
Expand Down
Loading