Skip to content

Conversation

@vincendep
Copy link
Contributor

@vincendep vincendep commented Jan 31, 2025

Hi there, this PR contains a raw implementation of the load position feature.


closes #991

@vincendep vincendep marked this pull request as draft January 31, 2025 15:43
@vincendep vincendep changed the title WIP: poc implementation WIP: [Feat] Load position in board editor Jan 31, 2025
@vincendep
Copy link
Contributor Author

vincendep commented Feb 1, 2025

Hi @veloce I need some advice on how to land this feature. First of all speaking about the UX. imo navigating to a full screen selection list is far way better than using modals when many items are present, let me know if you disagree. Other than that, I would like to have some indication on how to organize the code for a proper data fetching implementation. Thanks

@vincendep vincendep changed the title WIP: [Feat] Load position in board editor [Feat] Load position in board editor Feb 5, 2025
@vincendep vincendep marked this pull request as ready for review February 5, 2025 15:36
@veloce
Copy link
Contributor

veloce commented Feb 11, 2025

Yes, full screen selection is fine! Will look at the code asap.

Copy link
Contributor

@veloce veloce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your implementation if perfectly fine. Using StatefulWidgets instead of providers in that case is valid. You could have used providers, but I don't think we'd gain anything in using providers compared to StatefulWidgets. Also, I don't expect these positions to be loaded elsewhere in the app in the future.

Good job!

child: Text(context.l10n.loadPosition),
onPressed: () {
final notifier = ref.read(editorController.notifier);
pushReplacementPlatformRoute(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't exist anymore. You should update to the last main commit. Now we're using directly Navigator.of(context).push and we define route as static method of Screen type widgets using the buildScreenRoute function.

}

class _OpeningsTabState extends State<_OpeningsTab> {
// TODO Provider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove TODO

_openings = DefaultAssetBundle.of(context).loadString('assets/positions.json').then((s) {
final List<Position> result = [];
for (final opening in jsonDecode(s) as List) {
// ignore: avoid_dynamic_calls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to remove that and use as List<Map<String, dynamic>> instead.

}

class _EndGamesTabState extends State<_EndGamesTab> {
// TODO Provider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove TODO

void initState() {
_endGames = DefaultAssetBundle.of(context).loadString('assets/endgames.json').then((s) {
final List<Position> result = [];
for (final position in jsonDecode(s) as List) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cast the explicit type of List.

@vincendep
Copy link
Contributor Author

Thanks @veloce, my point about the providers was just to easily cache data loaded and parsed from files.

@vincendep vincendep force-pushed the feat/board-editor-load-position branch from 3c5b410 to 591c50f Compare February 12, 2025 11:38
@veloce
Copy link
Contributor

veloce commented Feb 12, 2025

Thanks @veloce, my point about the providers was just to easily cache data loaded and parsed from files.

Yes sure we could do that, but I don't believe caching this data is important.

this.leading,
this.actions = const [],
this.androidTitleSpacing,
this.bottom,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting me know about this feature of CupertinoNavigationBar I wasn't aware of ;)

Now putting that in PlatformScaffold might lead to some issue. The way the platform scaffold wraps PlatformBottomBar in PreferredSize is not ideal, I will refactor this. Also I tested the bottom property of CupertinoNavigationBar, and it still has some issues with routes transition, currently being fixed in flutter repo.

I think PlatformScaffold should stay very limited, and don't support too much use cases. For now I'd say lets remove the bottom from platform scaffold and use separately Scaffold and CupertinoPageScaffold in your PR.

@vincendep vincendep force-pushed the feat/board-editor-load-position branch from 4c06d2c to 2bb177a Compare February 13, 2025 20:58
@vincendep
Copy link
Contributor Author

Hi @veloce. I made some changes based on your comments.

@veloce veloce merged commit c557816 into lichess-org:main Feb 14, 2025
1 check passed
@vincendep vincendep deleted the feat/board-editor-load-position branch February 14, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add a "Load position" button to board editor menu

2 participants