Skip to content

Commit

Permalink
Merge pull request #7 from PlugFox/feature/quadtree
Browse files Browse the repository at this point in the history
Feature/quadtree
  • Loading branch information
PlugFox authored Jan 8, 2025
2 parents 71ff6f3 + 8464b49 commit 752d579
Show file tree
Hide file tree
Showing 25 changed files with 2,794 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checkout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: 🚂 Setup Flutter and dependencies
uses: ./.github/actions/setup
with:
flutter-version: 3.24.3
flutter-version: 3.27.1

- name: 👷 Install Dependencies
timeout-minutes: 1
Expand Down
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
"--dart-define-from-file=config/development.json",
],
"env": {}
},
{
"name": "Example (Release, Web, CanvasKit)",
"type": "dart",
"program": "lib/main.dart",
"request": "launch",
"flutterMode": "release",
"cwd": "${workspaceFolder}/example",
"args": [
"--dart-define-from-file=config/development.json",
"--device-id=chrome",
"--web-port=3000",
],
"env": {}
}
]
}
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
## 0.0.6

- **ADDED**: Basic `QuadTree` implementation and example
- **CHANGED**: Minimum Flutter version is now 3.27.0

## 0.0.5

- **CHANGED**: `frameRate` is replaced with `needsPaint` in `RePainter` delegate.
- **CHANGED**: `frameRate` is replaced with `needsPaint` in `RePainter` delegate

## 0.0.4

- **ADDED**: More examples
- **CHANGED**: Change interface of `RePainter` delegate.
- **CHANGED**: Change interface of `RePainter` delegate

## 0.0.3

Expand Down
3 changes: 3 additions & 0 deletions devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:
2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
Binary file added example/assets/fonts/RobotoMono-Bold.ttf
Binary file not shown.
Binary file added example/assets/fonts/RobotoMono-Regular.ttf
Binary file not shown.
5 changes: 4 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ import 'package:repaintexample/src/common/util/app_zone.dart';
import 'package:repaintexample/src/common/widget/app.dart';

void main() => appZone(
() => runApp(const App()),
() => runApp(App(
initalRoute:
WidgetsBinding.instance.platformDispatcher.defaultRouteName,
)),
);
10 changes: 8 additions & 2 deletions example/lib/src/common/util/app_zone.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import 'dart:async';

import 'package:flutter/widgets.dart';
import 'package:l/l.dart';

/// Catch all application errors and logs.
void appZone(FutureOr<void> Function() fn) => l.capture<void>(
() => runZonedGuarded<void>(
() => fn(),
() {
final binding = WidgetsFlutterBinding.ensureInitialized()
..deferFirstFrame();
fn();
binding.allowFirstFrame();
},
l.e,
),
const LogOptions(
handlePrint: true,
messageFormatting: _messageFormatting,
outputInRelease: false,
outputInRelease: true,
printColors: true,
),
);
Expand Down
17 changes: 16 additions & 1 deletion example/lib/src/common/widget/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import 'package:repaintexample/src/feature/home/home_screen.dart';
/// {@endtemplate}
class App extends StatefulWidget {
/// {@macro app}
const App({super.key});
const App({String? initalRoute, super.key}) : _initalRoute = initalRoute;

final String? _initalRoute;

/// Change the navigation stack.
static void navigate(BuildContext context,
Expand Down Expand Up @@ -40,6 +42,19 @@ class _AppState extends State<App> {
final ValueNotifier<List<Page<void>>> _pages =
ValueNotifier<List<Page<void>>>(defaultPages);

@override
void initState() {
super.initState();
final initialRoute = widget._initalRoute;
if (initialRoute != null &&
initialRoute.isNotEmpty &&
initialRoute != '/') {
final uri = Uri.tryParse(initialRoute);
final page = $routes[uri?.pathSegments.firstOrNull]?.call(null);
if (page != null) navigate((_) => [page]);
}
}

/// Changes the navigation stack.
void navigate(List<Page<void>> Function(List<Page<void>> pages) change) {
final pages = change(_pages.value);
Expand Down
6 changes: 6 additions & 0 deletions example/lib/src/common/widget/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:repaintexample/src/feature/clock/clock_screen.dart';
import 'package:repaintexample/src/feature/fps/fps_screen.dart';
import 'package:repaintexample/src/feature/home/home_screen.dart';
import 'package:repaintexample/src/feature/performance_overlay/performance_overlay_screen.dart';
import 'package:repaintexample/src/feature/quadtree/quadtree_screen.dart';
import 'package:repaintexample/src/feature/shaders/fragment_shaders_screen.dart';
import 'package:repaintexample/src/feature/sunflower/sunflower_screen.dart';

Expand Down Expand Up @@ -39,4 +40,9 @@ final Map<String, Page<void> Function(Map<String, Object?>?)> $routes =
child: const SunflowerScreen(),
arguments: arguments,
),
'quadtree': (arguments) => MaterialPage<void>(
name: 'quadtree',
child: const QuadTreeScreen(),
arguments: arguments,
),
};
4 changes: 4 additions & 0 deletions example/lib/src/feature/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class HomeScreen extends StatelessWidget {
title: 'Sunflower',
page: 'sunflower',
),
HomeTile(
title: 'QuadTree',
page: 'quadtree',
),
],
),
),
Expand Down
Loading

0 comments on commit 752d579

Please sign in to comment.