-
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.
准备给To增加继承的能力,观察下是否把接口适配放在layout还是To更合适
- Loading branch information
Showing
9 changed files
with
207 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:you_flutter/router.dart'; | ||
import 'package:you_note_dart/note.dart'; | ||
import 'package:you_note_dart/note_layouts.dart'; | ||
|
||
PageBuilder layout(NoteBuilder builder) { | ||
return (context, uri) => NoteLayoutStyle1(uri: uri, builder: builder); | ||
} | ||
|
||
Widget layout2(BuildContext context, ToUri uri, NoteBuilder builder) { | ||
return NoteLayoutStyle1(uri: uri, builder: builder); | ||
} |
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,3 +1,3 @@ | ||
library you_router; | ||
|
||
export 'package:you_flutter/src/router.dart' show YouRouter,To,ToUri,PageBuilder,LazyPageBuilder; | ||
export 'package:you_flutter/src/router.dart' show YouRouter,To,ToUri,PageBuilder,LazyPageBuilder,PageLayoutBuilder; |
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,5 +1,6 @@ | ||
library note; | ||
|
||
export 'src/note.dart' show Cell, NoteBuilder, LazyNoteBuilder, NoteSystem; | ||
export 'src/contents/contents.dart' show contents; | ||
export 'src/contents/mockup.dart' show MockupWindow; | ||
export 'src/contents/markdown_content.dart' show MD; |
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,4 @@ | ||
library note; | ||
|
||
export 'src/layouts/note_layout_style_1.dart' show NoteLayoutStyle1; | ||
export 'src/layouts/note_layout_style_1.dart' show NoteLayoutStyle1; | ||
export 'src/layouts/note_layout_default.dart' show NoteLayoutDefault; |
39 changes: 39 additions & 0 deletions
39
packages/you_note_dart/lib/src/layouts/note_layout_default.dart
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,39 @@ | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/router.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
import 'package:you_note_dart/note.dart'; | ||
|
||
final class NoteLayoutDefault extends StatelessWidget { | ||
final NoteBuilder builder; | ||
final ToUri uri; | ||
|
||
const NoteLayoutDefault({super.key, required this.uri, required this.builder}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
// collect note page contents(from print(xxx)) | ||
Cell rootCell = Cell.empty(); | ||
builder(context, rootCell); | ||
|
||
return Scaffold( | ||
body: SafeArea( | ||
child: SelectionArea( | ||
/// Watch是you_flutter的state管理组件, 被其包裹的状态可以被观测刷新(ref: Cell._contents = [].signal()) | ||
child: Watch((context) { | ||
// contents是收集到调用print(xx)的所有结果 | ||
var pageContents = rootCell.toList().expand((cell) sync* { | ||
for (var content in cell.contents) { | ||
yield Align( | ||
alignment: Alignment.centerLeft, | ||
child: contents.contentToWidget(content), | ||
); | ||
} | ||
}).toList(); | ||
return ListView(children: pageContents); | ||
}), | ||
), | ||
), | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/you_note_dart/lib/src/layouts/page_layout_default.dart
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,21 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/router.dart'; | ||
|
||
final class PageLayoutDefault extends StatelessWidget { | ||
final PageBuilder builder; | ||
final ToUri uri; | ||
|
||
const PageLayoutDefault({super.key, required this.uri, required this.builder}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var pageBody = builder(context, uri); | ||
return Scaffold( | ||
body: SafeArea( | ||
child: SelectionArea( | ||
child: pageBody, | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.