Skip to content

Commit 2c2ca2d

Browse files
committed
Restore reactivity
1 parent 830d133 commit 2c2ca2d

19 files changed

+792
-489
lines changed

demos/supabase-todolist-drift/lib/components/app_bar.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:auto_route/auto_route.dart';
12
import 'package:flutter/foundation.dart';
23
import 'package:flutter/material.dart';
34
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -23,6 +24,7 @@ final class StatusAppBar extends ConsumerWidget implements PreferredSizeWidget {
2324
final statusIcon = _getStatusIcon(syncState);
2425

2526
return AppBar(
27+
leading: const AutoLeadingButton(),
2628
title: title,
2729
actions: <Widget>[
2830
IconButton(

demos/supabase-todolist-drift/lib/components/page_layout.dart

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,53 @@ final class PageLayout extends ConsumerWidget {
88
final Widget content;
99
final Widget? title;
1010
final Widget? floatingActionButton;
11+
final bool showDrawer;
1112

1213
const PageLayout({
1314
super.key,
1415
required this.content,
1516
this.title,
1617
this.floatingActionButton,
18+
this.showDrawer = true,
1719
});
1820

1921
@override
2022
Widget build(BuildContext context, WidgetRef ref) {
2123
return Scaffold(
22-
appBar: StatusAppBar(title: title ?? const Text('PowerSync Demo')),
24+
appBar: StatusAppBar(
25+
title: title ?? const Text('PowerSync Demo'),
26+
),
2327
body: Center(child: content),
2428
floatingActionButton: floatingActionButton,
25-
drawer: Drawer(
26-
// Add a ListView to the drawer. This ensures the user can scroll
27-
// through the options in the drawer if there isn't enough vertical
28-
// space to fit everything.
29-
child: ListView(
30-
// Important: Remove any padding from the ListView.
31-
padding: EdgeInsets.zero,
32-
children: [
33-
const DrawerHeader(
34-
decoration: BoxDecoration(
35-
color: Colors.blue,
29+
drawer: showDrawer
30+
? Drawer(
31+
// Add a ListView to the drawer. This ensures the user can scroll
32+
// through the options in the drawer if there isn't enough vertical
33+
// space to fit everything.
34+
child: ListView(
35+
// Important: Remove any padding from the ListView.
36+
padding: EdgeInsets.zero,
37+
children: [
38+
const DrawerHeader(
39+
decoration: BoxDecoration(
40+
color: Colors.blue,
41+
),
42+
child: Text(''),
43+
),
44+
ListTile(
45+
title: const Text('SQL Console'),
46+
onTap: () {},
47+
),
48+
ListTile(
49+
title: const Text('Sign Out'),
50+
onTap: () async {
51+
ref.read(authNotifierProvider.notifier).signOut();
52+
},
53+
),
54+
],
3655
),
37-
child: Text(''),
38-
),
39-
ListTile(
40-
title: const Text('SQL Console'),
41-
onTap: () {},
42-
),
43-
ListTile(
44-
title: const Text('Sign Out'),
45-
onTap: () async {
46-
ref.read(authNotifierProvider.notifier).signOut();
47-
},
48-
),
49-
],
50-
),
51-
),
56+
)
57+
: null,
5258
);
5359
}
5460
}

demos/supabase-todolist-drift/lib/navigation.dart

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:auto_route/auto_route.dart';
2+
import 'package:flutter/material.dart';
23
import 'package:flutter_riverpod/flutter_riverpod.dart';
34

45
import 'navigation.gr.dart';
@@ -16,15 +17,49 @@ final class AppRouter extends RootStackRouter {
1617
RouteType get defaultRouteType => const RouteType.material();
1718

1819
@override
19-
List<AutoRoute> get routes => [
20-
AutoRoute(page: LoginRoute.page),
21-
AutoRoute(page: SignupRoute.page),
22-
AutoRoute(
23-
initial: true,
24-
page: ListsRoute.page,
25-
guards: [_authGuard],
26-
),
27-
];
20+
List<AutoRoute> get routes {
21+
return [
22+
AutoRoute(page: LoginRoute.page),
23+
AutoRoute(page: SignupRoute.page),
24+
AutoRoute(
25+
page: LoggedInRoot.page,
26+
initial: true,
27+
guards: [_authGuard],
28+
children: [
29+
AutoRoute(
30+
initial: true,
31+
page: ListsRoute.page,
32+
),
33+
_dialogRoute(AddListRoute.page),
34+
CustomRoute(page: ListsDetailsRoute.page),
35+
_dialogRoute(AddItemRoute.page),
36+
],
37+
),
38+
];
39+
}
40+
41+
static CustomRoute _dialogRoute(PageInfo page) {
42+
return CustomRoute(
43+
page: page,
44+
customRouteBuilder: <T>(context, child, page) {
45+
return DialogRoute(
46+
context: context,
47+
builder: (_) => child,
48+
settings: page,
49+
);
50+
},
51+
);
52+
}
53+
}
54+
55+
@RoutePage(name: 'LoggedInRoot')
56+
final class LoggedInContents extends StatelessWidget {
57+
const LoggedInContents({super.key});
58+
59+
@override
60+
Widget build(BuildContext context) {
61+
return const AutoRouter();
62+
}
2863
}
2964

3065
final class _AuthGuard extends AutoRouteGuard {

demos/supabase-todolist-drift/lib/navigation.gr.dart

Lines changed: 130 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)