Commit 1ef00dc

derdilla <82763757+derdilla@users.noreply.github.com>
2025-08-24 15:45:49
Fix home screen graph overlapping with notification bar (#592)
1 parent b3a0746
Changed files (2)
app
lib
test
app/lib/screens/home_screen.dart
@@ -25,7 +25,7 @@ class AppHome extends StatelessWidget {
   Widget _buildValueGraph(BuildContext context) => Column(
     children: [
       Padding(
-        padding: const EdgeInsets.only(right: 8, top: 16),
+        padding: const EdgeInsets.only(right: 8.0),
         child: SizedBox(
           height: 240.0,
           width: MediaQuery.of(context).size.width,
@@ -54,60 +54,60 @@ class AppHome extends StatelessWidget {
   );
 
   @override
-  Widget build(BuildContext context) => OrientationBuilder(
-    builder: (BuildContext context, Orientation orientation) {
-      // direct use of settings possible as no listening is required
-      if (_appStart == 0) {
-        if (Provider.of<Settings>(context, listen: false).startWithAddMeasurementPage) {
-          SchedulerBinding.instance.addPostFrameCallback((_) {
-            if (context.mounted) {
-              context.createEntry();
-              _appStart++;
-            } else {
-              _appStart--;
-            }
-          });
+  Widget build(BuildContext context) => SafeArea(
+    child: OrientationBuilder(
+      builder: (BuildContext context, Orientation orientation) {
+        // direct use of settings possible as no listening is required
+        if (_appStart == 0) {
+          if (Provider.of<Settings>(context, listen: false).startWithAddMeasurementPage) {
+            SchedulerBinding.instance.addPostFrameCallback((_) {
+              if (context.mounted) {
+                context.createEntry();
+                _appStart++;
+              } else {
+                _appStart--;
+              }
+            });
+          }
+          _appStart++;
         }
-        _appStart++;
-      }
-
-      if (showValueGraphAsHomeScreenInLandscapeMode && orientation == Orientation.landscape) {
-        return SafeArea(
-          child: Scaffold(
+    
+        if (showValueGraphAsHomeScreenInLandscapeMode && orientation == Orientation.landscape) {
+          return Scaffold(
             body: _buildValueGraph(context),
+          );
+        }
+        return DefaultTabController(
+          length: 2,
+          child: Scaffold(
+            body: CustomScrollView(
+              slivers: [
+                SliverToBoxAdapter(child: _buildValueGraph(context),),
+                if (!(context.select<Settings, bool>((s) => s.weightInput)))
+                  SliverFillRemaining(child: _buildMeasurementList(context)),
+    
+                if ((context.select<Settings, bool>((s) => s.weightInput)))
+                  const SliverToBoxAdapter(child: TabBar(
+                    tabs: [
+                      Tab(icon: Icon(Icons.monitor_heart)),
+                      Tab(icon: Icon(Icons.scale)),
+                    ],
+                  )),
+                if ((context.select<Settings, bool>((s) => s.weightInput)))
+                  SliverFillRemaining(
+                    child: TabBarView(
+                        children: [
+                          _buildMeasurementList(context),
+                          const WeightList(rangeType: IntervalStoreManagerLocation.mainPage),
+                        ]
+                    ),
+                  )
+              ],
+            ),
+            floatingActionButton: const NavigationActionButtons(),
           ),
         );
-      }
-      return DefaultTabController(
-        length: 2,
-        child: Scaffold(
-          body: CustomScrollView(
-            slivers: [
-              SliverToBoxAdapter(child: _buildValueGraph(context),),
-              if (!(context.select<Settings, bool>((s) => s.weightInput)))
-                SliverFillRemaining(child: _buildMeasurementList(context)),
-
-              if ((context.select<Settings, bool>((s) => s.weightInput)))
-                const SliverToBoxAdapter(child: TabBar(
-                  tabs: [
-                    Tab(icon: Icon(Icons.monitor_heart)),
-                    Tab(icon: Icon(Icons.scale)),
-                  ],
-                )),
-              if ((context.select<Settings, bool>((s) => s.weightInput)))
-                SliverFillRemaining(
-                  child: TabBarView(
-                      children: [
-                        _buildMeasurementList(context),
-                        const WeightList(rangeType: IntervalStoreManagerLocation.mainPage),
-                      ]
-                  ),
-                )
-            ],
-          ),
-          floatingActionButton: const NavigationActionButtons(),
-        ),
-      );
-    },
+      },
+    ),
   );
 }
app/test/screens/home_screen_test.dart
@@ -79,4 +79,13 @@ void main() {
     expect(find.ancestor(of: find.byType(BloodPressureValueGraph), matching: find.byType(Scaffold)), findsOneWidget);
     expect(find.ancestor(of: find.byType(BloodPressureValueGraph), matching: find.byType(MaterialApp)), findsOneWidget);
   });
+
+  testWidgets('includes safe area in phone mode', (tester) async {
+    await binding.setSurfaceSize(const Size(400, 800));
+
+    await tester.pumpWidget(await appBaseWithData(const AppHome()));
+    await tester.pumpAndSettle();
+
+    expect(find.byType(SafeArea), findsOneWidget);
+  });
 }