-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
174 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:you_flutter/router.dart'; | ||
import 'package:you_flutter/note.dart'; | ||
|
||
/// [NoteLayoutBuilder] | ||
BuildResult layout(BuildContext context, BuildResult child) { | ||
// ignore: unnecessary_type_check | ||
assert(layout is PageLayoutBuilder); | ||
return child.warp(RootLayout(child: child)); | ||
} | ||
|
||
class RootLayout extends StatelessWidget { | ||
final BuildResult child; | ||
|
||
const RootLayout({super.key, required this.child}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final route = YouRouter.of(context); | ||
|
||
|
||
return Scaffold( | ||
primary: true, | ||
// content... | ||
appBar: AppBar(toolbarHeight: 38, title: Text("location: ${route.uri}"), actions: [ | ||
IconButton(iconSize: 24, icon: const Icon(Icons.color_lens_outlined), onPressed: () {}), | ||
IconButton(iconSize: 24, icon: const Icon(Icons.settings), onPressed: () {}), | ||
]), | ||
body: SafeArea( | ||
child: SelectionArea( | ||
child: child.widget, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,81 @@ | ||
import 'package:flutter/widgets.dart'; | ||
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) | ||
Widget layout(BuildContext context, NoteBuilder builder) { | ||
BuildNote layout(BuildContext context, BuildNote child) { | ||
// ignore: unnecessary_type_check | ||
assert(layout is NoteLayoutBuilder); | ||
return NoteLayoutStyle1(builder: builder); | ||
return child.warp(NoteLayout(child: child)); | ||
} | ||
|
||
|
||
/// 一个极简的笔记布局范例 | ||
/// 左边routes树,右边页面内容 | ||
final class NoteLayout extends StatelessWidget { | ||
final BuildNote child; | ||
|
||
const NoteLayout({super.key, required this.child}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: SafeArea( | ||
child: SelectionArea( | ||
/// Watch是you_flutter的state管理组件, 被其包裹的状态可以被观测刷新(ref: Cell._contents = [].signal()) | ||
child: Watch((context) { | ||
// contents是收集到调用print(xx)的所有结果 | ||
var pageContents = child.cell.toList().expand((cell) sync* { | ||
for (var content in cell.contents) { | ||
yield Align( | ||
alignment: Alignment.centerLeft, | ||
child: contents.contentToWidget(content), | ||
); | ||
} | ||
}).toList(); | ||
return Row( | ||
children: [ | ||
// IntrinsicWidth(child: _NoteTreeView(uri)), | ||
const _RouteTree(), | ||
Flexible(child: ListView(children: pageContents)), | ||
], | ||
); | ||
}), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _RouteTree extends StatelessWidget { | ||
const _RouteTree(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final route = YouRouter.of(context); | ||
|
||
var validRoutes = route.root.toList().where((e) => e.isValid || e.isNonLeaf); | ||
var routeWidgets = validRoutes.map((node) { | ||
String title = "▼ ${node.part}"; | ||
title = title.padLeft((node.level * 3) + title.length); | ||
|
||
click() { | ||
route.to(node.toUri()); | ||
} | ||
|
||
return Align( | ||
alignment: Alignment.centerLeft, | ||
child: TextButton(onPressed: node.isValid ? click : null, child: Text(title)), | ||
); | ||
}); | ||
return ConstrainedBox( | ||
constraints: const BoxConstraints.tightFor(width: 350), | ||
child: ListView( | ||
children: [ | ||
...routeWidgets, | ||
], | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
library note; | ||
|
||
export 'src/note/note.dart' show ToNote, Cell, NoteBuilder, NoteLayoutBuilder, NoteSystem; | ||
export 'src/note/note.dart' show ToNote, Cell, NoteBuilder,BuildNote, NoteLayoutBuilder, NoteSystem; | ||
|
||
export 'src/note/contents/contents.dart' show contents, Contents; | ||
export 'src/note/contents/mockup.dart' show MockupWindow; | ||
export 'src/note/contents/markdown_content.dart' show MD; | ||
|
||
export 'src/note/layouts/note_layout_style_1.dart' show NoteLayoutStyle1; | ||
export 'src/note/layouts/note_layout_default.dart' show NoteLayoutDefault; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, RouteNode, ToType, RouteUri, RouteBuilder, ToPage, PageBuilder, LazyPageBuilder, PageLayoutBuilder; | ||
export 'package:you_flutter/src/router.dart' show YouRouter, RouteNode,BuildResult, ToType, RouteUri, RouteBuilder, ToPage, PageBuilder, LazyPageBuilder, PageLayoutBuilder; |
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
packages/you_flutter/lib/src/note/layouts/note_layout_default.dart
This file was deleted.
Oops, something went wrong.
75 changes: 0 additions & 75 deletions
75
packages/you_flutter/lib/src/note/layouts/note_layout_style_1.dart
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.