Skip to content

Commit

Permalink
add PageMeta
Browse files Browse the repository at this point in the history
  • Loading branch information
chen56 committed May 6, 2024
1 parent b8b5231 commit bf4d11b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
11 changes: 1 addition & 10 deletions notes/flutter_web/lib/routes/notes/layout.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:you_flutter/router.dart';
import 'package:you_flutter/note.dart';
import 'package:you_flutter/state.dart';

/// [NoteLayoutBuilder]
@ToType(type: ToNote)
Expand All @@ -23,15 +22,7 @@ final class NoteLayout extends StatelessWidget with NoteMixin {

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SelectionArea(
child: Watch((context) {
return SingleChildScrollView(child: child);
}),
),
),
);
return SingleChildScrollView(child: child);
}
}

Expand Down
3 changes: 2 additions & 1 deletion notes/flutter_web/lib/routes/notes/page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:flutter/widgets.dart';
import 'package:you_flutter/note.dart';
import 'package:you_flutter/router.dart';

/// [PageBuilder]
@PageMeta(label: "笔记", toType: ToNote)
void build(BuildContext context, Cell print) {
print(const MD(r'''
# home
Expand Down
2 changes: 1 addition & 1 deletion packages/you_flutter/lib/router.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
library you_router;

export 'package:you_flutter/src/router.dart' show YouRouter, RouteContext, To, ToType, RouteUri, PageBodyBuilder, LazyPageBodyBuilder, PageLayoutBuilder;
export 'package:you_flutter/src/router.dart' show YouRouter, PageMeta, RouteContext, To, ToType, RouteUri, PageBodyBuilder, LazyPageBodyBuilder, PageLayoutBuilder;
18 changes: 18 additions & 0 deletions packages/you_flutter/lib/src/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ typedef PageBodyBuilder = WidgetBuilder;
typedef PageLayoutBuilder = Widget Function(BuildContext context, Widget child);
typedef LazyPageBodyBuilder = Future<PageBodyBuilder> Function();

/// page annotation
class PageMeta {
const PageMeta({
required this.label,
this.publish = false,
this.toType = To,
});

/// 每个节点单独设置,子节点不继承
final String label;

/// 每个节点单独设置,子节点不继承
final bool publish;

/// 子节点若未设置此属性,则继承父节点
final Type toType;
}

final class NotFoundError extends ArgumentError {
NotFoundError({required Uri invalidValue, String name = "uri", String message = "Not Found"}) : super.value(invalidValue.toString(), name, message);
}
Expand Down

0 comments on commit bf4d11b

Please sign in to comment.