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

Commit f5d8504

Browse files
committed
redesign drawer
1 parent 00da985 commit f5d8504

File tree

2 files changed

+53
-25
lines changed

2 files changed

+53
-25
lines changed

lib/src/screens/category/category_screen.dart

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'package:nextcloud_cookbook_flutter/src/screens/recipe_import_screen.dart
1313
import 'package:nextcloud_cookbook_flutter/src/screens/recipes_list_screen.dart';
1414
import 'package:nextcloud_cookbook_flutter/src/screens/timer_screen.dart';
1515
import 'package:nextcloud_cookbook_flutter/src/widget/category_card.dart';
16+
import 'package:nextcloud_cookbook_flutter/src/widget/drawer_item.dart';
1617
import 'package:nextcloud_cookbook_flutter/src/widget/user_image.dart';
1718
import 'package:search_page/search_page.dart';
1819

@@ -222,7 +223,6 @@ class MainDrawer extends StatelessWidget {
222223
Widget build(BuildContext context) {
223224
return Drawer(
224225
child: ListView(
225-
// Important: Remove any padding from the ListView.
226226
padding: EdgeInsets.zero,
227227
children: <Widget>[
228228
DrawerHeader(
@@ -231,12 +231,9 @@ class MainDrawer extends StatelessWidget {
231231
),
232232
child: const UserImage(),
233233
),
234-
ListTile(
235-
trailing: Icon(
236-
Icons.alarm_add_outlined,
237-
semanticLabel: translate('timer.title'),
238-
),
239-
title: Text(translate('timer.title')),
234+
DrawerItem(
235+
icon: Icons.alarm_add_outlined,
236+
title: translate('timer.title'),
240237
onTap: () {
241238
Navigator.pop(context);
242239
Navigator.push(
@@ -247,12 +244,9 @@ class MainDrawer extends StatelessWidget {
247244
);
248245
},
249246
),
250-
ListTile(
251-
trailing: Icon(
252-
Icons.cloud_download_outlined,
253-
semanticLabel: translate('categories.drawer.import'),
254-
),
255-
title: Text(translate('categories.drawer.import')),
247+
DrawerItem(
248+
icon: Icons.cloud_download_outlined,
249+
title: translate('categories.drawer.import'),
256250
onTap: () {
257251
Navigator.pop(context);
258252
Navigator.push(
@@ -263,12 +257,9 @@ class MainDrawer extends StatelessWidget {
263257
);
264258
},
265259
),
266-
ListTile(
267-
trailing: Icon(
268-
Icons.settings_outlined,
269-
semanticLabel: translate('categories.drawer.settings'),
270-
),
271-
title: Text(translate('categories.drawer.settings')),
260+
DrawerItem(
261+
icon: Icons.settings_outlined,
262+
title: translate('categories.drawer.settings'),
272263
onTap: () async {
273264
await Navigator.push(
274265
context,
@@ -278,12 +269,9 @@ class MainDrawer extends StatelessWidget {
278269
);
279270
},
280271
),
281-
ListTile(
282-
trailing: Icon(
283-
Icons.exit_to_app_outlined,
284-
semanticLabel: translate('app_bar.logout'),
285-
),
286-
title: Text(translate('app_bar.logout')),
272+
DrawerItem(
273+
icon: Icons.exit_to_app_outlined,
274+
title: translate('app_bar.logout'),
287275
onTap: () {
288276
BlocProvider.of<AuthenticationBloc>(context)
289277
.add(const LoggedOut());

lib/src/widget/drawer_item.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import 'package:flutter/material.dart';
2+
3+
class DrawerItem extends StatelessWidget {
4+
const DrawerItem({
5+
required this.title,
6+
this.icon,
7+
this.onTap,
8+
super.key,
9+
});
10+
11+
final String title;
12+
final IconData? icon;
13+
final GestureTapCallback? onTap;
14+
15+
@override
16+
Widget build(BuildContext context) {
17+
final leading = icon != null
18+
? Icon(
19+
icon,
20+
semanticLabel: title,
21+
)
22+
: null;
23+
24+
return SizedBox(
25+
height: 56,
26+
child: ListTile(
27+
style: ListTileStyle.drawer,
28+
shape: const RoundedRectangleBorder(
29+
borderRadius: BorderRadius.all(
30+
Radius.circular(28),
31+
),
32+
),
33+
splashColor: Theme.of(context).colorScheme.secondaryContainer,
34+
leading: leading,
35+
title: Text(title),
36+
onTap: onTap,
37+
),
38+
);
39+
}
40+
}

0 commit comments

Comments
 (0)