Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
feat: adding buttons to system drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
RossComputerGuy committed Apr 30, 2024
1 parent 3ac1caa commit 8243557
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/views/desktop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class _DesktopViewState extends State<DesktopView> {
@override
Widget build(BuildContext context) =>
SystemLayout(
userMode: true,
body: Container(),
);
}
12 changes: 12 additions & 0 deletions lib/widgets/system_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ class SystemBar extends StatelessWidget implements PreferredSizeWidget {
Widget build(BuildContext context) =>
AppBar(
automaticallyImplyLeading: false,
leading: Scaffold.of(context).hasDrawer
? IconButton.filled(
onPressed: () {
final state = Scaffold.of(context);
if (state.isDrawerOpen) {
state.closeDrawer();
} else {
state.openDrawer();
}
},
icon: Icon(Icons.apps),
) : null,
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
actions: [
Scaffold.of(context).hasEndDrawer ?
Expand Down
37 changes: 35 additions & 2 deletions lib/widgets/system_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,47 @@ import '../logic/power.dart';
import 'power.dart';

class SystemDrawer extends StatelessWidget {
const SystemDrawer({ super.key });
const SystemDrawer({
super.key,
this.userMode = false,
});

final bool userMode;

@override
Widget build(BuildContext context) =>
Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: [
userMode ? Row(
children: [
Expanded(
child: ButtonBar(),
),
Align(
alignment: Alignment.centerRight,
child: ButtonBar(
children: [
IconButton(
style: IconButton.styleFrom(
shape: const LinearBorder(),
),
onPressed: () {},
icon: Icon(Icons.settings),
),
IconButton(
style: IconButton.styleFrom(
shape: const LinearBorder(),
),
onPressed: () {},
icon: Icon(Icons.power),
),
],
),
),
],
) : null,
StatefulBuilder(
builder: (context, setState) =>
PowerBar(
Expand All @@ -27,7 +60,7 @@ class SystemDrawer extends StatelessWidget {
),
),
),
],
].where((e) => e != null).toList().cast<Widget>(),
),
);
}
24 changes: 22 additions & 2 deletions lib/widgets/system_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ class SystemLayout extends StatelessWidget {
const SystemLayout({
super.key,
required this.body,
this.userMode = false,
this.bottomSheet,
});

final Widget body;
final bool userMode;
final Widget? bottomSheet;

Widget _buildMobile(BuildContext context) =>
Expand All @@ -34,7 +36,16 @@ class SystemLayout extends StatelessWidget {
GestureDetector(
child: ListTileTheme(
tileColor: Theme.of(context).colorScheme.background,
child: const SystemDrawer(),
child: IconButtonTheme(
data: IconButtonThemeData(
style: IconButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.background,
),
),
child: SystemDrawer(
userMode: userMode,
),
),
),
onVerticalDragDown: (details) => Backdrop.of(context).fling(),
),
Expand All @@ -56,7 +67,16 @@ class SystemLayout extends StatelessWidget {
endDrawer: Drawer(
child: ListTileTheme(
tileColor: Theme.of(context).colorScheme.inversePrimary,
child: const SystemDrawer(),
child: IconButtonTheme(
data: IconButtonThemeData(
style: IconButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
),
child: SystemDrawer(
userMode: userMode,
),
),
),
),
body: body,
Expand Down

0 comments on commit 8243557

Please sign in to comment.