Commit 6ee97c5

derdilla <derdilla06@gmail.com>
2023-05-13 10:40:11
FIX: settings overflow on small screens
1 parent 38aeb86
lib/components/complex_settings.dart
@@ -29,22 +29,27 @@ class SettingsTile extends StatelessWidget {
         child: Row(
           children: [
             lead,
-            (() {
+            SizedBox(
+              width: MediaQuery.of(context).size.width - 150,
+              child: (() {
               if (description != null) {
                 return Column(
                   mainAxisSize: MainAxisSize.min,
                   crossAxisAlignment: CrossAxisAlignment.start,
                   children: [
                     title,
-                    DefaultTextStyle(
-                        style: const TextStyle(color: Colors.grey),
-                        child: description ?? const SizedBox.shrink()
+                    Flexible(
+                        child: DefaultTextStyle(
+                            style: const TextStyle(color: Colors.grey),
+                            overflow: TextOverflow.visible,
+                            child: description ?? const SizedBox.shrink()
+                        )
                     )
                   ],
                 );
               }
               return title;
-            })(),
+            })(),),
             const Expanded(child: SizedBox.shrink()),
             trail
           ],
lib/model/blood_pressure.dart
@@ -20,8 +20,12 @@ class BloodPressureModel extends ChangeNotifier {
   Future<void> _asyncInit(String? dbPath) async {
     dbPath ??= await getDatabasesPath();
 
+    if (dbPath != inMemoryDatabasePath) {
+      dbPath = join(dbPath, 'blood_pressure.db');
+    }
+
     _database = await openDatabase(
-      join(dbPath, 'blood_pressure.db'),
+      dbPath,
       // runs when the database is first created
       onCreate: (db, version) {
         return db.execute('CREATE TABLE bloodPressureModel(timestamp INTEGER(14) PRIMARY KEY, systolic INTEGER, diastolic INTEGER, pulse INTEGER, notes STRING)');
@@ -151,7 +155,6 @@ class BloodPressureModel extends ChangeNotifier {
 
     if (result != null) {
       var binaryContent = result.files.single.bytes;
-      print(binaryContent);
       if (binaryContent != null) {
         final csvContents = const CsvToListConverter().convert(
             String.fromCharCodes(binaryContent),
test/model/bood_pressure_test.dart
@@ -101,7 +101,6 @@ void main() {
 
       m.save((success, msg) {
         expect(success, true);
-        // TODO: rewrite blood_pressure to remove UI code entirely
       });
     });
   });
test/model/settings_test.dart
@@ -21,10 +21,10 @@ void main() {
     databaseFactory = databaseFactoryFfi;
 
     test('should initialize', () async {
-      expect(() async { await Settings.create(dbPath: '/tmp/setting_test/should_init'); }, returnsNormally);
+      expect(() async { await Settings.create(); }, returnsNormally);
     });
     test('fields defaults should be set after initialization', () async {
-      var s = await Settings.create(dbPath: '/tmp/setting_test/should_default');
+      var s = await Settings.create();
       expect(s.graphStepSize, TimeStep.day);
       expect(s.graphStart, DateTime.fromMillisecondsSinceEpoch(-1));
       expect(s.graphEnd, DateTime.fromMillisecondsSinceEpoch(-1));
@@ -40,7 +40,7 @@ void main() {
     });
 
     test('setting fields should save changes', () async {
-      var s = await Settings.create(dbPath: '/tmp/setting_test/should_save');
+      var s = await Settings.create();
 
       int i = 0;
       s.addListener(() {
@@ -80,7 +80,7 @@ void main() {
     });
 
     test('setting fields should notify listeners and change values', () async {
-      var s = await Settings.create(dbPath: '/tmp/setting_test/should_notify');
+      var s = await Settings.create();
 
       int i = 0;
       s.addListener(() {