Skip to content

Commit

Permalink
gen pages.g.dart: 4.已调通一个简单的note layout 模版,左树形导航,右note page,但目前not fo…
Browse files Browse the repository at this point in the history
…und page场景未处理,导致点了无builder页面会报错
  • Loading branch information
chen56 committed Apr 26, 2024
1 parent 30d0f90 commit b564ca9
Show file tree
Hide file tree
Showing 24 changed files with 539 additions and 441 deletions.
2 changes: 1 addition & 1 deletion bake
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ flutter_web.clean() { _run flutter_web flutter clean;
rm -rf build; }
flutter_web.upgrade() { _run flutter_web flutter pub upgrade ; }
flutter_web.gen() { #_run root dart run packages/you_cli/bin/you_cli2.dart gen all --dir notes/flutter_web/;
_run root dart run packages/you_cli/bin/you_cli2.dart gen routes.g.dart --dir notes/flutter_web/ --async
_run root dart run packages/you_cli/bin/you_cli2.dart gen routes.g.dart --dir notes/flutter_web/ # --async
}
flutter_web.dev() { flutter_web.dev_html ; }
flutter_web.build() { flutter_web.build_html ;}
Expand Down
30 changes: 29 additions & 1 deletion notes/flutter_web/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_web/pages.g.dart';
import 'package:you_flutter/better_ui.dart';
import 'package:you_note_dart/note.dart';
import 'package:flutter_web/note_app.dart';
import 'package:shared_preferences/shared_preferences.dart';
Expand All @@ -9,5 +10,32 @@ void main() async {
root: BaseNotes.rootroot,
);
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
runApp(NoteApp(noteSystem: noteSystem, sharedPreferences: sharedPreferences));
runApp(_AppRootWidget(title: "ssss",));
}

class _AppRootWidget extends StatefulWidget {

const _AppRootWidget({required this.title});

final String title;

@override
State<_AppRootWidget> createState() => _AppRootWidgetState();

}

class _AppRootWidgetState extends State<_AppRootWidget> {
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: widget.title,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.tealAccent.shade700, brightness: Brightness.light),
useMaterial3: true),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: ColorSeed.m3baseline.color, brightness: Brightness.dark),
useMaterial3: true),
routerConfig: router.toRouterConfig(),
);
}
}
28 changes: 25 additions & 3 deletions notes/flutter_web/lib/note_app.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// part of "pages.g.dart";
import 'package:flutter/material.dart';
import 'package:flutter_web/routes.g.dart';
import 'package:you_flutter/better_ui.dart';
import 'package:you_flutter/router.dart';
import 'package:you_note_dart/ui.dart';
import 'package:you_note_dart/note_shell.dart';
import 'package:you_note_dart/note.dart';
Expand Down Expand Up @@ -42,7 +45,7 @@ import 'package:shared_preferences/shared_preferences.dart';
// ]),
// ]),
// ]);

//
@immutable
class Notes extends BaseNotes with Navigable {
final SharedPreferences sharedPreferences;
Expand Down Expand Up @@ -84,6 +87,11 @@ class Notes extends BaseNotes with Navigable {
return DeferredScreen(noteRoute: find, noteSystem: noteSystem);
}
}
final YouRouter router = YouRouter(
root: root,
initial: routes.notes_widgets_specific_widgets_button_overview.toUri(),
navigatorKey: GlobalKey<NavigatorState>(debugLabel: "mainNavigator"),
);

class NoteApp extends StatelessWidget {
final NoteSystem noteSystem;
Expand All @@ -92,8 +100,7 @@ class NoteApp extends StatelessWidget {
// ignore: prefer_const_constructors_in_immutables
NoteApp({super.key, required this.noteSystem, required this.sharedPreferences});

@override
Widget build(BuildContext context) {
Widget build2(BuildContext context) {
// BaseNotes.rootroot这个设计临时的,可以改善

Notes notes = Notes(noteSystem: noteSystem, sharedPreferences: sharedPreferences);
Expand All @@ -112,4 +119,19 @@ class NoteApp extends StatelessWidget {
);
return routerApp;
}

@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: "flutter note",
theme: ThemeData(
primarySwatch: Colors.indigo,
useMaterial3: true,
),

// theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.tealAccent.shade700, brightness: Brightness.light), useMaterial3: true),
// darkTheme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: ColorSeed.m3baseline.color, brightness: Brightness.dark), useMaterial3: true),
routerConfig: router.toRouterConfig(),
);
}
}
6 changes: 1 addition & 5 deletions notes/flutter_web/lib/pages/notes/layout.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
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 (BuildContext context, ToUri uri) => NoteLayoutStyle1(
uri: uri,
builder: builder,
);
return (context, uri) => NoteLayoutStyle1(uri: uri, builder: builder);
}
Loading

0 comments on commit b564ca9

Please sign in to comment.