Skip to content

Commit

Permalink
Merge branch 'treeViewInterface' of https://github.com/tom-anders/lic…
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Oct 21, 2024
2 parents 0c7800c + d9eb9a4 commit 85a756e
Show file tree
Hide file tree
Showing 7 changed files with 1,182 additions and 1,104 deletions.
11 changes: 9 additions & 2 deletions lib/src/model/analysis/analysis_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:lichess_mobile/src/model/engine/work.dart';
import 'package:lichess_mobile/src/model/game/player.dart';
import 'package:lichess_mobile/src/utils/rate_limit.dart';
import 'package:lichess_mobile/src/view/engine/engine_gauge.dart';
import 'package:lichess_mobile/src/view/pgn/pgn_tree_view.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'analysis_controller.freezed.dart';
Expand Down Expand Up @@ -60,7 +61,8 @@ class AnalysisOptions with _$AnalysisOptions {
}

@riverpod
class AnalysisController extends _$AnalysisController {
class AnalysisController extends _$AnalysisController
implements PgnTreeNotifier {
late Root _root;

final _engineEvalDebounce = Debouncer(const Duration(milliseconds: 150));
Expand Down Expand Up @@ -261,10 +263,12 @@ class AnalysisController extends _$AnalysisController {
_setPath(state.currentPath.penultimate, replaying: true);
}

@override
void userJump(UciPath path) {
_setPath(path);
}

@override
void expandVariations(UciPath path) {
final node = _root.nodeAt(path);
for (final child in node.children) {
Expand All @@ -276,8 +280,9 @@ class AnalysisController extends _$AnalysisController {
state = state.copyWith(root: _root.view);
}

@override
void collapseVariations(UciPath path) {
final node = _root.parentAt(path);
final node = _root.nodeAt(path);

for (final child in node.children) {
child.isHidden = true;
Expand All @@ -286,6 +291,7 @@ class AnalysisController extends _$AnalysisController {
state = state.copyWith(root: _root.view);
}

@override
void promoteVariation(UciPath path, bool toMainline) {
_root.promoteAt(path, toMainline: toMainline);
state = state.copyWith(
Expand All @@ -294,6 +300,7 @@ class AnalysisController extends _$AnalysisController {
);
}

@override
void deleteFromHere(UciPath path) {
_root.deleteAt(path);
_setPath(path.penultimate, shouldRecomputeRootView: true);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/analysis/analysis_board.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:lichess_mobile/src/model/common/chess.dart';
import 'package:lichess_mobile/src/model/common/eval.dart';
import 'package:lichess_mobile/src/model/engine/evaluation_service.dart';
import 'package:lichess_mobile/src/model/settings/board_preferences.dart';
import 'package:lichess_mobile/src/view/analysis/annotations.dart';
import 'package:lichess_mobile/src/view/pgn/annotations.dart';

class AnalysisBoard extends ConsumerStatefulWidget {
const AnalysisBoard(
Expand Down
Loading

0 comments on commit 85a756e

Please sign in to comment.