Skip to content

Commit 510dbf6

Browse files
committed
Introduce app menu for grid layout
1 parent 93a90b8 commit 510dbf6

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

open_earable/lib/apps_tab/apps_tab.dart

+12-12
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AppsTab extends StatelessWidget {
3030

3131
const AppsTab(this._openEarable, {super.key});
3232

33-
List<AppInfo> sampleApps(BuildContext context) {
33+
static List<AppInfo> sampleApps(BuildContext context, OpenEarable openEarable) {
3434
return [
3535
AppInfo(
3636
logoPath: "lib/apps_tab/recorder/assets/logo.png",
@@ -43,7 +43,7 @@ class AppsTab extends StatelessWidget {
4343
builder: (context) => Material(
4444
child: Theme(
4545
data: materialTheme,
46-
child: Recorder(_openEarable),
46+
child: Recorder(openEarable),
4747
),
4848
),
4949
),
@@ -63,8 +63,8 @@ class AppsTab extends StatelessWidget {
6363
child: Theme(
6464
data: materialTheme,
6565
child: PostureTrackerView(
66-
EarableAttitudeTracker(_openEarable),
67-
_openEarable,
66+
EarableAttitudeTracker(openEarable),
67+
openEarable,
6868
),
6969
),
7070
),
@@ -85,7 +85,7 @@ class AppsTab extends StatelessWidget {
8585
child: Theme(
8686
data: materialTheme,
8787
child: Material(
88-
child: JumpHeightTest(_openEarable),
88+
child: JumpHeightTest(openEarable),
8989
),
9090
),
9191
),
@@ -105,7 +105,7 @@ class AppsTab extends StatelessWidget {
105105
builder: (context) => Material(
106106
child: Theme(
107107
data: materialTheme,
108-
child: JumpRopeCounter(_openEarable),
108+
child: JumpRopeCounter(openEarable),
109109
),
110110
),
111111
),
@@ -123,7 +123,7 @@ class AppsTab extends StatelessWidget {
123123
builder: (context) => Material(
124124
child: Theme(
125125
data: materialTheme,
126-
child: StepCounter(_openEarable),
126+
child: StepCounter(openEarable),
127127
),
128128
),
129129
),
@@ -142,7 +142,7 @@ class AppsTab extends StatelessWidget {
142142
builder: (context) => Material(
143143
child: Theme(
144144
data: materialTheme,
145-
child: SleepHomeScreen(_openEarable),
145+
child: SleepHomeScreen(openEarable),
146146
),
147147
),
148148
),
@@ -161,7 +161,7 @@ class AppsTab extends StatelessWidget {
161161
builder: (context) => Material(
162162
child: Theme(
163163
data: materialTheme,
164-
child: TightnessMeter(_openEarable),
164+
child: TightnessMeter(openEarable),
165165
),
166166
),
167167
),
@@ -180,8 +180,8 @@ class AppsTab extends StatelessWidget {
180180
child: Theme(
181181
data: materialTheme,
182182
child: StretchAppView(
183-
EarableAttitudeTracker(_openEarable),
184-
_openEarable,
183+
EarableAttitudeTracker(openEarable),
184+
openEarable,
185185
),
186186
),
187187
),
@@ -195,7 +195,7 @@ class AppsTab extends StatelessWidget {
195195

196196
@override
197197
Widget build(BuildContext context) {
198-
List<AppInfo> apps = sampleApps(context);
198+
List<AppInfo> apps = sampleApps(context, _openEarable);
199199

200200
return Padding(
201201
padding: const EdgeInsets.only(top: 5),

open_earable/lib/grid_home_page.dart

+40
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:open_earable/apps_tab/apps_tab.dart';
23
import 'package:open_earable/ble/ble_controller.dart';
34
import 'package:open_earable/ble/ble_tab_bar_page.dart';
45
import 'package:open_earable/controls_tab/models/open_earable_settings_v2.dart';
@@ -53,9 +54,21 @@ class _InternalGridHomePage extends StatelessWidget {
5354

5455
@override
5556
Widget build(BuildContext context) {
57+
List<AppInfo> sampleApps = AppsTab.sampleApps(context, openEarable);
58+
5659
return Scaffold(
5760
backgroundColor: Theme.of(context).colorScheme.surface,
5861
appBar: AppBar(
62+
leading: Builder(
63+
builder: (context) {
64+
return IconButton(
65+
icon: const Icon(Icons.menu),
66+
onPressed: () {
67+
Scaffold.of(context).openDrawer();
68+
},
69+
);
70+
},
71+
),
5972
title: Center(
6073
child: Row(
6174
mainAxisAlignment: MainAxisAlignment.center,
@@ -89,6 +102,33 @@ class _InternalGridHomePage extends StatelessWidget {
89102
),
90103
],
91104
),
105+
drawer: Drawer(
106+
child: ListView(
107+
padding: EdgeInsets.zero,
108+
children: sampleApps.map((appInfo) {
109+
return ListTile(
110+
leading: SizedBox(
111+
height: 30.0,
112+
width: 30.0,
113+
child: ClipRRect(
114+
borderRadius: BorderRadius.circular(8.0),
115+
child: Image.asset(
116+
appInfo.logoPath,
117+
fit: BoxFit.cover,
118+
),
119+
),
120+
),
121+
title: Text(appInfo.title),
122+
subtitle: Text(appInfo.description),
123+
onTap: () {
124+
// Close the drawer before launching the app
125+
Navigator.of(context).pop();
126+
appInfo.onTap();
127+
},
128+
);
129+
}).toList(),
130+
),
131+
),
92132
body: SquareChildrenGrid(
93133
precalculatedRows: precalculatedRows,
94134
precalculatedColumns: precalculatedColumns,

0 commit comments

Comments
 (0)