Skip to content

Commit

Permalink
Introduce app menu for grid layout
Browse files Browse the repository at this point in the history
  • Loading branch information
cadivus committed Oct 27, 2024
1 parent 93a90b8 commit 510dbf6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
24 changes: 12 additions & 12 deletions open_earable/lib/apps_tab/apps_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AppsTab extends StatelessWidget {

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

List<AppInfo> sampleApps(BuildContext context) {
static List<AppInfo> sampleApps(BuildContext context, OpenEarable openEarable) {
return [
AppInfo(
logoPath: "lib/apps_tab/recorder/assets/logo.png",
Expand All @@ -43,7 +43,7 @@ class AppsTab extends StatelessWidget {
builder: (context) => Material(
child: Theme(
data: materialTheme,
child: Recorder(_openEarable),
child: Recorder(openEarable),
),
),
),
Expand All @@ -63,8 +63,8 @@ class AppsTab extends StatelessWidget {
child: Theme(
data: materialTheme,
child: PostureTrackerView(
EarableAttitudeTracker(_openEarable),
_openEarable,
EarableAttitudeTracker(openEarable),
openEarable,
),
),
),
Expand All @@ -85,7 +85,7 @@ class AppsTab extends StatelessWidget {
child: Theme(
data: materialTheme,
child: Material(
child: JumpHeightTest(_openEarable),
child: JumpHeightTest(openEarable),
),
),
),
Expand All @@ -105,7 +105,7 @@ class AppsTab extends StatelessWidget {
builder: (context) => Material(
child: Theme(
data: materialTheme,
child: JumpRopeCounter(_openEarable),
child: JumpRopeCounter(openEarable),
),
),
),
Expand All @@ -123,7 +123,7 @@ class AppsTab extends StatelessWidget {
builder: (context) => Material(
child: Theme(
data: materialTheme,
child: StepCounter(_openEarable),
child: StepCounter(openEarable),
),
),
),
Expand All @@ -142,7 +142,7 @@ class AppsTab extends StatelessWidget {
builder: (context) => Material(
child: Theme(
data: materialTheme,
child: SleepHomeScreen(_openEarable),
child: SleepHomeScreen(openEarable),
),
),
),
Expand All @@ -161,7 +161,7 @@ class AppsTab extends StatelessWidget {
builder: (context) => Material(
child: Theme(
data: materialTheme,
child: TightnessMeter(_openEarable),
child: TightnessMeter(openEarable),
),
),
),
Expand All @@ -180,8 +180,8 @@ class AppsTab extends StatelessWidget {
child: Theme(
data: materialTheme,
child: StretchAppView(
EarableAttitudeTracker(_openEarable),
_openEarable,
EarableAttitudeTracker(openEarable),
openEarable,
),
),
),
Expand All @@ -195,7 +195,7 @@ class AppsTab extends StatelessWidget {

@override
Widget build(BuildContext context) {
List<AppInfo> apps = sampleApps(context);
List<AppInfo> apps = sampleApps(context, _openEarable);

return Padding(
padding: const EdgeInsets.only(top: 5),
Expand Down
40 changes: 40 additions & 0 deletions open_earable/lib/grid_home_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:open_earable/apps_tab/apps_tab.dart';
import 'package:open_earable/ble/ble_controller.dart';
import 'package:open_earable/ble/ble_tab_bar_page.dart';
import 'package:open_earable/controls_tab/models/open_earable_settings_v2.dart';
Expand Down Expand Up @@ -53,9 +54,21 @@ class _InternalGridHomePage extends StatelessWidget {

@override
Widget build(BuildContext context) {
List<AppInfo> sampleApps = AppsTab.sampleApps(context, openEarable);

return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
appBar: AppBar(
leading: Builder(
builder: (context) {
return IconButton(
icon: const Icon(Icons.menu),
onPressed: () {
Scaffold.of(context).openDrawer();
},
);
},
),
title: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -89,6 +102,33 @@ class _InternalGridHomePage extends StatelessWidget {
),
],
),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: sampleApps.map((appInfo) {
return ListTile(
leading: SizedBox(
height: 30.0,
width: 30.0,
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.asset(
appInfo.logoPath,
fit: BoxFit.cover,
),
),
),
title: Text(appInfo.title),
subtitle: Text(appInfo.description),
onTap: () {
// Close the drawer before launching the app
Navigator.of(context).pop();
appInfo.onTap();
},
);
}).toList(),
),
),
body: SquareChildrenGrid(
precalculatedRows: precalculatedRows,
precalculatedColumns: precalculatedColumns,
Expand Down

0 comments on commit 510dbf6

Please sign in to comment.