mirror of
https://github.com/flame-engine/flame.git
synced 2026-03-13 09:43:03 +08:00
This PR adds a debug navigation to the flame `devtools` extension, allowing developers to quickly switch between `overlays`. https://github.com/user-attachments/assets/00d5e2f8-d78b-4ba4-92cb-b0c295d76ba6 ### Changes 1. added getter for `registeredOverlays` to `OverlayManager` 2. created `OverlayNavigationConnector` exposing `getOverlays` and `navigateToOverlay` to the devtools 3. added `getOverlays` and `navigateToOverlay` to `Repository` 4. created `OverlayNavigation` holding a list of all `registeredOverlays` which when an item is tapped shows this `overlay` If you have any ideas/remarks/suggestions please let me know 🚀 --------- Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
50 lines
1.4 KiB
Dart
50 lines
1.4 KiB
Dart
import 'package:devtools_app_shared/ui.dart' as devtools_ui;
|
|
import 'package:flame_devtools/repository.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class OverlayNavigation extends StatefulWidget {
|
|
const OverlayNavigation({super.key});
|
|
|
|
@override
|
|
State<OverlayNavigation> createState() => _OverlayNavigationState();
|
|
}
|
|
|
|
class _OverlayNavigationState extends State<OverlayNavigation> {
|
|
Future<List<String>>? _overlays;
|
|
|
|
@override
|
|
void initState() {
|
|
_overlays = Repository.getOverlays();
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FutureBuilder<List<String>>(
|
|
future: _overlays,
|
|
builder: (context, snapshot) {
|
|
if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
|
return const SizedBox();
|
|
}
|
|
|
|
return devtools_ui.RoundedOutlinedBorder(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const devtools_ui.AreaPaneHeader(title: Text('Overlays')),
|
|
for (final overlay in snapshot.data!)
|
|
ListTile(
|
|
dense: true,
|
|
leading: const Icon(Icons.layers, size: 20),
|
|
title: Text(overlay),
|
|
onTap: () => Repository.navigateToOverlay(overlay),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|