-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathpage_layout.dart
67 lines (63 loc) · 2.05 KB
/
page_layout.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../navigation.gr.dart';
import '../supabase.dart';
import 'app_bar.dart';
final class PageLayout extends ConsumerWidget {
final Widget content;
final Widget? title;
final Widget? floatingActionButton;
final bool showDrawer;
const PageLayout({
super.key,
required this.content,
this.title,
this.floatingActionButton,
this.showDrawer = true,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
appBar: StatusAppBar(
title: title ?? const Text('PowerSync Demo'),
),
body: Center(child: content),
floatingActionButton: floatingActionButton,
drawer: showDrawer
? Drawer(
// Add a ListView to the drawer. This ensures the user can scroll
// through the options in the drawer if there isn't enough vertical
// space to fit everything.
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: [
const DrawerHeader(
decoration: BoxDecoration(
color: Colors.blue,
),
child: Text(''),
),
ListTile(
title: const Text('SQL Console'),
onTap: () {
final route = context.topRoute;
if (route.name != SqlConsoleRoute.name) {
context.pushRoute(const SqlConsoleRoute());
}
},
),
ListTile(
title: const Text('Sign Out'),
onTap: () async {
ref.read(authNotifierProvider.notifier).signOut();
},
),
],
),
)
: null,
);
}
}