Skip to content

Commit d1fa424

Browse files
committed
Initial DB structure
1 parent aea6ef2 commit d1fa424

File tree

14 files changed

+615
-209
lines changed

14 files changed

+615
-209
lines changed

client/lib/base/app_bar/app_bar.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:time_keeper/base/app_bar/login_action.dart';
55
import 'package:time_keeper/base/app_bar/settings_action.dart';
66
import 'package:time_keeper/base/app_bar/theme_action.dart';
77
import 'package:time_keeper/colors.dart';
8+
import 'package:time_keeper/providers/auth_provider.dart';
89
import 'package:time_keeper/providers/health_provider.dart';
910
import 'package:time_keeper/router/app_routes.dart';
1011

@@ -34,12 +35,14 @@ class BaseAppBar extends ConsumerWidget implements PreferredSizeWidget {
3435
return null;
3536
}
3637

37-
Widget _leading(BuildContext context) {
38+
Widget _leading(BuildContext context, String username) {
3839
// Show home button only when not on home page
3940
final isHomePage = state.matchedLocation == '/';
4041

4142
if (isHomePage) {
42-
return SizedBox.shrink(); // Hide button on home page
43+
return Center(
44+
child: Text(username, style: TextStyle(fontWeight: FontWeight.bold)),
45+
); // Hide button on home page
4346
}
4447

4548
return IconButton(
@@ -51,10 +54,11 @@ class BaseAppBar extends ConsumerWidget implements PreferredSizeWidget {
5154
@override
5255
Widget build(BuildContext context, WidgetRef ref) {
5356
final isConnected = ref.watch(isConnectedProvider).value ?? false;
57+
final username = ref.watch(usernameProvider);
5458

5559
return AppBar(
5660
backgroundColor: isConnected ? null : supportErrorColor,
57-
leading: _leading(context),
61+
leading: _leading(context, username ?? ''),
5862
title: _title(isConnected, ref),
5963
actions: _actions(),
6064
);

client/lib/base/base_scaffold.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import 'package:go_router/go_router.dart';
33
import 'package:hooks_riverpod/hooks_riverpod.dart';
44
import 'package:time_keeper/base/app_bar/app_bar.dart';
55
import 'package:time_keeper/base/base_rail.dart';
6+
import 'package:time_keeper/generated/common/common.pbenum.dart';
7+
import 'package:time_keeper/providers/auth_provider.dart';
8+
import 'package:time_keeper/utils/permissions.dart';
69

710
class BaseScaffold extends HookConsumerWidget {
811
final GoRouterState state;
@@ -18,24 +21,26 @@ class BaseScaffold extends HookConsumerWidget {
1821
this.disableRail = false,
1922
});
2023

21-
bool get _showDrawerInd {
22-
final isHomePage = state.matchedLocation == '/';
23-
return !disableRail && !isHomePage;
24+
bool _showDrawerInd(bool hasPermissions) {
25+
return !disableRail && hasPermissions;
2426
}
2527

2628
@override
2729
Widget build(BuildContext context, WidgetRef ref) {
30+
final roles = ref.watch(rolesProvider);
31+
bool hasPermission = roles.any((r) => r.hasPermission(Role.STUDENT));
32+
2833
return Scaffold(
2934
appBar: BaseAppBar(state: state, showActions: showActions),
3035
body: Stack(
3136
children: [
3237
Row(
3338
children: [
34-
if (_showDrawerInd) const SizedBox(width: 48),
39+
if (_showDrawerInd(hasPermission)) const SizedBox(width: 48),
3540
Expanded(child: child),
3641
],
3742
),
38-
if (_showDrawerInd) BaseRail(),
43+
if (_showDrawerInd(hasPermission)) BaseRail(),
3944
],
4045
),
4146
);

0 commit comments

Comments
 (0)